Deploy class-files of a RoR-Application in a .war File


#1

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I’d like to package a RoR app using warble in such a way that the main
part of the application is being precompiled into Java bytecode using
jrubyc. What I currently have tried is to do a

$ jrubyc app/controller/*.rb
$ rake warble

and then unzip the resulting .war file, remove the controller *.rb
files, so that only the compiled .class files remain. If I then deploy
the app I get a scaring stack trace.

Is there some option which I can apply to warbler so that I get
precompiled classes?

Best regards,
Christian


“He’s a gun-slinging dishevelled firefighter haunted by memories of
'Nam. She’s a sharp-shooting African-American opera singer who hides
her
beauty behind a pair of thick-framed spectacles. They fight crime!”

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkk5VD0ACgkQCNjA0nfhW7zpVQCg5ZfADyy8H+rpo5IiH0KbZChu
HpUAnRV/tndJefQFbaj5bLjBxBscfEKk
=DS9h
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

On Fri, Dec 5, 2008 at 10:18 AM, Christian N. removed_email_address@domain.invalid
wrote:

   $ jrubyc app/controller/*.rb
   $ rake warble

and then unzip the resulting .war file, remove the controller *.rb
files, so that only the compiled .class files remain. If I then deploy
the app I get a scaring stack trace.

Is there some option which I can apply to warbler so that I get
precompiled classes?

There’s no option as of yet, but it sounds like a good potential
feature enhancement. Although I created and maintain Warbler, I
haven’t had the need for ahead-of-time compiled scripts. So if someone
else wants to investigate what it would take and send a patch or way
forward, I’d be happy to accept such help.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Nick,

Nick S. wrote:

There’s no option as of yet, but it sounds like a good potential
feature enhancement. Although I created and maintain Warbler, I
haven’t had the need for ahead-of-time compiled scripts. So if someone
else wants to investigate what it would take and send a patch or way
forward, I’d be happy to accept such help.

/Nick

I’d like to dig into this matter. I guess the starting point would be
jruby-rack. If you could point me to some documentation and/or starting
points in the codebase of jruby-rack, I would appreciate that.

Thanks,
Christian


“He’s a jaded voodoo vagrant on the wrong side of the law. She’s a
chain-smoking mutant Hell’s Angel trying to make a difference in a
man’s
world. They fight crime!”

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkk+aUQACgkQCNjA0nfhW7xwMACgo2OjZhstKLTIT6VSfV7PEp+g
oasAoMXvdQYdJJZh2aoxzTb4CQ+lkNK6
=T3kU
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#4

Christian N. wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I’d like to package a RoR app using warble in such a way that the main
part of the application is being precompiled into Java bytecode using
jrubyc.

Is this something that Rawr could help with?

rawr.rubyforge.org

James B.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#5

On Tue, Dec 9, 2008 at 6:49 AM, Christian N. removed_email_address@domain.invalid
wrote:

I’d like to dig into this matter. I guess the starting point would be
jruby-rack. If you could point me to some documentation and/or starting
points in the codebase of jruby-rack, I would appreciate that.

Hopefully you won’t need to touch jruby-rack. Warbler, on the other
hand, may be what you are looking for 1. Instead, if you could read
up on past threads [e.g., 2] and figure out a standard approach for
pre-compiling scripts and including them in the war file, and perhaps
find a way to integrate that into Warbler, that would be fantastic.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#6

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

james schrieb:

Is this something that Rawr could help with?

rawr.rubyforge.org

Thanks for the hint James. For now I think that the simplest solution
would be to add compilation support to warbler. Which means that instead
of the .rb files simply the .class files are packaged into the .war I
currently see no need for packaging the compiled class files into a .jar
which then would be added to the .war.

Perhaps rawr can be added in a later stage.


“He’s a benighted vegetarian filmmaker on a search for his missing
sister. She’s a mentally unstable impetuous femme fatale with someone
else’s memories. They fight crime!”

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkk/6OoACgkQCNjA0nfhW7zxtwCgiov6qzPiSUTcbSbH5LSP/Bef
fv0AoIi5/n4B+j+g7QB1T+1cVapNpswN
=qTuN
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#7

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Christian N. wrote:

find a way to integrate that into Warbler, that would be fantastic.

/Nick

Thanks so far Nick, I will look into this.

Just a quick note with what I have found out so far:

I used the rails example app which is provided with jruby-rack as a
testing ground.

First, I did some compilation tests so that the application can be
started with ‘jruby ./script/server’ using the compiled .class files.

I simply compiled the .rb files using the following command-line:

find app public -name “*.rb” | xargs jrubyc

As it turns out .rb Files under config/ cannot be compiled into .class
files, because for example config/boot.rb uses File.read to directly
load .rb files ( File.read("#{RAILS_ROOT}/config/environment.rb")) if
these are replaced with .class files rails spits out a file not found
error and the app does not work.

As jruby prefers .class files over .rb files, they can coexist.

If for example app/controller/*.rb files are missing but the compiled
classes exist instead, the application does not work, because rails
somehow needs the .rb files for routing purposes. If a controller .class
file exists without a corresponding .rb file, we get the following error
(for the snoop controller):

No route matches “/snoop” with {:method=>:get}

So as it seems .class files have to coexist with their corresponding .rb
files (at least where direct IO is used within the rails framework).

With the command-line mentioned above, I am able to compile a rails
application and then start and run it using ./script/server.

Unfortunately deploying a .war file generated by warbler does not work.
I believe that jruby-rack causes some trouble here. If the example
application is being compiled, warbled and then deployed (I use jboss
4.2.3GA) I get the following stacktrace just before the application
could be correctly initalized:


21:10:42,066 ERROR [[/rails]] Exception caught
org.jruby.rack.RackInitializationException: IO error –
/home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/app/controllers/application
from
/home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/gems/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:177:in
call' from /home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/gems/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:177:inevaluate_method’
from
/home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/gems/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:161:in
call' from /home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/gems/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:inrun’
from
/home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/gems/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:in
each' from /home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/gems/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:inrun’
from
/home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/gems/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:272:in
run_callbacks' from /home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/gems/gems/rails-2.1.0/lib/initializer.rb:483:inprepare_dispatcher’
… 7 levels…
from
file:/home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/lib/jruby-rack-0.9.2.jar!/rack/builder.rb:22:in
instance_eval' from file:/home/nolte/tools/jboss-4.2.3.GA/server/default/tmp/deploy/tmp8666342699739510041rails-exp.war/WEB-INF/lib/jruby-rack-0.9.2.jar!/rack/builder.rb:22:ininitialize’
from :3

at
org.jruby.rack.DefaultRackApplicationFactory$4.init(DefaultRackApplicationFactory.java:159)
at
org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:53)
at
org.jruby.rack.PoolingRackApplicationFactory.getApplication(PoolingRackApplicationFactory.java:97)
at
org.jruby.rack.DefaultRackDispatcher.process(DefaultRackDispatcher.java:31)
at org.jruby.rack.RackFilter.doFilter(RackFilter.java:51)


The problem here is that controllers/application(.rb) cannot correctly
be loaded, even if the corresponding .rb file exists in the deployment.


“He’s a short-sighted chivalrous hairdresser from the 'hood. She’s a
bloodthirsty blonde wrestler from the wrong side of the tracks. They
fight crime!”

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAklAMK8ACgkQCNjA0nfhW7xxZACeIjohvnJq+bOI0JdAAXbZRNoX
1JMAoPn/uUN+0e/Z9aa6N0ZTDmdWfhjE
=yPRn
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#8

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nick S. schrieb:

/Nick

Thanks so far Nick, I will look into this.


“He’s an ungodly arachnophobic messiah with nothing left to lose. She’s
a foxy psychic detective from a secret island of warrior women. They
fight crime!”

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkk/zboACgkQCNjA0nfhW7yW/ACeM+1sY1vS7uE+J6aFeRJPzHxR
ysoAniyXJZT3vcQ+acAiKcB564XNj316
=X4t9
-----END PGP SIGNATURE-----


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email