Sunspot :: Solr :: Server :: JavaMissing: You Need a Java Runtime Environment to Run the Solr Server


Trying to start Solr with sunspot but having an issue with the Java Runtime Environment by getting this error.

[email protected]:~# dokku run oktob bundle exec rake sunspot:solr:start
rake aborted!
Sunspot::Solr::Server::JavaMissing: You need a Java Runtime Environment to run the Solr server
/app/vendor/bundle/ruby/2.1.0/gems/sunspot_solr-2.2.0/lib/sunspot/solr/server.rb:203:in `ensure_java_installed'
/app/vendor/bundle/ruby/2.1.0/gems/sunspot_solr-2.2.0/lib/sunspot/solr/server.rb:27:in `initialize'
/app/vendor/bundle/ruby/2.1.0/gems/sunspot_solr-2.2.0/lib/sunspot/solr/tasks.rb:38:in `new'
/app/vendor/bundle/ruby/2.1.0/gems/sunspot_solr-2.2.0/lib/sunspot/solr/tasks.rb:38:in `server'
/app/vendor/bundle/ruby/2.1.0/gems/sunspot_solr-2.2.0/lib/sunspot/solr/tasks.rb:10:in `block (3 levels) in <top (required)>'
Tasks: TOP => sunspot:solr:start
(See full trace by running task with --trace)

Solar is up and running on the remote server.

Java is installed

[email protected]:~# which java

And this is the output of sudo update-alternatives --config java

[email protected]:~# sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java          1073      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
* 2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1072      manual mode
  3            /usr/lib/jvm/java-8-oracle/jre/bin/java          1073      manual mode

I edited /etc/profile file to export the path inspired by discussions here and here and javaandme

export JAVA_HOME
export PATH

I'm not sure about the path above is it correct or not.

config/sunspot.xml file

    hostname: localhost
    port: 8983
    log_level: WARNING
    path: /solr/production
    # read_timeout: 2
    # open_timeout: 0.5

    hostname: localhost
    port: 8982
    log_level: INFO
    path: /solr/development

    hostname: localhost
    port: 8981
    log_level: WARNING
    path: /solr/test

To me, reinstallation JDK( fixes the problem that happened during the first use of solr in El Capitan