The OpenShift forums have been retired, but you can still read and search them.
For the most up-to-date information about how to use OpenShift please visit

How to pass JVM options to JBoss 7AS?


I was wondering where is the best (only?) place that I should specify JVM options that I want to pass to JBoss 7AS? Specifically, I'd like to set the timezone:


so that JBoss thinks it's in my timezone.


Have you tried using custom environment variables?:

For example, on your local repo, you can configure variables in your pre_start hook in the dir: {app_Repo_Dir}/.openshift/action_hooks/


@Kevin, as Nam mentioned this can be done in a couple of ways w/ adding a custom environment variable (JAVA_OPTS | _JAVA_OPTIONS) in your pre_start JBoss AS7 action hook (.openshift/action_hooks/pre_start_jbossas7).

Plan A: Via the JBoss java options: export JAVA_OPTS="-Duser.timezone=mytimezone"
Plan B: Via a env variable _JAVA_OPTIONS that the JVM would pick up: export _JAVA_OPTIONS="-Duser.timezone=mytimezone"


thanks guys...I tried adding .openshift/action_hooks/pre_start_jbossas7, made it executable, put in

export JAVA_OPTS="-Duser.timezone=mytimezone"

but I don't think it worked (my application is still behaving like it's in the same timezone) do I check the command line options that are being picked up by the server to see if my variable got in there or not? A log file somewhere?

sorry, I just don't understand how the git hooks work yet and where everything goes...

You can check the boot.log to see what JBoss is using and if its picking up the -X options you set.

The action_hooks are called in a particular order on git push (stop, build, deploy, pre/start/post for example if hot_deploy is not involved). The action_hooks are also chained on app start (pre/start/post).

Hope that helps;

thanks, that helped. I found it and found that JAVA_OPTS seems to not work, but JAVA_OPTIONS does seem to work:

export JAVA_OPTS="-Duser.timezone=America/Regina"

then the log file:

    user.timezone = GMT-05:00

-Dorg.jboss.boot.log.file=/var/lib/stickshift/changedforsecurityreasons/app1/jbossas-7/standalone/log/boot.log -Dlogging.configuration=file:/var/lib/stickshift/changedforsecurityreasons/app1/jbossas-7/standalone/configuration/

so, it didn't pick it I tried to put an underscore before the variable:

export _JAVA_OPTS="-Duser.timezone=America/Regina"

and the log file after that change:

    user.timezone =  America/New_York

21:28:27,031 DEBUG [] VM Arguments: -D[Standalone] -Xmx256m -XX:MaxPermSize=128m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true -Dorg.jboss.resolver.warning=true -Dfile.encoding=UTF-8 -Djgroups.bind_addr= -Dorg.jboss.boot.log.file=/var/lib/stickshift/changedforsecurityreasons/app1/jbossas-7/standalone/log/boot.log -Dlogging.configuration=file:/var/lib/stickshift/changedforsecurityreasons/app1/jbossas-7/standalone/configuration/

well, that seemed to change the timezone, but still the wrong timezone...and it seems like the other default VM arguments are there now. Finally, I tried _JAVA_OPTIONS:

export _JAVA_OPTIONS="-Duser.timezone=America/Regina"

and the log file showing it worked:

     user.timezone = America/Regina

19:39:59,740 DEBUG [] VM Arguments: -D[Standalone] -Xmx256m -XX:MaxPermSize=128m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true -Dorg.jboss.resolver.warning=true -Dfile.encoding=UTF-8 -Djgroups.bind_addr= -Dorg.jboss.boot.log.file=/var/lib/stickshift/changedforsecurityreasons/app1/jbossas-7/standalone/log/boot.log -Dlogging.configuration=file:/var/lib/stickshift/changedforsecurityreasons/app1/jbossas-7/standalone/configuration/ -Duser.timezone=America/Regina

there...finally it picked up my timezone.

Any ideas why JAVA_OPTS doesn't work but _JAVA_OPTIONS does work?

@Kevin, the _JAVA_OPTIONS env variable value is picked up by the JVM and hence that one's independent of what code you are running inside the jvm and will always work.

The JAVA_OPTS variable on the other hand is handled by jboss (in -- seems like its not being picked up correctly.

1.When Web app in Tomcat

export JAVA_OPTS="-Duser.timezone=Asia/Shanghai"

then: ctl_app stop

after stop,then: ctl_app start

OK,Well done.

2.if jar file app: java -Duser.timezone=Asia/Shanghai -jar TestServerTime.jar

OK,Good job.

In the yourapp.openshift\config\ you can add your property for the jvm. Push the change and will reflect.

Good luck.