2012-09-05 80 views
0

我最近升級我的本地項目的Rails 3.2.8到現在,當我做任何搜索,我得到以下錯誤:爲什麼在Ruby on Rails中使用Sunspot Solr時會出現NullPointerException?

RSolr::Error::Http - 500 Internal Server Error 
Error: java.lang.NullPointerException 
    at org.apache.solr.servlet.SolrServlet.doGet(SolrServlet.java:91) 
    at org.apache.solr.servlet.SolrServlet.doPost(SolrServlet.java:76) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) 
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221) 
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:297) 
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212) 
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399) 
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) 

Request Data: "fq=type%3ALocation&fq=%7B%21geofilt+sfield%3Dcoordinates_ll+pt%3D29.813142%2C-95.309789+d%3D60%7D&q=gem&fl=%2A+score&qf=name_text%5E3.0+alternate_name_text%5E2.0+business_name_text%5E1.7+category_ids_text%5E1.2+reviews_text%5E0.8+questions_answers_text%5E0.6+simple_name_basic_text+name_without_articles_text+description_text+keywords_text&defType=dismax&pf=name_text%5E5.0+category_ids_text%5E2+reviews_text%5E2.5+questions_answers_text%5E2&mm=2%3C66%25&ps=1&qs=1&tie=0.1&start=0&rows=10&facet=true&f.category_ids_sm.facet.sort=false&f.category_ids_sm.facet.mincount=1&facet.field=category_ids_sm" 

Backtrace: /Users/a_user/.rvm/gems/ruby-1.9.2-p320/gems/rsolr-1.0.8/lib/rsolr/client.rb:230:in `adapt_response' 
/Users/a_user/.rvm/gems/ruby-1.9.2-p320/gems/rsolr-1.0.8/lib/rsolr/client.rb:167:in `execute' 
/Users/a_user/.rvm/gems/ruby-1.9.2-p320/gems/rsolr-1.0.8/lib/rsolr/client.rb:161:in `send_and_receive' 
(eval):2:in `post' 
/Users/a_user/.rvm/gems/ruby-1.9.2-p320/bundler/gems/sunspot-8f330615edb1/sunspot/lib/sunspot/search/abstract_search.rb:45:in `execute' 
/Users/a_user/rails_projects/project_a/lib/location_searchable.rb:132:in `search' 
/Users/a_user/rails_projects/project_a/app/controllers/locations_controller.rb:34:in `index' 
/Users/a_user/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action' 
/Users/a_user/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `process_action' 
/Users/a_user/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action' 
/Users/a_user/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:in `block in process_action' 

我已經改變了Solr的schema.xml中到以前的版本,它是仍然給我同樣的錯誤。

我已經安裝了寶石:

sunspot (2.0.0.pre.120720) 
sunspot_rails (2.0.0.pre.120720) 
sunspot_solr (2.0.0.pre.120720) 

此外,Solr的錯誤日誌顯示如下:

Sep 5, 2012 9:24:50 PM org.apache.solr.core.SolrResourceLoader locateSolrHome 
INFO: JNDI not configured for solr (NoInitialContextEx) 

謝謝!

回答

1

嘗試刪除solr文件夾並重新啓動Solr。它應該重新生成solr/datasolr/conf文件夾。然後重新索引,像這樣:

cd /path/to/rails/root 
rm -r solr 
rake sunspot:solr:run 
rake sunspot:solr:reindex 

另外注意太陽黑子2.0不適用於JRuby 1.7,只有1.6。

+0

簡單但有效。 – maxhs

相關問題