Home Rails with Solr + sunspot: java.lang.NullPointerException
Reply: 1

Rails with Solr + sunspot: java.lang.NullPointerException

Christian Benseler
1#
Christian Benseler Published in 2018-01-02 09:42:50Z

I have a Rails app (4.1.1) running in an Ubuntu instance under Apache + Phusion with SOLR (via sunspot)

THe app used to work well, but last week I upgraded the ubuntu (now it's on Ubuntu 16.04.3 LTS) and then SOLR stopped to work. I start the server with the command

RAILS_ENV=production bundle exec rake sunspot:solr:start

and the console outputs Successfully started Solr ...

Successfully started Solr ...

But when I tried to access it (example: to reindex the models, or even via browser, through http://myip:8983/solr) it outputs:

HTTP ERROR 500 Problem accessing /solr/. Reason:

Server Error Caused by: java.lang.NullPointerException    at org.apache.solr.servlet.SolrDispatchFilter.authenticateRequest(SolrDispatchFilter.java:241)

at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:186) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:179) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:748)

anyone has any ideia of how I could start to work on this problem? I can't find anything relevant in the rails app log (/log/production.log) or in the Apache's error.log file.

Fabrizio Bertoglio
2#
Fabrizio Bertoglio Reply to 2018-01-02 11:54:49Z

Maybe you are missing some packages in your Ubuntu 16?

what about this steps from the documentation wiki

Install Java (if not already installed)

Because tomcat and solr are Java based softwares we need the Java environment (As it is advised in the Solr wiki : prefere a full JDK to a simple JRE.)

$ sudo apt-get install openjdk-6-jdk

Note : Working on Amazon EC2 instance, I had to upgrade temporarly my “micro” instance to “medium”, because of special memory needs during java’s installation.

Install Tomcat & Solr (You can’t avoid this one)

For ubuntu (tested with 10.4 LTS), there is an unique package to install, it will take care of installing both Tomcat & Solr, plus the integration of Solr in Tomcat.

$ sudo apt-get install solr-tomcat

then let’s start the server

$ sudo service tomcat6 start

Ok it is done ! Solr server responds at http://localhost:8080/solr and the config & index will be stored at : /usr/share/solr/ In order to use it with Sunspot you’ll have to copy conf/schema.xml & conf/solrconfig.xml from your application to /usr/share/solr/ or /usr/share/solr/conf (Ubuntu 12.04). But, indeed, you should read the tutorial further to understand why you shouldn’t use Solr directly.

For now your data are stored in a folder of your system not dedicated to a specific user or application. It is quite common to read that a public server should use a dedicated user account with constraint privileges. (internet is full of it)

If like me your not totaly happy with it, follow the next steps to customize the whole thing. I won’t explain you how to start Tomcat as another user (Google it), but how to choose your Solr home directory

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299901 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO