Liferay Development

Liferay Consulting

Liferay Training

Your Trusted Liferay Solutions Partner

Saturday, March 21, 2020

Add new JVM arguments to Liferay Portal Tomcat Server


Sometimes we may need to add new JVM arguments to Liferay Portal Tomcat server.

We have different ways to add JVM arguments to server and here are the options.
Tomcat provided setenv.bat and setenv.sh files in bin directory and we will add new JVM arguments in these files under “CATALINA_OPTS” variable.

JVM Argument syntax


-D[ARGUMENT_NAME]=[ARGUMENT_VALUE]


Windows Operating System

In Windows Operating system, we have to use setenv.bat file to add new JVM arguments
Open setenv.bat file in editor and add your JVM argument as follows and save the file


set "CATALINA_OPTS=%CATALINA_OPTS% -Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory"


Make sure we have to keep the %CATALINA_OPTS% always which means that we are adding new JVM arguments along with existing arguments.
You can also create your custom options and finally append to “CATALINA_OPTS”

Example:


set "LIFERAY_OPTS=-Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory"

set "CATALINA_OPTS=%CATALINA_OPTS% %LIFERAY_OPTS%"



Unix/Linux Family Operating Systems

Open setenv.sh file in editor and add your JVM argument as follows and save the file


CATALINA_OPTS="$CATALINA_OPTS -Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory "


Make sure we have to keep the $CATALINA_OPTS always which means that we are adding new JVM arguments along with existing arguments.

You can also create your custom options and finally append to “CATALINA_OPTS”

Example:


LIFERAY_OPTS="-Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory"

CATALINA_OPTS="$CATALINA_OPTS $ LIFERAY_OPTS"



Liferay Portal already have many existing CATALINA_OPTS and we have to add new JVM argument to existing list.

setenv.bat

Example setenv.bat file in Liferay Portal Tomcat (tomcat-9.0.17\bin)


set "CATALINA_OPTS=%CATALINA_OPTS% -Dfile.encoding=UTF8 -Djava.locale.providers=JRE,COMPAT,CLDR -Djava.net.preferIPv4Stack=true -Duser.timezone=GMT -Xms2560m -Xmx2560m -XX:MaxNewSize=1536m -XX:MaxMetaspaceSize=512m -XX:MetaspaceSize=512m -XX:NewSize=1536m -XX:SurvivorRatio=7"
set "CATALINA_OPTS=%CATALINA_OPTS% -Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory"


setenv.sh


CATALINA_OPTS="$CATALINA_OPTS -Dfile.encoding=UTF8 -Djava.locale.providers=JRE,COMPAT,CLDR -Djava.net.preferIPv4Stack=true -Duser.timezone=GMT -Xms2560m -Xmx2560m -XX:MaxNewSize=1536m -XX:MaxMetaspaceSize=512m -XX:MetaspaceSize=512m -XX:NewSize=1536m -XX:SurvivorRatio=7"
CATALINA_OPTS="$CATALINA_OPTS -Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory"


Restart servers then new configuration applies to the server.

Liferay IDE/Liferay Developer Studio

If you are using Liferay IDE/Liferay Developer Studio then use server configuration to add new JVM arguments.

Servers View --> Double Click on Liferay Server --> Open Launch Configuration --> Click Arguments --> Edit VM arguments Input

Its editable text area and we can add new variable as follows and Make sure each argument separated by SPACE.


Restart server then new configuration applies to the server.

IntelliJ Idea

If you are using IntelliJ Idea Liferay Plugin Developer Studio then use server configuration to add new JVM arguments

Liferay Server Edit Configuration


Add new JVM arguments in VM Options list as follows and click on OK then configuration will be saved. Make sure each argument separated by SPACE.

Example


-Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory



Restart server then new configuration applies to the server.

Author

0 comments :

Post a Comment

Recent Posts

Recent Posts Widget

Popular Posts