Monday, May 23, 2011

Exception in thread "main" java.lang.NoClassDefFoundError + running sunspot:solr:run on windows

While running "sunspot:solr:run" on Windows ["sunspot:solr:run" works with windows otherwise use "sunspot:solr:start"] if you are receiving error like -
Exception in thread "main" java.lang.NoClassDefFoundError: 
'-Djava/util/logging/config/file=C:/DOCUME~1/pli/LOCALS~1/Temp/
logging/properties20100617-11284-furc4v-0'
Caused by: java.lang.ClassNotFoundException:
'-Djava.util.logging.config.file=C:.DOCUME~1.pli.LOCALS~1.Temp.
logging.properties20100617-11284-furc4v-0'
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: 
'-Djava.util.logging.config.file=C:/DOCUME~1/pli/LOCALS~1/Temp/
logging.properties20100617-11284-furc4v-0'.
  Program will exit.  
Please change line no. 74 in server.rb from lib of sunspot gem, 
"exec(Escape.shell_command(command))" 
with "exec(Escape.shell_command(command).gsub("'",'"'))"
For details refer source.

3 comments:

  1. good article , you have indeed cover the topic with great details. I have also documented my experience as 3 ways to resolve NoClassDefFoundError in Java
    . let me know if you find it useful.

    ReplyDelete
  2. Thank you so much! it works like a charm!

    ReplyDelete