eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
378 stars 144 forks source link

asadmin start-domain does not keep jvm-options order listed in domain.xml #18777

Closed glassfishrobot closed 12 years ago

glassfishrobot commented 12 years ago

asadmin start-domain does not keep jvm-options order listed in domain.xml So, it is impossible to start glassfish server with enabled JFR (java flight recorder)

Steps to reproduce:

  1. Set AS_JAVA in asenv.conf to use java with JFR, e.g. jdk 7u4
  2. Add to java-config section in domain.xml: -XX:+UnlockCommercialFeatures -XX:+FlightRecorder
  3. Execute: asadmin start-domain --verbose true

Jun 01, 2012 5:36:09 PM com.sun.enterprise.admin.launcher.GFLauncherLogger info INFO: JVM invocation command line: -XX:+UnlockDiagnosticVMOptions -XX:PermSize=64m -XX:MaxPermSize=192m -XX:+FlightRecorder -XX:NewRatio=2 -XX:+UnlockCommercialFeatures -Xmx512m -server -javaagent:/home/boris/glassfish3/glassfish/lib/monitor/flashlight-agent.jar -Dfelix.fileinstall.disableConfigSave=false -Dcom.ibm.xml.xlxp.support.dtd.compat.mode=false -Djavax.net.ssl.keyStore=/home/boris/glassfish3/glassfish/domains/domain1/config/keystore.jks -Djava.awt.headless=true -Dfelix.fileinstall.poll=5000 -Djava.endorsed.dirs=/home/boris/glassfish3/glassfish/modules/endorsed:/home/boris/glassfish3/glassfish/lib/endorsed -Dfelix.fileinstall.bundles.startTransient=true -Djavax.net.ssl.trustStore=/home/boris/glassfish3/glassfish/domains/domain1/config/cacerts.jks -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as -DANTLR_USE_DIRECT_CLASS_LOADING=true -Djava.security.auth.login.config=/home/boris/glassfish3/glassfish/domains/domain1/config/login.conf -Dgosh.args=--nointeractive -Dosgi.shell.telnet.maxconn=1 -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver -Dfelix.fileinstall.dir=/home/boris/glassfish3/glassfish/modules/autostart/ -Dosgi.shell.telnet.port=6666 -Djava.security.policy=/home/boris/glassfish3/glassfish/domains/domain1/config/server.policy -Dfelix.fileinstall.log.level=2 -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory -Dosgi.shell.telnet.ip=127.0.0.1 -Dcom.sun.aas.instanceRoot=/home/boris/glassfish3/glassfish/domains/domain1 -Dcom.sun.aas.installRoot=/home/boris/glassfish3/glassfish -Djava.ext.dirs=/opt/jdk7u4/lib/ext:/opt/jdk7u4/jre/lib/ext:/home/boris/glassfish3/glassfish/domains/domain1/lib/ext -Dfelix.fileinstall.bundles.new.start=true Error: To use 'FlightRecorder', first unlock using -XX:+UnlockCommercialFeatures. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Jun 01, 2012 5:36:09 PM com.sun.enterprise.admin.launcher.GFLauncherLogger info INFO: Successfully launched in 6 msec. Command start-domain failed. The DAS was stopped.

Affected Versions

[3.1.2_dev, 4.0]

glassfishrobot commented 6 years ago
glassfishrobot commented 12 years ago

@glassfishrobot Commented tmueller said: The root cause of this problem is that the JvmOptions class in launcher.jar uses a HashMap to store the parsed JVM options. The HashMap does not preserve ordering of the options.

glassfishrobot commented 12 years ago

@glassfishrobot Commented bnevins said: We get the jvm-options already in scrambled up order by the XML parser. The problem is NOT because we store things in a Map.

Note that these are the only known order-dependent JVM options.

Fix:

When post-processing the list, bubble to the beginning of the order all jvm-options that begin with "-XX:+Unlock"

glassfishrobot commented 12 years ago

@glassfishrobot Commented bnevins said: Note that we have been doing this for several releases already with:

-XX:+UnlockDiagnosticVMOptions

glassfishrobot commented 12 years ago

@glassfishrobot Commented bnevins said: d:\bg\all\main\nucleus\admin\launcher>svn commit Sending src\main\java\com\sun\enterprise\admin\launcher\JvmOptions.java Transmitting file data . Committed revision 54667.

==========

Simple change.

Before:

After:

Note: Assuming no order dependence between multiple unlocks.

Note: Super-easy to test! Simply add garbage jvm-option's that start with the above string. The JVM will not start but you can easily check that the order was correct by running:

asadmin start-domain -v

Example output after adding some fake strings:

C:\bin\jdk\bin\java.exe -cp D:/glassfish3/glassfish/modules/glassfish.jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9009 -XX:+UnlockDiagnosticVMOptions -XX:+UnlockFooBar -XX:+UnlockCommercialFeatures -XX:+Unlockzzzz -XX:MaxPermSize=192m -XX:NewRatio=2 -Xmx512m

glassfishrobot commented 11 years ago

@glassfishrobot Commented claes.redestad said: To workaround this on an older GF installation, for example 3.1.2.2, it's possible to set the required flags using debug-options and enable debug for the domain:

<java-config ... debug-enabled="true" debug-options="... -XX:+UnlockCommercialFeatures -XX:+FlightRecorder">

glassfishrobot commented 8 years ago

@glassfishrobot Commented grimmeld said: This is again an issue in glassfish 4.1

glassfishrobot commented 12 years ago

@glassfishrobot Commented Was assigned to bnevins

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-18777

glassfishrobot commented 12 years ago

@glassfishrobot Commented Reported by boris.molodenkov

glassfishrobot commented 12 years ago

@glassfishrobot Commented Marked as fixed on Wednesday, June 20th 2012, 11:04:12 am