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
containsWarbler::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.