Rails 4:Solr抛出JavaMissing错误,但安装了Java

时间:2014-07-02 15:18:24

标签: java ruby-on-rails solr

我重启了Rails 4 VPS,Solr显然也关机了。我现在正在尝试启动Solr,但是当我运行以下RAILS_ENV=production bundle exec rake sunspot:solr:start时,我收到以下错误消息:

rake aborted!
Sunspot::Solr::Server::JavaMissing: You need a Java Runtime Environment to run the Solr server
/home/dani/.rvm/gems/ruby-2.1.2/gems/sunspot_solr-2.1.1/lib/sunspot/solr/server.rb:203:in `ensure_java_installed'
/home/dani/.rvm/gems/ruby-2.1.2/gems/sunspot_solr-2.1.1/lib/sunspot/solr/server.rb:27:in `initialize'
/home/dani/.rvm/gems/ruby-2.1.2/gems/sunspot_solr-2.1.1/lib/sunspot/solr/tasks.rb:37:in `new'
/home/dani/.rvm/gems/ruby-2.1.2/gems/sunspot_solr-2.1.1/lib/sunspot/solr/tasks.rb:37:in `server'
/home/dani/.rvm/gems/ruby-2.1.2/gems/sunspot_solr-2.1.1/lib/sunspot/solr/tasks.rb:5:in `block (3 levels) in <top (required)>'
/home/dani/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
/home/dani/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => sunspot:solr:start
(See full trace by running task with --trace)

奇怪的是安装了Java:

$ echo $JAVA_HOME
/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
$ java -version
java version "1.6.0_31"
OpenJDK Runtime Environment (IcedTea6 1.13.3) (6b31-1.13.3-1ubuntu1~0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

我不确定可能导致此行为的原因。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

尝试添加PATH java所在的文件夹,如下所示:

export PATH=$PATH:/path/to/java/bin

这样java就可以从任何地方调用而无需指定文件夹。

在调用rake之前启动它解决了我的问题。