"sunspot-solr run" doesn't start on windows
Reported by Scott Simon | March 6th, 2010 @ 02:42 PM | in Wishlist
From a fresh install of sunspot 1.0.1 on Windows XP:
sunspot-solr run
Running : java
-Dsolr.data.dir=C:/DOCUME~1/Scottley/LOCALS~1/temp
-Dsolr.solr.home=c:/ruby/lib/ruby/gems/1.8/gems/sunspot-1.0.1/solr/solr
-jar start.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
'-Dsolr/data/dir=C:/DOCUME~1/Scottley/LOCALS~1/temp'
Caused by: java.lang.ClassNotFoundException:
'-Dsolr.data.dir=C:.DOCUME~1.Scottley.LOCALS~1.temp'
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: '-Dsolr.data.dir=C:/DOCUME~1/Scottley/LOCALS~1/temp'. Program will exit.
Problem stems from Escape gem putting single quotes around
entire arguments that contain paths with backslashes (Windows
style) -- thus java thinks '-Dsolr.data.dir....' is the file to
run, not an argument.
Replacing Escape.shell_commands(command) with command.join(" ") fixed the issue on my system and solr started up fine.
Comments and changes to this ticket
-

-

mat March 10th, 2010 @ 02:50 PM
- → State changed from new to patches-welcome
Can't just ditch the Escape library -- it's needed for cases when directory names have space, etc. Would welcome a patch tested by a Windows user that solves the problem without regressions.
-

Kandada Boggu April 12th, 2010 @ 04:52 PM
I have created a patch for this issue. The change is specific to
Sunspot::Server.runmethod. The patch callsEscape.shell_commandon the file input parameters instead of the entire command string.E.g:
command << "-Dsolr.data.dir=#{Escape.shell_command(solr_data_dir)}"instead of
command << "-Dsolr.data.dir=#{solr_data_dir}"Refer to the attached patch for more details.
-

Kandada Boggu April 12th, 2010 @ 05:19 PM
This might not be a Windows specific issue. Same issue might occur in other operating system if the value of
solr_homeORsolr_data_dirhas a space.E.g.
If
solr_homeis/user/foo/bar net, then the command executed is as follows:java '-Dsolr.solr.home=/user/foo/bar net' ..The
javacommand will not interpret -D option enclosed inside single quotes and hence throw an error. The correct command syntax should be as follows:java -Dsolr.solr.home='/user/foo/bar net' .. -

mat December 27th, 2010 @ 02:50 PM
- → Milestone changed from Bugs to Wishlist
- → Tag changed from java, solr, windows to bug
-

FutureKode April 28th, 2011 @ 07:17 AM
any update on a fix for this? Or is the patch still the best way?
-

Tom Russell July 3rd, 2011 @ 09:02 AM
I encountered this issue as well, and I patched the server.rb file in a similar (but worse) manner to Kandada - https://github.com/kalleth/sunspot/commit/f8b69d79cc8bbe50c24dd59ac....
His patch is the better way to do it though, but at least it confirms that the issue is reproducible by multiple people, and a similar fix fixes it.
-

Scott Schneider September 14th, 2011 @ 10:29 PM
Hi, Kandadu- Your patch does not work for me (on Windows). It looks to me like we are passing strings (rather than arrays) into the new Escape.shell_command() calls.
I get "undefined method 'map' for http://outoftime.lighthouseapp.com/projects/20339/tickets/126-java-... . Though I understand that's a total hack!
-

Scott Schneider September 14th, 2011 @ 10:58 PM
Oops, some of that didn't come through. Let me try again.
I get "undefined method 'map' for (data development path name in quotes):String". Trace shows the top 2 levels as escape.rb:53 (which is Escape.shell_command()) and sunspot/server.rb:69 (which is the first line where we added the call to Escape.shell_command()).
What worked for me is adding .gsub("'",'"') on line 74, as in http://outoftime.lighthouseapp.com/projects/20339/tickets/126-java-... . Though I understand that's a total hack!
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Awesome Solr interaction for Ruby