executable war file

View: New views
4 Messages — Rating Filter:   Alert me  

executable war file

by Chad Woolley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

We are trying to make a war file with Jruby which will be executable
in non-exploded form with 'java -jar execwar.war'.

There is a problem with jruby-rack being able to load some of the
rails files from the classpath.  Here's the error:

org.jruby.rack.RackInitializationException: No such file to load --
/Users/pivotal/workspace/execwar/WEB-INF/config/environment.rb
  from file:/Users/pivotal/workspace/execwar/execwar.war!/jruby/rack/rails.rb:32:in
`load_environment'

Since jruby is successfully interpreting /jruby/rack/rails.rb, it
seems like it should be possible to interpret
/WEB-INF/config/environment.rb as well.  Can we force the usage of the
"file:/.../execwar.war!/..." format to locate and load the
environment.rb file?

We've created a sample rails app to illustrate this problem.
Instructions for compiling and running the war are in the README:

http://github.com/pivotal/execwar

Thanks,
-- Chad

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: executable war file

by David Calavera :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

seems there is a bug in the JRuby-Rack development version, I don't know if you are using it but when I execute its tests I get:

NativeException in 'Java::OrgJrubyRackRails::RailsRackApplicationFactory getApplication should load the Rails environment and return an application'
org.jruby.rack.RackInitializationException: No such file to load -- /home/david/dev/jruby-rack/config/environment.rb
    from /home/david/dev/jruby-rack/target/classes/jruby/rack/rails.rb:32:in `load_environment'
    from /home/david/dev/jruby-rack/target/classes/jruby/rack/rails.rb:155:in `new'
    from <script>:2
    from /opt/jruby-1.3.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in `instance_eval'
    from /opt/jruby-1.3.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in `initialize'
    from <script>:2
org/jruby/rack/DefaultRackApplicationFactory.java:153:in `init'

That's pretty similar to what you get in your app. In theory you could override your RAILS_ROOT to use "execwar.war!/WEB-INF" adding it to the warble.rb with this option "config.webxml.rails.root = '/execwar.war!/WEB-INF'", but I did it in your sample app and it doesn't work at all.

On Wed, Oct 28, 2009 at 8:45 PM, Chad Woolley <thewoolleyman@...> wrote:
Hello,

We are trying to make a war file with Jruby which will be executable
in non-exploded form with 'java -jar execwar.war'.

There is a problem with jruby-rack being able to load some of the
rails files from the classpath.  Here's the error:

org.jruby.rack.RackInitializationException: No such file to load --
/Users/pivotal/workspace/execwar/WEB-INF/config/environment.rb
 from file:/Users/pivotal/workspace/execwar/execwar.war!/jruby/rack/rails.rb:32:in
`load_environment'

Since jruby is successfully interpreting /jruby/rack/rails.rb, it
seems like it should be possible to interpret
/WEB-INF/config/environment.rb as well.  Can we force the usage of the
"file:/.../execwar.war!/..." format to locate and load the
environment.rb file?

We've created a sample rails app to illustrate this problem.
Instructions for compiling and running the war are in the README:

http://github.com/pivotal/execwar

Thanks,
-- Chad

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
David Calavera
http://www.thinkincode.net

Re: executable war file

by David Calavera :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just remember another thing.

I moved some jruby on rails applications to Jetty 7 recently and I had some initialization issues because I tryed to load a spring context in a rails initializer but the variable $servlet_context hadn't been initialized when that code ran.

I solved it moving my code to a method and initialized the spring context on demand but perhaps you could try to use Jetty 6 and see what happens.

On Thu, Oct 29, 2009 at 10:56 AM, David Calavera <david.calavera@...> wrote:
seems there is a bug in the JRuby-Rack development version, I don't know if you are using it but when I execute its tests I get:

NativeException in 'Java::OrgJrubyRackRails::RailsRackApplicationFactory getApplication should load the Rails environment and return an application'
org.jruby.rack.RackInitializationException: No such file to load -- /home/david/dev/jruby-rack/config/environment.rb
    from /home/david/dev/jruby-rack/target/classes/jruby/rack/rails.rb:32:in `load_environment'
    from /home/david/dev/jruby-rack/target/classes/jruby/rack/rails.rb:155:in `new'
    from <script>:2
    from /opt/jruby-1.3.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in `instance_eval'
    from /opt/jruby-1.3.0/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in `initialize'
    from <script>:2
org/jruby/rack/DefaultRackApplicationFactory.java:153:in `init'

That's pretty similar to what you get in your app. In theory you could override your RAILS_ROOT to use "execwar.war!/WEB-INF" adding it to the warble.rb with this option "config.webxml.rails.root = '/execwar.war!/WEB-INF'", but I did it in your sample app and it doesn't work at all.


On Wed, Oct 28, 2009 at 8:45 PM, Chad Woolley <thewoolleyman@...> wrote:
Hello,

We are trying to make a war file with Jruby which will be executable
in non-exploded form with 'java -jar execwar.war'.

There is a problem with jruby-rack being able to load some of the
rails files from the classpath.  Here's the error:

org.jruby.rack.RackInitializationException: No such file to load --
/Users/pivotal/workspace/execwar/WEB-INF/config/environment.rb
 from file:/Users/pivotal/workspace/execwar/execwar.war!/jruby/rack/rails.rb:32:in
`load_environment'

Since jruby is successfully interpreting /jruby/rack/rails.rb, it
seems like it should be possible to interpret
/WEB-INF/config/environment.rb as well.  Can we force the usage of the
"file:/.../execwar.war!/..." format to locate and load the
environment.rb file?

We've created a sample rails app to illustrate this problem.
Instructions for compiling and running the war are in the README:

http://github.com/pivotal/execwar

Thanks,
-- Chad

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
David Calavera
http://www.thinkincode.net



--
David Calavera
http://www.thinkincode.net

Re: executable war file

by Chad Woolley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Oct 29, 2009 at 3:34 AM, David Calavera
<david.calavera@...> wrote:
> Just remember another thing.
>
> I moved some jruby on rails applications to Jetty 7 recently and I had some
> initialization issues because I tryed to load a spring context in a rails
> initializer but the variable $servlet_context hadn't been initialized when
> that code ran.
>
> I solved it moving my code to a method and initialized the spring context on
> demand but perhaps you could try to use Jetty 6 and see what happens.

Yes, we got that error until we defined this in Main.java:

context.setResourceBase("");

Then it went away.  It seemed to be because Jetty couldn't determine
the real root path / resource base automatically.

Thanks
-- Chad

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email