【问题标题】:Running jruby application with Elastic Search gem.使用 Elastic Search gem 运行 jruby 应用程序。
【发布时间】:2019-01-24 12:05:34
【问题描述】:

我正在尝试使用jruby 生成Rails 项目的编译应用程序并将其托管在Tomcat server 上。 编译后我正在努力建立与elasticsearch 的连接。

以下是我采取的步骤:

  • 已安装Jruby-9.2.0.0
  • 创建了一个jruby on rails 应用程序
  • Gemfile 包含

    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 包含

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

  • 控制器包含:

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

  • 在项目文件夹中运行warble compiled war命令创建.war文件

当我直接使用 rails s 运行应用程序时,它按预期工作。

但是当我编译应用程序并在 Tomcat 服务器上运行时,我收到以下错误

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.

【问题讨论】:

    标签: ruby-on-rails tomcat elasticsearch jruby warbler


    【解决方案1】:

    解决方案是在warble.conf 文件中包含所需的gem。

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

    【讨论】:

      猜你喜欢
      • 2019-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-26
      • 1970-01-01
      • 1970-01-01
      • 2019-08-28
      • 1970-01-01
      相关资源
      最近更新 更多