JBoss startup options questions

10,781

Solution 1

Why java exits with an 'unrecognized option' error

The order in which options are passed to java is relevant.

As Perception writes in his answer, -mp, -logmodule, and -jaxpmodule are JBoss options. The Oracle Help Center explains that these and other non-JVM options must be specified after class (the name of the class to be called) or after the -jar file.jar option:

java [JVM options] class [non-JVM options]
java [JVM options] -jar file.jar [non-JVM options]

(Non-JVM options are then passed to the main function of class or, when using -jar file.jar, to the main function in the startup class indicated by the Main-Class manifest header in the JAR file.)

That's why setting JBoss options in JAVA_OPTS won't work: they precede the -jar %JBOSS_HOME%\jboss-modules.jar option, as you can see in standalone.bat:

"%JAVA%" %JAVA_OPTS% ^
 "-Dorg.jboss.boot.log.file=%JBOSS_HOME%\standalone\log\boot.log" ^
 "-Dlogging.configuration=file:%JBOSS_HOME%/standalone/configuration/logging.properties" ^
-jar "%JBOSS_HOME%\jboss-modules.jar" ^
-mp "%MODULEPATH%" ^
-logmodule "org.jboss.logmanager" ^
-jaxpmodule "javax.xml.jaxp-provider" ^
 org.jboss.as.standalone ^
-Djboss.home.dir="%JBOSS_HOME%" ^
 %*

java complains because it expects a legal JVM option.

To your questions

Do I even need to set these JBoss startup options?

Those are default values, so no, you don't.

What is the best way to set these startup options?

You can add the JBoss options to the SERVER_OPTS variable, as it is appended to the end of the command.

For the curious: other JBoss options

You can list other JBoss options with java -jar %JBOSS_HOME%\jboss-modules.jar:

Usage: java [-jvmoptions...] -jar jboss-modules.jar [-options...] <module-spec> [args...]
   java [-jvmoptions...] -jar jboss-modules.jar [-options...] -jar <jar-name> [args...]
   java [-jvmoptions...] -jar jboss-modules.jar [-options...] -cp <class-path> <class-name> [args...]
   java [-jvmoptions...] -jar jboss-modules.jar [-options...] -class <class-name> [args...]
   java [-jvmoptions...] -jar jboss-modules.jar -addindex [-modify] <jar-name>

where <module-spec> is a valid module specification string
and options include:

    -help         Display this message
    -modulepath <search path of directories>
    -mp <search path of directories>
                  A list of directories, separated by ':', where modules may be located
                  If not specified, the value of the "module.path" system property is used
    -class        Specify that the final argument is a
                  class to load from the class path; not compatible with -jar
    -cp,-classpath <search path of archives or directories>
                  A search path for class files; implies -class
    -dep,-dependencies <module-spec>[,<module-spec>,...]
                  A list of module dependencies to add to the class path;
                  requires -class or -cp
    -deptree      Print the dependency tree of the given module instead of running it
    -jar          Specify that the final argument is the name of a
                  JAR file to run as a module; not compatible with -class
    -jaxpmodule <module-spec>
                  The default JAXP implementation to use of the JDK
    -secmgr       Run with a security manager installed; not compatible with -secmgrmodule
    -secmgrmodule <module-spec>
                  Run with a security manager module; not compatible with -secmgr
    -addindex     Specify that the final argument is a
                  jar to create an index for
    -modify       Modify the indexes jar in-place
    -version      Print version and exit

Solution 2

The -mp, -logmodule, and -jaxpmodule options belong to JBoss, not the Java interpreter. Your startup is failing because you included them in the list of Java options and the interpreter is choking (it doesn't recognize those options).

If you are not trying to circumvent standalone.bat then I see no reason to move those options to the standalone.conf.bat file.

EDIT

The default standalone.bat for JBoss 7.0.1 has the following entry:

:RESTART
"%JAVA%" %JAVA_OPTS% ^
 "-Dorg.jboss.boot.log.file=%JBOSS_HOME%\standalone\log\boot.log" ^
 "-Dlogging.configuration=file:%JBOSS_HOME%/standalone/configuration/logging.properties" ^
    -jar "%JBOSS_HOME%\jboss-modules.jar" ^
    -mp "%MODULEPATH%" ^
    -logmodule "org.jboss.logmanager" ^
    -jaxpmodule "javax.xml.jaxp-provider" ^
     org.jboss.as.standalone ^
    -Djboss.home.dir="%JBOSS_HOME%" ^
     %*

If you want to modify the -mp, -logmodule or -jaxpmodule values then simply do it in place, in the standalone.bat file. As an aside, looks like you are using default values, so no changes are even necessary.

Share:
10,781
user619804
Author by

user619804

Updated on September 10, 2022

Comments

  • user619804
    user619804 about 1 year

    I'm starting JBoss as7 via standalone.bat, which sources it's JAVA_OPTS startup options via standalone.conf.bat. I set most of my JAVA_OPTS in standalone.conf.bat, I have some questions about some JAVA_OPTS

    -mp "/opt/jboss-as-7.0.0.Final/modules" 
    -logmodule org.jboss.logmanager 
    -jaxpmodule javax.xml.jaxp-provider
    

    I tried setting these like

    set "JAVA_OPTS=%JAVA_OPTS% -mp /opt/jboss-as-7.0.0.Final/modules"
    set "JAVA_OPTS=%JAVA_OPTS% -logmodule org.jboss.logmanager"
    set "JAVA_OPTS=%JAVA_OPTS% -jaxpmodule javax.xml.jaxp-provider"
    

    in standalone.conf.bat. This doesn't seem to work, when I startup JBoss via standalone.bat, I get errors like 'unrecognized option -mp' or 'unrecognized option -logmodule'. If I remove these lines from my standalone.conf.bat, my JBoss is able to start successfully.

    My questions are - do I even need to set these JBoss startup options? I wasn't able to find much documentation about what they were, especially '-mp'. And if so, what is the best way to set these startup options? JBoss is not liking the syntax above. Any advice appreciated.