setting JAVA_OPTS causes ClassNotFoundException #856

Closed
teaforthecat opened this Issue Nov 19, 2012 · 2 comments

Comments

2 participants

This particular value of JAVA_OPTS in .bashrc causes the problem.

Steps to reproduce:
in ~/.bashrc

export JAVA_OPTS="$JAVA_OPTS  -Dsolr.solr.home=/usr/lib/solr/" 
$ lein run
Exception in thread "main" java.lang.NoClassDefFoundError:  
Caused by: java.lang.ClassNotFoundException:  
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class:  . Program will exit.
Compilation failed: Subprocess failed
$  export JAVA_OPTS=
$ lein run
success
$  export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/lib/solr/" 
$ lein run
success

Now try it again with this value in bashrc, and a new shell.

export JAVA_OPTS="-Dsolr.solr.home=/usr/lib/solr/" 
$ lein run 
success

Could someone try to reproduce this please?

possibly related to issues #233, and #326 but I'm not sure.

$ lein -v
Leiningen 2.0.0-preview10 on Java 1.6.0_24 OpenJDK 64-Bit Server VM

Contributor

bruceadams commented Nov 19, 2012

I can reproduce the problem. The problem I see is triggered by the leading space in JAVA_OPTS. We should fix lein to not care about leading spaces. A workaround is to avoid putting the leading space in JAVA_OPTS. Trailing spaces don't trigger the issue (for me, anyway).

Instead of:

export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/lib/solr/"

please try:

export JAVA_OPTS="-Dsolr.solr.home=/usr/lib/solr/ $JAVA_OPTS"

Yep, removing the leading space fixes it. Thanks!

bruceadams added a commit to bruceadams/leiningen that referenced this issue Nov 19, 2012

michaelklishin pushed a commit that referenced this issue Nov 19, 2012

Merge pull request #857 from bruceadams/master
Bug fix for leading spaces in JVM_OPTS #856

@zloster zloster referenced this issue in TechEmpower/FrameworkBenchmarks Apr 4, 2017

Merged

Adjusting JVM parameters for Dropwizard, Jetty, Resin, Undertow #2652

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment