Question

I have a Rails 3 app that is packed into a war file using Warbler and being deployed to Weblogic 11g. I am deploying the war via the console web app. When I try accessing the app it fails, generating stack trace below. However, if I deploy the app unpacked (extracting the same war file that is failing) it runs perfectly.

Env:

  • Ubuntu 12.04
  • JDK (1.7.0_06-b24)
  • Weblogic 11g (10.3.6)
  • rails (3.2.8)
  • warbler (1.3.6)
  • jruby (1.6.7.2)

Gist of stack trace and warble.rb

Stack Trace

<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

EDIT: Added JDK version.

Was it helpful?

Solution

The solution was easier than I thought. The symptoms above were being caused by the fact that Weblogic does not support ServletContext.getRealPath() by default for packed war files. However, this can be enabled by providing a WEB-INF/weblogic.xml that has show-archived-real-path-enabled set to true

Example:

<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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top