setting JAVA_OPTS causes ClassNotFoundException #856

teaforthecat opened this Issue Nov 19, 2012 · 2 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 Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
Could not find the main class:  . Program will exit.
Compilation failed: Subprocess failed
$  export JAVA_OPTS=
$ lein run
$  export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/lib/solr/" 
$ lein run

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

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

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


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


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