Solr
  1. Solr
  2. SOLR-7016

techproducts example does not start on windows with "solr.cmd -e techproducts" if install dir contains whitespace

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.10.4, 5.0, 5.1, 6.0
    • Component/s: scripts and tools
    • Labels:
      None

      Description

      If you try to start the techproducts example on windows with "solr.cmd -e techproducts" it fails if install dir contains whitespace:

      C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr1\solr\bin>solr.cmd -e techproducts -p 8984
      Ein Unterverzeichnis oder eine Datei mit dem Namen "C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr1\solr\example\techproducts\s
      olr" existiert bereits.
      Backing up C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr1\solr\example\techproducts\solr\..\logs\solr_gc.log
              1 Datei(en) verschoben.
      
      Starting Solr on port 8984 from C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr1\solr\server
      
      Zugriff verweigert
      
      Gewartet wird 10 Sekunden. Weiter mit beliebiger Taste...Fehler: Hauptklasse Schindler\Projects\lucene\trunk-lusolr1\solr\example\re
      sources\log4j.properties konnte nicht gefunden oder geladen werden
                     0
      SLF4J: Class path contains multiple SLF4J bindings.
      SLF4J: Found binding in [jar:file:/C:/Users/Uwe%20Schindler/Projects/lucene/trunk-lusolr1/solr/server/lib/ext/slf4j-log4j12-1.7.6.ja
      r!/org/slf4j/impl/StaticLoggerBinder.class]
      SLF4J: Found binding in [jar:file:/C:/Users/Uwe%20Schindler/Projects/lucene/trunk-lusolr1/solr/server/lib/ext/slf4j-log4j12-1.7.7.ja
      r!/org/slf4j/impl/StaticLoggerBinder.class]
      SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
      SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
      WARN  - 2015-01-22 12:40:23.866; org.apache.solr.util.SolrCLI; Request to http://localhost:8984/solr/admin/info/system failed due to
      : Connection refused: connect, sleeping for 5 seconds before re-trying the request ...
      Exception in thread "main" java.net.ConnectException: Connection refused: connect
              at java.net.DualStackPlainSocketImpl.connect0(Native Method)
              at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
              at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
              at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
              at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
              at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
              at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
              at java.net.Socket.connect(Socket.java:589)
              at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
              at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178)
              at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
              at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
              at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
              at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
              at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
              at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:214)
              at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:160)
              at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:136)
              at org.apache.solr.util.SolrCLI.getJson(SolrCLI.java:503)
              at org.apache.solr.util.SolrCLI.getJson(SolrCLI.java:456)
              at org.apache.solr.util.SolrCLI.getJson(SolrCLI.java:466)
              at org.apache.solr.util.SolrCLI$CreateCoreTool.runTool(SolrCLI.java:1379)
              at org.apache.solr.util.SolrCLI.main(SolrCLI.java:203)
      
      Indexing tech product example docs from C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr1\solr\example\exampledocs
      Error: Unable to access jarfile C:\Users\Uwe
      
      Solr techproducts example launched successfully.
      Direct your Web browser to http://localhost:8984/solr to visit the Solr Admin UI
      
      
      C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr1\solr\bin>
      

      Basically there are some quotes missing, which leads to the fact that it thinks "log4j.properties" is the java class to be started. I tried to fix it but got lost in the script.

      1. SOLR-7016.patch
        14 kB
        Timothy Potter
      2. SOLR-7016.patch
        13 kB
        Timothy Potter
      3. SOLR-7016-lucene_solr_4_10.patch
        12 kB
        Steve Rowe
      4. SOLR-7016-lucene_solr_4_10.patch
        12 kB
        Steve Rowe

        Issue Links

          Activity

          Hide
          Uwe Schindler added a comment -

          In addition, on Trunk this makes "ant run-example" fail, too. In 5.x, "ant run-example" still runs the example the old way (which I prefer).

          Show
          Uwe Schindler added a comment - In addition, on Trunk this makes "ant run-example" fail, too. In 5.x, "ant run-example" still runs the example the old way (which I prefer).
          Hide
          Uwe Schindler added a comment -

          In addition most scripts print "access denied" all the time with spaces in installation folder, but succeed sometimes. This affects all scripts, not only the "techproducts" example.

          Show
          Uwe Schindler added a comment - In addition most scripts print "access denied" all the time with spaces in installation folder, but succeed sometimes. This affects all scripts, not only the "techproducts" example.
          Hide
          Anshum Gupta added a comment -

          I tried running this on an AWS windows instance (I haven't used windows in almost a decade now) and got the errors. I tried debugging a bit and seems like it's the log4j.properties path that screws up the call to start Solr, which in turn leads to Solr not starting up at all.

          The indexer fails for that reason.

          From what I read up, all the spaces need to be in quotes and a few of aren't. After a few random fixes I was try to get Solr to run in standalone mode in a directory named 'Test Dir' i.e. with a space but I am not confident with what I did.
          I'll try working on it more but I think it'd be way more productive for someone else (who is happy working on and understands windows) to take it up.

          Show
          Anshum Gupta added a comment - I tried running this on an AWS windows instance (I haven't used windows in almost a decade now) and got the errors. I tried debugging a bit and seems like it's the log4j.properties path that screws up the call to start Solr, which in turn leads to Solr not starting up at all. The indexer fails for that reason. From what I read up, all the spaces need to be in quotes and a few of aren't. After a few random fixes I was try to get Solr to run in standalone mode in a directory named 'Test Dir' i.e. with a space but I am not confident with what I did. I'll try working on it more but I think it'd be way more productive for someone else (who is happy working on and understands windows) to take it up.
          Show
          Anshum Gupta added a comment - This might help : http://stackoverflow.com/questions/6376113/spaces-problem-in-cmd
          Hide
          Timothy Potter added a comment - - edited

          This patch addresses two issues going on with Windows. First, dealing with Solr being installed in a location that has spaces in the path. I tested using:

          c:\Program Files\solr-5.0.0\solr installed here\
          

          Also, there were some issues with the port / pid resolution when you open up a browser and hit the Solr server, a bunch of new processes get found that match when doing:

          netstat -aon | find "TCP " | find ":8983 "
          

          Lastly, bin\solr stop -all is implemented in this script and works as expected for me. Please try this out ASAP as it is a blocker for the 5.0 release.

          Show
          Timothy Potter added a comment - - edited This patch addresses two issues going on with Windows. First, dealing with Solr being installed in a location that has spaces in the path. I tested using: c:\Program Files\solr-5.0.0\solr installed here\ Also, there were some issues with the port / pid resolution when you open up a browser and hit the Solr server, a bunch of new processes get found that match when doing: netstat -aon | find "TCP " | find ":8983 " Lastly, bin\solr stop -all is implemented in this script and works as expected for me. Please try this out ASAP as it is a blocker for the 5.0 release.
          Hide
          Uwe Schindler added a comment -

          Hi,
          patch works for me! I can start the techproducts example. I also no longer get strange "Access Denied" error messages all the time during startup. Shutting down Solr with "-all" works fine.

          Starting Solr with "ant run-example" still fails because the script cannot start in non-interactive mode. I would like to do this also on windows here. But this is just an issue of trunk. In 5.0 and 5.x the run-example ant task still starts everything as usual with start.jar (not detached, god thanks). I would like to maybe restore this in Solr trunk, too. I have no idea why this was only committed to build.xml in trunk.

          Thanks, Uwe

          Show
          Uwe Schindler added a comment - Hi, patch works for me! I can start the techproducts example. I also no longer get strange "Access Denied" error messages all the time during startup. Shutting down Solr with "-all" works fine. Starting Solr with "ant run-example" still fails because the script cannot start in non-interactive mode. I would like to do this also on windows here. But this is just an issue of trunk. In 5.0 and 5.x the run-example ant task still starts everything as usual with start.jar (not detached, god thanks). I would like to maybe restore this in Solr trunk, too. I have no idea why this was only committed to build.xml in trunk. Thanks, Uwe
          Hide
          Timothy Potter added a comment -

          Thanks for testing Uwe.

          Reverting back to using start.jar won't get you much since there's no longer a built-in collection1. So all you can really do is start the server, unless I'm missing something? The script can't run an example in the foreground since it needs to execute commands (create core and post docs) after the server starts. Why don't we just get rid of the run-example target as doing: ant server && bin\solr -e techproducts is the same.

          Not sure about why that fix didn't get ported to the other branches ... most likely my fault.

          Show
          Timothy Potter added a comment - Thanks for testing Uwe. Reverting back to using start.jar won't get you much since there's no longer a built-in collection1. So all you can really do is start the server, unless I'm missing something? The script can't run an example in the foreground since it needs to execute commands (create core and post docs) after the server starts. Why don't we just get rid of the run-example target as doing: ant server && bin\solr -e techproducts is the same. Not sure about why that fix didn't get ported to the other branches ... most likely my fault.
          Hide
          Mark Miller added a comment -

          Why don't we just get rid of the run-example target

          I'm -1 on dropping the target. I'd rather just improve it so that it works like it used to - not spawning some background process and stopping with ctrl + c, etc. This is much less fun in my eclipse workflow than it used to be. I think perhaps going back to the jar way of starting is not such a bad idea.

          Starting with a collection is not a priority, making it easy to add one is, in which case I just want to start solr via ant in eclipse, and it doesn't need to auto create anything.

          Show
          Mark Miller added a comment - Why don't we just get rid of the run-example target I'm -1 on dropping the target. I'd rather just improve it so that it works like it used to - not spawning some background process and stopping with ctrl + c, etc. This is much less fun in my eclipse workflow than it used to be. I think perhaps going back to the jar way of starting is not such a bad idea. Starting with a collection is not a priority, making it easy to add one is, in which case I just want to start solr via ant in eclipse, and it doesn't need to auto create anything.
          Hide
          Timothy Potter added a comment -

          +1 to revert trunk's build.xml and just use start.jar again for the run-example target

          Show
          Timothy Potter added a comment - +1 to revert trunk's build.xml and just use start.jar again for the run-example target
          Hide
          Mark Miller added a comment -

          ant server && bin\solr -e techproducts

          I think we should stop trying to conflate these - those that want to work with the scripts for dev, they can already just use the scripts.

          This target is not for those people. Right now it's in an ugly in between place. Let's have this target simply avoid the scripts and not do any magic. I deal with adding config and a collection with a couple cmd line calls for this case all the time.

          People that don't like how this target worked, can simply use the start scripts.

          Show
          Mark Miller added a comment - ant server && bin\solr -e techproducts I think we should stop trying to conflate these - those that want to work with the scripts for dev, they can already just use the scripts. This target is not for those people. Right now it's in an ugly in between place. Let's have this target simply avoid the scripts and not do any magic. I deal with adding config and a collection with a couple cmd line calls for this case all the time. People that don't like how this target worked, can simply use the start scripts.
          Hide
          Timothy Potter added a comment -

          Here's an updated patch with the changes to build.xml for the run-example task.

          Show
          Timothy Potter added a comment - Here's an updated patch with the changes to build.xml for the run-example task.
          Hide
          Uwe Schindler added a comment - - edited

          The changes to build.xml are jiust a revert to the old state from November?

          I agree with Mark. The run-example is a convenience target for developers to quickly start a new instance and see the log output inside the ANT log. Also you can kill with Ctrl-C when you are done. This target is not intended to be used by endusers.

          What we can do: We can use a <parallel> ant task to start a parallel task (parallel to the start.jar) execution, that creates and imports the techproducts example. I can help with that. Just give me the REST commands to send or a script to execute (synchronously) to setup the techproducts example on a running server.

          Show
          Uwe Schindler added a comment - - edited The changes to build.xml are jiust a revert to the old state from November? I agree with Mark. The run-example is a convenience target for developers to quickly start a new instance and see the log output inside the ANT log. Also you can kill with Ctrl-C when you are done. This target is not intended to be used by endusers. What we can do: We can use a <parallel> ant task to start a parallel task (parallel to the start.jar) execution, that creates and imports the techproducts example. I can help with that. Just give me the REST commands to send or a script to execute (synchronously) to setup the techproducts example on a running server.
          Hide
          Uwe Schindler added a comment -

          In any case, wfater the revert of build.xml, the above is a new issue and can wait for later, that's nothing for 5.0.

          Show
          Uwe Schindler added a comment - In any case, wfater the revert of build.xml, the above is a new issue and can wait for later, that's nothing for 5.0.
          Hide
          Timothy Potter added a comment -

          It's not a true revert because:

          <sysproperty key="jetty.home" value="${server.dir}"/>
          

          is now required for the Jetty 9 stuff on trunk.

          Show
          Timothy Potter added a comment - It's not a true revert because: <sysproperty key= "jetty.home" value= "${server.dir}" /> is now required for the Jetty 9 stuff on trunk.
          Hide
          ASF subversion and git services added a comment -

          Commit 1655070 from Timothy Potter in branch 'dev/trunk'
          [ https://svn.apache.org/r1655070 ]

          SOLR-7016: Fix bin\solr.cmd to work in a directory with spaces in the name.

          Show
          ASF subversion and git services added a comment - Commit 1655070 from Timothy Potter in branch 'dev/trunk' [ https://svn.apache.org/r1655070 ] SOLR-7016 : Fix bin\solr.cmd to work in a directory with spaces in the name.
          Hide
          ASF subversion and git services added a comment -

          Commit 1655080 from Timothy Potter in branch 'dev/branches/branch_5x'
          [ https://svn.apache.org/r1655080 ]

          SOLR-7016: Fix bin\solr.cmd to work in a directory with spaces in the name.

          Show
          ASF subversion and git services added a comment - Commit 1655080 from Timothy Potter in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1655080 ] SOLR-7016 : Fix bin\solr.cmd to work in a directory with spaces in the name.
          Hide
          ASF subversion and git services added a comment -

          Commit 1655083 from Timothy Potter in branch 'dev/branches/lucene_solr_5_0'
          [ https://svn.apache.org/r1655083 ]

          SOLR-7016: Fix bin\solr.cmd to work in a directory with spaces in the name.

          Show
          ASF subversion and git services added a comment - Commit 1655083 from Timothy Potter in branch 'dev/branches/lucene_solr_5_0' [ https://svn.apache.org/r1655083 ] SOLR-7016 : Fix bin\solr.cmd to work in a directory with spaces in the name.
          Hide
          Anshum Gupta added a comment -

          Bulk close after 5.0 release.

          Show
          Anshum Gupta added a comment - Bulk close after 5.0 release.
          Hide
          Steve Rowe added a comment -

          Reopening to backport to 4.10.4

          Show
          Steve Rowe added a comment - Reopening to backport to 4.10.4
          Hide
          Steve Rowe added a comment -

          Patch for lucene_solr_4_10 branch.

          I'm testing on Win 7.

          Show
          Steve Rowe added a comment - Patch for lucene_solr_4_10 branch. I'm testing on Win 7.
          Hide
          Steve Rowe added a comment -

          Patch with extra space after a trailing caret ^ removed; also adds the CHANGES.txt entry.

          Without this patch from an install dir with spaces in it, the .port file can't be written (Access is denied. gets printed to the console), so although bin\solr start works, bin\solr stop -all does not.

          The following work as expected with the patch from an install dir with spaces in it:

          • bin\solr start / bin\solr stop -all
          • bin\solr start / bin\solr stop -p 8983
          • bin\solr start / bin\solr start (appropriate error is printed)
          • bin\solr start / bin\solr -i

          Committing shortly.

          Show
          Steve Rowe added a comment - Patch with extra space after a trailing caret ^ removed; also adds the CHANGES.txt entry. Without this patch from an install dir with spaces in it, the .port file can't be written ( Access is denied. gets printed to the console), so although bin\solr start works, bin\solr stop -all does not. The following work as expected with the patch from an install dir with spaces in it: bin\solr start / bin\solr stop -all bin\solr start / bin\solr stop -p 8983 bin\solr start / bin\solr start (appropriate error is printed) bin\solr start / bin\solr -i Committing shortly.
          Hide
          Steve Rowe added a comment -

          Committed to lucene_solr_4_10.

          Show
          Steve Rowe added a comment - Committed to lucene_solr_4_10.
          Hide
          ASF subversion and git services added a comment -

          Commit 1662587 from Steve Rowe in branch 'dev/branches/lucene_solr_4_10'
          [ https://svn.apache.org/r1662587 ]

          SOLR-7016: Fix bin\solr.cmd to work in a directory with spaces in the name. (merged branch_5x r1655080)

          Show
          ASF subversion and git services added a comment - Commit 1662587 from Steve Rowe in branch 'dev/branches/lucene_solr_4_10' [ https://svn.apache.org/r1662587 ] SOLR-7016 : Fix bin\solr.cmd to work in a directory with spaces in the name. (merged branch_5x r1655080)
          Hide
          Michael McCandless added a comment -

          Bulk close for 4.10.4 release

          Show
          Michael McCandless added a comment - Bulk close for 4.10.4 release

            People

            • Assignee:
              Steve Rowe
              Reporter:
              Uwe Schindler
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development