Setting JVM Options for Application Servers

Java Virtual Machine (JVM) runtime parameters normally need to be explicitly set so that the memory settings have values larger than the default settings. The options and values depend on your version of Java and the application server you use. For a list of supported JDK/JVMs and application servers, see the TIBCO Jaspersoft Platform Support document on the Documentation section of the Jaspersoft Community website.

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

For the Oracle database, setting the Oracle localization option, defaultNChar, can substantially impact the performance of JDBC queries. If you do not need to support UTF-8 for your Oracle database, you can omit this setting.

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 Setting your Java JVM Options.

JVM Options on Windows (64 bit)

Options for all app servers

set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx2048m -Xss2m

set JAVA_OPTS=%JAVA_OPTS% -XX:+UseConcMarkSweepGC

set JAVA_OPTS=%JAVA_OPTS% -XX:+CMSClassUnloadingEnabled

Additional options for JDK 1.7 set JAVA_OPTS=%JAVA_OPTS% -XX:PermSize=32m -XX:MaxPermSize=512m

For Oracle

set JAVA_OPTS=%JAVA_OPTS% -Doracle.jdbc.defaultNChar=true

Additional options for 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 EAP 6.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 all app servers, all JDKs

export JAVA_OPTS="$JAVA_OPTS -Xms1024m -Xmx2048m -Xss2m"

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

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

Additional options for JDK 1.7 export JAVA_OPTS="$JAVA_OPTS -XX:PermSize=32m -XX:MaxPermSize=512m "

For Oracle

export JAVA_OPTS="$JAVA_OPTS -Doracle.jdbc.defaultNChar=true"

Additional options for 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 EAP 6.1

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

You can set JVM options multiple ways. Sections “Changing JVM Options for 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 of the following 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\standalone.conf.bat

Find the existing JAVA_OPTS line, remove the default memory settings from this line, and add a new line with the recommended JAVA_OPTS after this line.

(For example, for JBoss EAP 6.1 on JDK 1.7, remove

Xms1303M -Xmx1303M -XX:MaxPermSize=256" and add the recommended settings on a new line.)

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/standalone.conf

Find the existing JAVA_OPTS line, remove the default memory settings from this line, and add a new line with the recommended JAVA_OPTS after this line.

(For example, for JBoss EAP 6.1 on JDK 1.7, remove

Xms1303M -Xmx1303M -XX:MaxPermSize=256 and add the recommended settings on a new line.)

Changing JVM Options for Tomcat as a Windows Service

If you installed JasperReports Server to use Tomcat 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. If you installed the bundled Tomcat, you can do this by going to the <js-install>/apache-tomcat/bin directory and double-clicking the jasperreportsTomcat.exe file. (If you have multiple instances of JasperReports Server installed, the file name will be of the form jasperreportsTomcatnum<number>.exe, for example, jasperreportsTomcatnum2.exe.) If you installed Tomcat using an existing Windows service, look for an .exe file in the same location, with the same name as your Tomcat service, or select the service 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, on JDK 1.7, add options as follows:
-Xms1024m
-Xmx2048m
-XX:PermSize=32m
-XX:MaxPermSize=512m
-Xss2m

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

5. Click Apply, then click OK.
6. Stop and restart Tomcat.

Changing JVM Options for Bundled Tomcat on Linux

If you installed 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. For example, on JDK 1.7:
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 you 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 the Server.

Changing GlassFish JVM Options

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

Setting GlassFish JVM Options with the asadmin Command

1. First make sure your GlassFish instance is up and running, then enter the command as a single line. For example, on JDK 1.7:
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:<MadCap:conditionalText data-mc-conditions="JasperConditions.Pro">
	-Doracle.jdbc.defaultNChar=true</MadCap:conditionalText>

If you're not using an Oracle database, you can omit the last option in the example above.

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, you may see error messages like this:

[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 appropriate lines to the section java-config. For example, on JDK 1.7:
<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<MadCap:conditionalText data-mc-conditions="JasperConditions.Pro">
	-Doracle.jdbc.defaultNChar=true</MadCap:conditionalText>
</jvm-options>

If you're not using an Oracle database, you can omit the last option in the example above.

3. If you're 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

Feedback
randomness