1

我有一个 Rails 3 应用程序,它使用 Warbler 打包到一个 war 文件中并部署到 Weblogic 11g。我正在通过控制台 Web 应用程序部署战争。当我尝试访问应用程序时失败,在下面生成堆栈跟踪。但是,如果我将应用程序解包部署(提取失败的相同 war 文件),它会完美运行。

环境:

  • Ubuntu 12.04
  • JDK (1.7.0_06-b24)
  • Weblogic 11g (10.3.6)
  • 导轨 (3.2.8)
  • 莺 (1.3.6)
  • jruby (1.6.7.2)

堆栈跟踪和 warble.rb 的要点

堆栈跟踪

<Sep 14, 2012 12:55:25 PM CDT> <Error> <ServletContext-/ruby-px> <BEA-000000> <ERROR: application error
org.jruby.rack.RackInitializationException: can't dup NilClass
    from classpath:/META-INF/jruby.home/lib/ruby/1.9/pathname.rb:215:in `initialize'
    from classpath:/jruby/rack/rails/railtie.rb:16:in `Railtie'
    from org/jruby/RubyProc.java:258:in `call'
    from /home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/gems/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
    from /home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/gems/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks'
    from org/jruby/RubyArray.java:1615:in `each'
    from /home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/gems/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    from /home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/gems/gems/railties-3.2.8/lib/rails/application.rb:67:in `inherited'
    from /home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/config/application.rb:13:in `RubyPx'
    from /home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/config/application.rb:12:in `(root)'
    from org/jruby/RubyKernel.java:1042:in `require'
    from /home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/config/application.rb:2:in `(root)'
    from org/jruby/RubyKernel.java:1042:in `require'
    from /home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/config/environment.rb:23:in `load_environment'
    from classpath:/jruby/rack/rails_booter.rb:65:in `load_environment'
    from <script>:1:in `(root)'

    at org.jruby.rack.DefaultRackApplicationFactory$4.init(DefaultRackApplicationFactory.java:231)
    at org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:58)
    at org.jruby.rack.PoolingRackApplicationFactory.createApplication(PoolingRackApplicationFactory.java:323)
    at org.jruby.rack.PoolingRackApplicationFactory.getApplication(PoolingRackApplicationFactory.java:171)
    at org.jruby.rack.DefaultRackDispatcher.getApplication(DefaultRackDispatcher.java:27)
    Truncated. see log file for complete stacktrace
Caused By: org.jruby.exceptions.RaiseException: (TypeError) can't dup NilClass
    at org.jruby.RubyKernel.dup(org/jruby/RubyKernel.java:1911)
    at Pathname.initialize(classpath:/META-INF/jruby.home/lib/ruby/1.9/pathname.rb:215)
    at (Anonymous).Railtie(classpath:/jruby/rack/rails/railtie.rb:16)
    at org.jruby.RubyProc.call(org/jruby/RubyProc.java:258)
    at (Anonymous).execute_hook(/home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/gems/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:34)
    Truncated. see log file for complete stacktrace
> 
<Sep 14, 2012 12:55:30 PM CDT> <Error> <ServletContext-/ruby-px> <BEA-000000> <ERROR: couldn't handle error
org.jruby.exceptions.RaiseException: (TypeError) can't convert nil into String
    at org.jruby.RubyFile.join(org/jruby/RubyFile.java:1496)
    at org.jruby.RubyFile.join(org/jruby/RubyFile.java:1518)
    at File._call(/home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/gems/gems/rack-1.4.1/lib/rack/file.rb:55)
    at File.call(/home/scott/wls_domains/PartnersXpress/servers/myserver/tmp/_WL_user/ruby-px/iikl7j/war/WEB-INF/gems/gems/rack-1.4.1/lib/rack/file.rb:30)
    at Errors.response_content(classpath:/jruby/rack/errors.rb:37)
    Truncated. see log file for complete stacktrace

编辑:添加了 JDK 版本。

4

1 回答 1

1

解决方案比我想象的要容易。上述症状是由于 Weblogic 默认不支持打包的战争文件的 ServletContext.getRealPath() 导致的。但是,这可以通过提供已show-archived-real-path-enabled设置为的 WEB-INF/weblogic.xml 来启用true

例子:

<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">   
   <container-descriptor>     
       <show-archived-real-path-enabled>true</show-archived-real-path-enabled>   
   </container-descriptor> 
</weblogic-web-app>
于 2012-09-17T19:09:48.200 回答