Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sunspot Rails Can't Load on Mac OS X

I'm not sure what changed, but solr will not start on my machine. I get the following error...

❯ bundle exec rake sunspot:solr:run
2017-04-06 08:47:48.624:INFO:oejs.Server:jetty-8.1.8.v20121106
2017-04-06 08:47:48.646:INFO:oejdp.ScanningAppProvider:Deployment monitor /Users/noahc/.rvm/gems/ruby-2.3.3@mbcapp/gems/sunspot_solr-2.2.0/solr/contexts at interval 0
2017-04-06 08:47:48.654:INFO:oejd.DeploymentManager:Deployable added: /Users/noahc/.rvm/gems/ruby-2.3.3@mbcapp/gems/sunspot_solr-2.2.0/solr/contexts/solr.xml
2017-04-06 08:47:48.723:INFO:oejw.WebInfConfiguration:Extract jar:file:/Users/noahc/.rvm/gems/ruby-2.3.3@mbcapp/gems/sunspot_solr-2.2.0/solr/webapps/solr.war!/ to /private/var/folders/cv/259q741957qc1v7qnf5v4kfm0000gn/T/jetty-0.0.0.0-443-
solr.war-_solr-any-/webapp
2017-04-06 08:47:49.653:INFO:oejw.StandardDescriptorProcessor:NO JSP Support for /solr, did not find org.apache.jasper.servlet.JspServlet
Null identity service, trying login service: null
Finding identity service: null
2017-04-06 08:47:49.679:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/solr,file:/private/var/folders/cv/259q741957qc1v7qnf5v4kfm0000gn/T/jetty-0.0.0.0-443-solr.war-_solr-any-/webapp/},/Users/noahc/.rvm/gems/ruby-2.3.3@mbcapp/ge
ms/sunspot_solr-2.2.0/solr/webapps/solr.war
2017-04-06 08:47:49.680:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/solr,file:/private/var/folders/cv/259q741957qc1v7qnf5v4kfm0000gn/T/jetty-0.0.0.0-443-solr.war-_solr-any-/webapp/},/Users/noahc/.rvm/gems/ruby-2.3.3@mbcapp/ge
ms/sunspot_solr-2.2.0/solr/webapps/solr.war
2017-04-06 08:48:06.041:WARN:oejuc.AbstractLifeCycle:FAILED [email protected]:443: java.net.BindException: Permission denied (Bind failed)
java.net.BindException: Permission denied (Bind failed)
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
        at java.net.ServerSocket.bind(ServerSocket.java:375)
        at java.net.ServerSocket.<init>(ServerSocket.java:237)
        at java.net.ServerSocket.<init>(ServerSocket.java:181)
        at org.eclipse.jetty.server.bio.SocketConnector.newServerSocket(SocketConnector.java:96)
        at org.eclipse.jetty.server.bio.SocketConnector.open(SocketConnector.java:85)
        at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
        at org.eclipse.jetty.server.bio.SocketConnector.doStart(SocketConnector.java:156)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.server.Server.doStart(Server.java:288)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1266)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1189)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:472)
        at org.eclipse.jetty.start.Main.start(Main.java:620)
        at org.eclipse.jetty.start.Main.main(Main.java:95)
2017-04-06 08:48:06.043:WARN:oejuc.AbstractLifeCycle:FAILED org.eclipse.jetty.server.Server@5d7148e2: java.net.BindException: Permission denied (Bind failed)
java.net.BindException: Permission denied (Bind failed)
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
        at java.net.ServerSocket.bind(ServerSocket.java:375)
        at java.net.ServerSocket.<init>(ServerSocket.java:237)
        at java.net.ServerSocket.<init>(ServerSocket.java:181)
        at org.eclipse.jetty.server.bio.SocketConnector.newServerSocket(SocketConnector.java:96)
        at org.eclipse.jetty.server.bio.SocketConnector.open(SocketConnector.java:85)
        at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
        at org.eclipse.jetty.server.bio.SocketConnector.doStart(SocketConnector.java:156)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.server.Server.doStart(Server.java:288)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1266)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1189)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:472)
        at org.eclipse.jetty.start.Main.start(Main.java:620)
        at org.eclipse.jetty.start.Main.main(Main.java:95)
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:472)
        at org.eclipse.jetty.start.Main.start(Main.java:620)
        at org.eclipse.jetty.start.Main.main(Main.java:95)
Caused by: java.net.BindException: Permission denied (Bind failed)
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
        at java.net.ServerSocket.bind(ServerSocket.java:375)
        at java.net.ServerSocket.<init>(ServerSocket.java:237)
        at java.net.ServerSocket.<init>(ServerSocket.java:181)
        at org.eclipse.jetty.server.bio.SocketConnector.newServerSocket(SocketConnector.java:96)
        at org.eclipse.jetty.server.bio.SocketConnector.open(SocketConnector.java:85)
        at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
        at org.eclipse.jetty.server.bio.SocketConnector.doStart(SocketConnector.java:156)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.server.Server.doStart(Server.java:288)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
        at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1266)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1189)
        ... 7 more

Usage: java -jar start.jar [options] [properties] [configs]
       java -jar start.jar --help  # for more information

I can use brew and install solr and get it to run and access an admin page like http://localhost:8981/solr/#/~logging, but I can't get my rails app and cucumber in particular to use that brew install version. Nor can I get the bundle exec rake sunspot:solr:run command to work, which works for everyone else on the team.

EDIT:

sunspot.yml

development:
  solr:
    hostname: localhost
    port: 8982
    log_level: INFO
    min_memory: 512M
    max_memory: 1G
    path: /solr/development

test:
  solr:
    hostname: localhost
    port: 8981
    log_level: WARNING
    path: /solr/test

solr.xml

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false">
  <cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:}">
    <core name="default"     instanceDir="." dataDir="default/data"/>
    <core name="development" instanceDir="." dataDir="development/data"/>
    <core name="test"        instanceDir="." dataDir="test/data"/>
  </cores>
</solr>
like image 280
Noah Clark Avatar asked Apr 06 '17 14:04

Noah Clark


2 Answers

Try to give permissions for /solr directory

chown -R $USER /solr

Explanation:

  • Permission denied (Bind failed) is typical error which raises when an application doesn't have enough permissions to run.

  • /solr directory has permissions only for root user (in most cases for sure)

  • Current user is /Users/noahc which is not root user

Thus I understand that the current user doesn't have enough permission to run the application.

like image 128
itsnikolay Avatar answered Sep 27 '22 18:09

itsnikolay


  1. Verify you are running the solr folder that you expect by setting an absolute path for your SOLR_HOME=/Users/rposborne/code/my-project/solr/conf your path my be different (this is how I tell my brew install to run in the source controlled solr config in my project)
  2. Verify that you do not have any JETTY_ARGS if you do this could be setting the port to 443 and causing the permission errors.
  3. Update your solr.xml. The posted xml config appears dated. Make sure you are using a solr config for your version of solr. https://github.com/sunspot/sunspot/blob/master/sunspot_solr/solr/solr/solr.xml

Perspective

It looks like the bundle exec rake sunspot:solr:run is trying to run on port 443, which is a protected port, hence the "permission denied". You should verify the port that is set in your config/sunspot.yml is set to the port that you are expecting maybe 8981.

Personally, I don't use the helper provided by sunspot as it adds a layer of abstraction that I'll eventually have to deal with in production.

To point sunspot at other installs you can configure it in a handful of different ways.

  1. ENV variables: Set the environment variable SOLR_URL which sunspot will take consider first. SOLR_URL=http://localhost:8981/solr/your-collection-name/
  2. config/sunspot.yml which is modeled after config/database.yml
like image 26
rposborne Avatar answered Sep 27 '22 20:09

rposborne