3

I'm trying to generate a compiled application of the Rails project using jruby and host it on Tomcat server. I'm struggling to establish the connection with elasticsearch after compiling.

Following are the steps I've taken:

  • Installed Jruby-9.2.0.0
  • Created a jruby on rails application
  • Gemfile contains

    gem 'rails', '~> 5.2.1' gem 'listen' gem 'activerecord-jdbcmysql-adapter' gem 'therubyrhino' gem 'java' gem 'ruby-debug', '~> 0.10.6' gem 'elasticsearch' gem 'warbler'

  • warble.conf contains

    Warbler::Config.new do |config| config.features = %w(FEATURE) config.features = %w(gemjar) end

  • Controller contains:

    def index $es_client = Elasticsearch::Client.new log: true products = $es_client.search index: 'production-products' render json: products end

  • Ran warble compiled war command in the project folder to create .war file

When I run the application directly using rails s it is working as expected.

But when I compile the application and run on Tomcat server I'm getting the following error

Internal Server Error (500)
Request Method:     GET
Request URL:    http://localhost:8080/blog/
java.lang.NullPointerException
You're seeing this error because you use    JRuby::Rack::ErrorApp::ShowStatus.
Harish
  • 131
  • 2
  • 8

1 Answers1

3

The solution is to include the required gem in warble.conf file.

Warbler::Config.new do |config|
  config.features = %w(FEATURE)
  config.features = %w(gemjar)
  config.gems["elasticsearch"]
end+
Harish
  • 131
  • 2
  • 8