NoMethodError:java.lang.NullPointerException的未定义方法`bindings'

时间:2017-02-28 22:29:01

标签: ruby-on-rails jruby puma

我们正在使用在jruby-1.7.25上运行的rails(4.2.8)应用程序上的ruby。现在是时候将这个木乃伊更新到最新版本9.1.7.0。我们这样做了,对于我的大多数同事而言,它的效果很好。但是 - 猜猜是什么 - 不适合我。在这里发表我的问题之前,我确保:

  • 我有相同的设置
  • 相同的数据库内容
  • 完全相同的代码

和其他人一样,但我仍然得到那个愚蠢的错误 java.lang.NullPointerException而且这就是全部,应用程序正在吐出任何请求。

我正在挖掘最后几个小时并发现,真正的问题是在伐木深度中迷失了。最后我发现,如果我在文件puts中添加vendor/jruby/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/show_exceptions.rb,我会看到真正的原因:

class ShowExceptions
  FAILSAFE_RESPONSE = [500, { 'Content-Type' => 'text/plain' },
    ["500 Internal Server Error\n" \
     "If you are the administrator of this website, then please read this web " \
     "application's log file and/or the web server's log file to find out what " \
     "went wrong."]]

  def initialize(app, exceptions_app)
    @app = app
    @exceptions_app = exceptions_app
  end

  def call(env)
    @app.call(env)
  rescue Exception => exception
    puts "EXCEPTION: #{exception.inspect}\n@app: #{@app.inspect}\nENV: #{env.inspect}"
    if env['action_dispatch.show_exceptions'] == false
      raise exception
    else
      render_exception(env, exception)
    end
  end

输出结果为:

EXCEPTION: #<NoMethodError: undefined method `bindings' for java.lang.NullPointerException:Java::JavaLang::NullPointerException

@appenv打印出可能无效的千字节数据。老实说,我有点被困在这里。如果它在我的机器上发生故障,它如何在其他机器上运行?你们中的任何人都有过类似的问题,或者有什么想法会导致这种麻烦吗?

啊,有些版本的信息

  • Puma:* Version 3.7.1 (jruby 9.1.7.0 - ruby 2.3.1), codename: Snowy Sagebrush
  • jruby:jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 24.79-b02 on 1.7.0_79-b15 +jit [darwin-x86_64]
  • java:java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
  • Mac OSX:10.12.3 (16D32)

感谢任何提示!

0 个答案:

没有答案