我正在开发一个使用 MongoDB 的 Ruby on Rails 应用程序,并且我已经实现了基本的 Sunspot 功能。这是有关我的环境的一些信息
- 导轨 3.2.11
- 蒙戈 2.4.3
- 太阳黑子 2.0.0
- 宝石 mongo_mapper
- 宝石 sunspot_rails
- 宝石太阳黑子_solr
- 宝石 sunspot_mongo_mapper
我以前一切正常,但现在我遇到了问题。我可以成功运行
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)
如果我尝试具有相同的 java.lang.NullPointerException 堆栈跟踪但 Ruby 堆栈跟踪略有不同,
我也会得到类似的错误。bundle exec rake sunspot:reindex
更新
对不起,我很久没有解决这个问题了。我终于尝试删除我的solr/
目录,然后重新启动。我现在可以运行bundle exec rake sunspot:solr:start
,然后bundle exec rake db:seed
没有任何问题,但是当我尝试时仍然出现错误:
bundle exec rake sunspot:solr:reindex
我看到以下堆栈跟踪
$ 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)
那么有谁知道这个问题是什么?
任何对此问题的见解将不胜感激!谢谢!