我正在使用MongoDB的Ruby on Rails应用程序,我已经实现了基本的Sunspot功能。以下是有关我的环境的一些信息
我以前把一切都搞定了,但现在我遇到了问题。我可以成功运行
bundle exec rake sunspot:solr:start
但是当我尝试
bundle exec rake db:seed
我收到以下错误:
rake aborted!
RSolr::Error::InvalidRubyResponse - 200 OK
Error: <result status="1">java.lang.NullPointerException
at org.apache.solr.handler.XmlUpdateRequestHandler.doLegacyUpdate(XmlUpdateRequestHandler.java:129)
at org.apache.solr.servlet.SolrUpdateServlet.doPost(SolrUpdateServlet.java:87)
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: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><add><doc><field name=\"id\">Event 5197f9061d41c853110005a1</field><field name=\"type\">Event</field><field name=\"class_name\">Event</field><field name=\"name_text\">TEST Event Name</field><field name=\"description_text\">TEST Event Description</field></doc></add>"
Backtrace: /var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:297:in `rescue in evaluate_ruby_response'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:294:in `evaluate_ruby_response'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:269:in `adapt_response'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:175:in `execute'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:161:in `send_and_receive'
(eval):2:in `post'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:67:in `update'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:87:in `add'
/var/lib/gems/1.9.1/gems/sunspot-2.0.0/lib/sunspot/indexer.rb:106:in `add_documents'
/var/lib/gems/1.9.1/gems/sunspot-2.0.0/lib/sunspot/indexer.rb:30:in `add'
/var/lib/gems/1.9.1/gems/sunspot-2.0.0/lib/sunspot/session.rb:91:in `index'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:297:in `rescue in evaluate_ruby_response'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:294:in `evaluate_ruby_response'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:269:in `adapt_response'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:175:in `execute'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:161:in `send_and_receive'
(eval):2:in `post'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:67:in `update'
/var/lib/gems/1.9.1/gems/rsolr-1.0.9/lib/rsolr/client.rb:87:in `add'
/var/lib/gems/1.9.1/gems/sunspot-2.0.0/lib/sunspot/indexer.rb:106:in `add_documents'
/var/lib/gems/1.9.1/gems/sunspot-2.0.0/lib/sunspot/indexer.rb:30:in `add'
/var/lib/gems/1.9.1/gems/sunspot-2.0.0/lib/sunspot/session.rb:91:in `index'
/var/lib/gems/1.9.1/gems/sunspot- 2.0.0/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `index'
/var/lib/gems/1.9.1/gems/sunspot-2.0.0/lib/sunspot.rb:184:in `index'
/var/lib/gems/1.9.1/gems/sunspot_rails-2.0.0/lib/sunspot/rails/searchable.rb:392:in `solr_index'
/var/lib/gems/1.9.1/gems/sunspot_rails-2.0.0/lib/sunspot/rails/searchable.rb:492:in `perform_index_tasks'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:431:in `_run__816338171__save__410491902__callbacks'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/embedded_callbacks.rb:28:in `run_callbacks'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/callbacks.rb:17:in `create_or_update'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/querying.rb:129:in `save'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/dirty.rb:19:in `block in save'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/dirty.rb:37:in `clear_changes'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/dirty.rb:19:in `save'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/validations.rb:22:in `save'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/identity_map.rb:113:in `save'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/querying.rb:134:in `save!'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/querying.rb:31:in `block in create!'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/querying.rb:100:in `block in initialize_each'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/querying.rb:98:in `each'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/querying.rb:98:in `initialize_each'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/querying.rb:31:in `create!'
/my_home_dir/my_rails_app/db/seed_events.rb:4:in `<top (required)>'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/my_home_dir/my_rails_app/db/seeds.rb:16:in `block in <top (required)>'
/my_home_dir/my_rails_app/db/seeds.rb:16:in `each'
/my_home_dir/my_rails_app/db/seeds.rb:16:in `<top (required)>'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `block in load'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/var/lib/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/railtie/database.rake:14:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
如果我尝试bundle exec rake sunspot:reindex
具有相同的java.lang.NullPointerException堆栈跟踪但略有不同的Ruby堆栈跟踪,我也会收到类似的错误。
击>
更新
很抱歉,我这么长时间没有接触到这个。我终于尝试删除我的solr/
目录,然后重新启动。我现在能够毫无问题地运行bundle exec rake sunspot:solr:start
然后bundle exec rake db:seed
,但我在尝试时仍然出错:
bundle exec rake sunspot:solr:reindex
我看到以下stacktrace
$ bundle exec rake sunspot:solr:reindex
rake aborted!
undefined method `includes' for Event:Class
/home/my_username/.rvm/gems/ruby-1.9.3-p429/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/dynamic_querying.rb:39:in `method_missing'
/home/my_username/.rvm/gems/ruby-1.9.3-p429/gems/sunspot_rails-2.1.0/lib/sunspot/rails/searchable.rb:254:in `solr_index'
/home/my_username/.rvm/gems/ruby-1.9.3-p429/gems/sunspot_rails-2.1.0/lib/sunspot/rails/searchable.rb:203:in `solr_reindex'
/home/my_username/.rvm/gems/ruby-1.9.3-p429/bundler/gems/sunspot_mongo_mapper-b6cf3edca97a/lib/sunspot/mongo_mapper/tasks.rb:21:in `block (3 levels) in <top (required)>'
/home/my_username/.rvm/gems/ruby-1.9.3-p429/bundler/gems/sunspot_mongo_mapper-b6cf3edca97a/lib/sunspot/mongo_mapper/tasks.rb:20:in `each'
/home/my_username/.rvm/gems/ruby-1.9.3-p429/bundler/gems/sunspot_mongo_mapper-b6cf3edca97a/lib/sunspot/mongo_mapper/tasks.rb:20:in `block (2 levels) in <top (required)>'
/home/my_username/.rvm/gems/ruby-1.9.3-p429/bin/ruby_noexec_wrapper:14:in `eval'
/home/my_username.rvm/gems/ruby-1.9.3-p429/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => sunspot:solr:reindex => sunspot:reindex
(See full trace by running task with --trace)
所以有人知道这个问题是什么吗?
对此问题的任何见解将不胜感激!谢谢!
答案 0 :(得分:0)
我只有用bundle exec rake sunspot:solr:reindex
触发了同样的错误,有助于强制退出我能找到的所有java进程。我用
bundle exec rake sunspot:solr:start
然后我可以重新索引而没有任何错误。
答案 1 :(得分:0)
我也遇到了这个错误 - https://stackoverflow.com/a/17665820/227403
解决方案是我的solr目录在SVN部署中出现了。我删除了目录并重新启动它。
答案 2 :(得分:0)
你的solr /目录结构是什么,它应该是:
sole/
conf/
data/
pids/
我的本地机器有这3个文件夹,它可以工作。但我的2台服务器都没有conf /。一个工作,另一个不起作用。
开始我尝试删除整个solr /文件夹,并重新启动solr,问题仍然存在,然后我重新安装java,重新安装宝石,问题依然存在。
最后我添加conf /一些由solr在我的本地机器上自动创建的配置文件,我将它们推送到服务器,解决问题。
我花了一整天的时间,希望这个答案有用。
答案 3 :(得分:0)
你应该尝试使用Pry&amp; prey-debbugger进入最后一个文件,看看发生了什么。
/home/my_username/.rvm/gems/ruby-1.9.3-p429/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/dynamic_querying.rb:39:in`method_missing'
正在寻找不再存在的东西。也许您已经在Searchable中定义了一个已被删除或更改的字段?