I am trying to run the Jenkins war file with some additional java options as suggested here, but I get the exception:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at Main._main(Main.java:288)
at Main.main(Main.java:98)
Caused by: java.lang.IllegalArgumentException: Multiple command line argument specified: -XX:+CMSClassUnloadingEnabled
at winstone.cmdline.CmdLineParser.parse(CmdLineParser.java:68)
at winstone.Launcher.getArgsFromCommandLine(Launcher.java:391)
at winstone.Launcher.main(Launcher.java:359)
... 6 more
Since IllegalArgumentException is an unchecked exception, you don't have to handle it in your code: Java will let you compile just fine. In many cases, instead of trying to catch IllegalArgumentException , you can simply check that a value falls in the expected range before passing it to a method.
An IllegalArgumentException is thrown in order to indicate that a method has been passed an illegal argument. This exception extends the RuntimeException class and thus, belongs to those exceptions that can be thrown during the operation of the Java Virtual Machine (JVM).
My problem, pointed out by my co-worker, is that I was specifying the jar file before the options:
nohup nice /usr/bin/java -DJENKINS_HOME=/opt/jenkins/CI -Dorg.apache.commons.jelly.tags.fmt.timeZone=America/New_York -Djava.awt.headless=true -jar jenkins.war -XX:MaxPermSize=2048m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
It should have been:
nohup nice /usr/bin/java -DJENKINS_HOME=/opt/jenkins/CI -Dorg.apache.commons.jelly.tags.fmt.timeZone=America/New_York -Djava.awt.headless=true -XX:MaxPermSize=2048m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -jar jenkins.war
Simple mistake, but (aside from the documentation, which I unfortunately glossed over), I haven't seen anywhere that XX options must precede the jar file on the java command line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With