Setting JVM Options for Application Servers

JasperReports Server is supported on Java 1.6 and 1.7. Java Virtual Machine (JVM) runtime parameters normally need to be explicitly set so that the memory settings have values that are larger than the default settings. The options that you should set and the values they are set to depend on your version of Java and the application server that you use.

The settings in this section apply specifically to the Oracle/Sun JVM. Other JVMs may or may not have equivalent settings.

Tomcat and JBoss JVM Options

The following tables present some typical settings of JVM options that affect JasperReports Server. For information about changing a JVM option setting for your particular environment, see your application server documentation.

The following example settings are for 64-bit systems. For 32-bit systems, see Checking your Java JVM Options.

JVM Options on Windows (64 bit)

Options for Java 1.6 and 1.7

set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx2048m -XX:PermSize=32m

set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=512m -Xss2m -XX:+UseConcMarkSweepGC

set JAVA_OPTS=%JAVA_OPTS% -XX:+CMSClassUnloadingEnabled

Additional options for Java 1.6-1.7 and JBoss

set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.MessageFactory=org.apache.axis.soap.MessageFactoryImpl 
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPConnectionFactory=org.apache.axis.soap.SOAPConnectionFactoryImpl 
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPFactory=org.apache.axis.soap.SOAPFactoryImpl 

Additional option for JBoss 5.1

set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl

JasperReports Server doesn’t provide a virtual X frame buffer on Linux. If your Linux applications are graphical, set the ‑Djava.awt.headless=true to prevent Java from trying to connect to an X-Server for image processing.

JVM Options on Linux and Mac OSX (64 bit)

Options for Java 1.6 and 1.7

export JAVA_OPTS="$JAVA_OPTS -Xms1024m -Xmx2048m -XX:PermSize=32m"

export JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=512m -Xss2m"

export JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"

export JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled"

Additional options for Java 1.6-1.7 and JBoss

export JAVA_OPTS="$JAVA_OPTS -Djavax.xml.soap.MessageFactory=org.apache.axis.soap.MessageFactoryImpl" 
export JAVA_OPTS="$JAVA_OPTS -Djavax.xml.soap.SOAPConnectionFactory=org.apache.axis.soap.SOAPConnectionFactoryImpl"
export JAVA_OPTS="$JAVA_OPTS -Djavax.xml.soap.SOAPFactory=org.apache.axis.soap.SOAPFactoryImpl"

Additional option for JBoss 5.1

export JAVA_OPTS="$JAVA_OPTS -Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl"

There are a number of ways to set JVM options. Sections “Changing JVM Options for Bundled Tomcat as a Windows Service” - “Changing GlassFish JVM Options” present step-by-step instructions for performing this task. Alternatively, you can add your JAVA_OPTS settings to any one of these files:

File

Add JVM Options After This Line on Windows

<tomcat>/bin/setclasspath.bat

set JAVA_ENDORSED_DIRS=%BASEDIR%\common\endorsed

<tomcat>/bin/setenv.bat

JAVA_OPTS setting can go anywhere in this file.

<jboss>/bin/run.bat (JBoss 5.1)

set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME%

<jboss>/bin/standalone.bat (JBoss 7)

rem Setup JBoss specific properties

File

Add JVM Options After This Line on Linux

<tomcat>/bin/setclasspath.sh

JAVA_ENDORSED_DIRS="$BASEDIR"/common/endorsed

<tomcat>/bin/setenv.sh

JAVA_OPTS setting can go anywhere in this file.

<jboss>/bin/run.sh (JBoss 5.1)

export JAVA_OPTS="$JAVA_OPTS -Dprogram.name=$PROGNAME"

<jboss>/bin/standalone.sh (JBoss 7)

Add JAVA_OPTS setting before #Display our environment

Changing JVM Options for Bundled Tomcat as a Windows Service

The Windows binary installer installs the bundled Tomcat component as a Windows Service by default. The steps to change JVM options are:

1. Open this file for editing:

cd <js-install>/apache-tomcat/bin/service.bat

2. Look for the following line to change the JVM heap size, for example:
"%EXECUTABLE%" //US//%SERVICE_NAME% --Startup auto --JvmOptions "-Xms1024M;-Xmx2048M;-Xss2M;-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvm
3. Update this line to increase the maximum heap size from 2048M to 3072M, for example:

-Xmx3072M

4. Because Tomcat is installed as a service, you need to re-install the service. From a Windows Command shell, enter these commands (Note: the cmd shell will disappear when these commands are run. You need to open a new cmd shell for each command.). To open a cmd shell: Start Menu > Run... > cmd
cd <js-install>\apache-tomcat\scripts
serviceinstall.bat REMOVE
serviceinstall.bat INSTALL

The Tomcat service is removed and then installed. After execution of the commands, the service is running.

Changing JVM Options for Existing Tomcat as a Windows Service

If you installed JasperReports Server to use an existing Tomcat (not the bundled component) that is running as a Windows service, you can set Java options on the Java Tab of the Tomcat Properties dialog:

1. Launch the Tomcat configuration application from the Windows Start menu:

Start > Programs > Apache Tomcat > Configure Tomcat (Run as administrator)

2. In the Apache Tomcat Properties dialog, click the Java tab.
3. In the Java Options field, add your JAVA_OPTS values according to the tables above.

Enter only the options preceded by -X or -D, not set JAVA_OPTS=%JAVA_OPTS%.

Enter only one Java option setting per line.

4. For instance, add options as follows:

These example settings are for 64-bit systems. For 32-bit systems, see Checking your Java JVM Options.

-Xms1024m
-Xmx2048m
-XX:PermSize=32m
-XX:MaxPermSize=512m
-Xss2m
5. Click Apply, then click OK.
6. Stop and restart Tomcat.

Changing JVM Options for Bundled Tomcat on Linux

If, under Linux, you installed JasperReports Server to use the bundled Tomcat, you can set Java options by editing the appropriate Tomcat configuration script. The steps to change JVM options are:

1. Open the following file for editing:

cd <js-install>/apache-tomcat/scripts/ctl.sh

2. Look for the start_tomcat() function and locate the JAVA_OPTS variable inside it.
3. Modify the JAVA_OPTS values according to the tables above:
start_tomcat() {
	is_tomcat_running
	...
	     export JAVA_OPTS="-Xms1024m -Xmx2048m -XX:PermSize=32m -XX:MaxPermSize=512m"
            export JAVA_OPTS="-Xss2m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"
	...
}

There may be more than one occurrence of the Java_OPTS variable in the ctl.sh file. Make sure to edit the instance inside the start_tomcat() function.

4. Save and close the ctl.sh file.
5. Stop and restart PostgreSQL and Tomcat as described in Starting and Stopping JasperReports Server.

Changing GlassFish JVM Options

The following sections describe how to set the JVM options for GlassFish for Java 1.6 and 1.7 using the command line or a configuration file.

Setting GlassFish JVM Options with asadmin Command

1. First make sure your GlassFish instance is up and running, then enter the following command as a single line:
asadmin create-jvm-options -Xms1024m:-Xmx2048m:-XX\:PermSize=32m:
	-XX\:MaxPermSize=512m:-Xss2m:-XX\:+UseConcMarkSweepGC:
	-XX\:+CMSClassUnloadingEnabled:
	-Djavax.xml.soap.MessageFactory=org.apache.axis.soap.MessageFactoryImpl:
	-Djavax.xml.soap.SOAPConnectionFactory=org.apache.axis.soap.SOAPConnectionFactoryImpl:
	-Djavax.xml.soap.SOAPFactory=org.apache.axis.soap.SOAPFactoryImpl:
2. Restart the application server using the following commands:

asadmin stop-domain domain1

asadmin start-domain domain1

When running the asadmin create-jvm-options command, error messages like this might appear:

[exec] CLI167 Could not create the following jvm options. Options exist:
[exec] -Xmx512m
[exec] CLI137 Command create-jvm-options failed.

This message indicates that one of the options specified was already set in the JVM. The command will succeed for all other JVM options on the command line. No further action is necessary.

Setting GlassFish JVM Options by Editing domain.xml

1. Open the <glassfish>/domains/domain1/config/domain.xml configuration file for editing.
2. Add the following lines to the section entitled java-config:
<jvm-options>-Xms1024m -Xmx2048m -XX:PermSize=32m -XX:MaxPermSize=512m -Xss2
	-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
	-Djavax.xml.soap.MessageFactory=org.apache.axis.soap.MessageFactoryImpl
	-Djavax.xml.soap.SOAPConnectionFactory=org.apache.axis.soap.SOAPConnectionFactoryImpl
	-Djavax.xml.soap.SOAPFactory=org.apache.axis.soap.SOAPFactoryImpl
 
</jvm-options>
3. If you are modifying the settings for a running instance of GlassFish, restart the application server using the following commands:

asadmin stop-domain domain1

asadmin start-domain domain1

Version: 
Feedback