glassfish
  1. glassfish
  2. GLASSFISH-18777

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

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.2_b23, 4.0
    • Fix Version/s: 4.0
    • Component/s: admin
    • Labels:
      None

      Description

      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:
        <jvm-options>-XX:+UnlockCommercialFeatures</jvm-options>
        <jvm-options>-XX:+FlightRecorder</jvm-options>
      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.

        Activity

        Hide
        Tom Mueller added a comment -

        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.

        Show
        Tom Mueller added a comment - 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.
        Hide
        Byron Nevins added a comment -

        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"

        Show
        Byron Nevins added a comment - 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"
        Hide
        Byron Nevins added a comment -

        Note that we have been doing this for several releases already with:

        -XX:+UnlockDiagnosticVMOptions

        Show
        Byron Nevins added a comment - Note that we have been doing this for several releases already with: -XX:+UnlockDiagnosticVMOptions
        Hide
        Byron Nevins added a comment -

        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:

        • search for "-XX:+UnlockDiagnosticVMOptions"
        • if found move it to position 0

        After:

        • search for options that start with "-XX:+Unlock"
        • if found move it to top positions.

        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

        Show
        Byron Nevins added a comment - 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: search for "-XX:+UnlockDiagnosticVMOptions" if found move it to position 0 After: search for options that start with "-XX:+Unlock" if found move it to top positions. 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
        Hide
        Claes Redestad added a comment -

        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">

        Show
        Claes Redestad added a comment - 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">

          People

          • Assignee:
            Byron Nevins
            Reporter:
            Boris Molodenkov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: