Reputation: 131
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:
Jruby-9.2.0.0
jruby on rails
applicationGemfile 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.
Upvotes: 3
Views: 533
Reputation: 131
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+
Upvotes: 3