# Rails: Rack + AOT --\> RackInitializationException: IO error

**URL:** <https://www.ruby-forum.com/t/rails-rack-aot-rackinitializationexception-io-error/152949>\
**Category:** JRuby\
**Created:** [November 10, 2008, 11:23am UTC](https://www.ruby-forum.com/t/rails-rack-aot-rackinitializationexception-io-error/152949 "2008-11-10T11:23:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [November 10, 2008, 11:23am UTC](https://www.ruby-forum.com/t/rails-rack-aot-rackinitializationexception-io-error/152949/1 "2008-11-10T11:23:25Z")

</div>

Hi,

I’m trying to deploy a very simple RoR application into a Glassfish  
Server.  
The problem here is that I need to protect my source code somehow, so  
I’ve  
compiled all models and controllers with jrubyc, hacked active\_support  
dependencies.rb to accept requiring .class files and removed all .rb  
files.  
So far I’ve been able to launch webbrick (jruby script/server) and it  
works  
fine.  
I’ve packed the application into a war with warble, and deployed it into  
Glassfish.  
And when I try to access the app, I get this error:

[#|2008-11-05T12:38:39.740+0100|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|\_ThreadID=22;\_ThreadName=httpSSLWorkerThread-57151-1;\_RequestID=ab6f35e2-2e2c-42f6-80d1-01e836ed06b8;|WebModule[/test]Exception  
caught org.jruby.rack.RackInitializationException: IO error –  
/root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/app/controllers/application  
from  
/root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/  
vendor/rails/activerecord/lib/…/…/activesupport/lib/active\_support/  
callbacks.rb:177:in `call' from /root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/ vendor/rails/activerecord/lib/../../activesupport/lib/active_support/ callbacks.rb:177:in`evaluate\_method’  
from  
/root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/  
vendor/rails/activerecord/lib/…/…/activesupport/lib/active\_support/  
callbacks.rb:161:in `call' from /root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/ vendor/rails/activerecord/lib/../../activesupport/lib/active_support/ callbacks.rb:90:in`run’  
from  
/root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/  
vendor/rails/activerecord/lib/…/…/activesupport/lib/active\_support/  
callbacks.rb:90:in `each' from /root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/ vendor/rails/activerecord/lib/../../activesupport/lib/active_support/ callbacks.rb:90:in`run’  
from  
/root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/  
vendor/rails/activerecord/lib/…/…/activesupport/lib/active\_support/  
callbacks.rb:272:in `run_callbacks' from /root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/ config/../vendor/rails/railties/lib/initializer.rb:483:in`prepare\_dispatcher’  
… 7 levels…  
from  
/root/glassfishv2/domain1/generated/jsp/j2ee-modules/test/loader/  
rack/builder.rb:22:in `instance_eval' from /root/glassfishv2/domain1/generated/jsp/j2ee-modules/test/loader/ rack/builder.rb:22:in`initialize’  
from :3

```
  at org.jruby.rack.DefaultRackApplicationFactory

```

$4.init(DefaultRackApplicationFactory.java:154)  
at  
org.jruby.rack.DefaultRackApplicationFactory.getApplication(DefaultRackApplicationFactory.java:  
53)  
at  
org.jruby.rack.PoolingRackApplicationFactory.getApplication(PoolingRackApplicationFactory.java:  
92)  
at  
org.jruby.rack.DefaultRackDispatcher.process(DefaultRackDispatcher.java:  
31)  
at org.jruby.rack.RackFilter.doFilter(RackFilter.java:51)  
at  
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:  
230)  
at  
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:  
198)  
…

I think JRuby Rack is trying to parse controllers/application but it  
can’t,  
mainly because it is in java bytecode. After looking a little to the  
rack’s  
code, the little I could understand is that it’s trying to include all  
rails  
app as ruby code, and then let jruby JIT compile it.  
Has anyone got into this problem before? Is there any configuration I  
can  
use to solve this? Is it planned to make rack accept AOT code?  
I’m using jruby-complete-1.1.4.jar and jruby-rack-0.9.2.jar for  
glassfish  
and jruby-1.1.5 for webbrick.

Thanks for your time,

Raimon Malatesta

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [November 12, 2008, 2:20pm UTC](https://www.ruby-forum.com/t/rails-rack-aot-rackinitializationexception-io-error/152949/2 "2008-11-12T14:20:16Z")

</div>

Can anyone help me on this? Or am I writing in the wrong place?

Thanks again,

RaY

2008/11/10 RaY [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [November 12, 2008, 4:38pm UTC](https://www.ruby-forum.com/t/rails-rack-aot-rackinitializationexception-io-error/152949/3 "2008-11-12T16:38:23Z")

</div>

You’re in the right place, I’m not sure anyone’s seen your problem.  
Have you looked on the wiki for tips on pre-compiling ruby scripts? It  
would seem to be related to JRuby support for loading only  
pre-compiled scripts, and I’m not sure if anyone else has reported  
100% success on precompiling a Rails app.

Could there be classloader or security issues that are taking place  
inside Glassfish that aren’t happening inside Mongrel?

/Nick

On Wed, Nov 12, 2008 at 7:19 AM, RaY [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > I’m trying to deploy a very simple RoR application into a Glassfish  
> > [#|2008-11-05T12:38:39.740+  
> > vendor/rails/activerecord/lib/../../activesupport/lib/active\_support/  
> > /root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/  
> > from  
> > from :3  
> > 92)  
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:  
> > and jruby-1.1.5 for webbrick.
> > 
> > Thanks for your time,
> > 
> > Raimon Malatesta

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [November 12, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/rails-rack-aot-rackinitializationexception-io-error/152949/4 "2008-11-12T16:47:51Z")

</div>

I will also add that I do not think you needed to hack anything to  
load those compiled files. They should have loaded so long as they  
were in your classpath.

-Tom

On Wed, Nov 12, 2008 at 9:37 AM, Nick S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > /root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/  
> > > from  
> > > callbacks.rb:272:in `run_callbacks' rack/builder.rb:22:in `initialize’  
> > > org.jruby.rack.PoolingRackApplicationFactory.getApplication(PoolingRackApplicationFactory.java:
> > > 
> > > I’m using jruby-complete-1.1.4.jar and jruby-rack-0.9.2.jar for glassfish  
> > > [http://xircles.codehaus.org/manage\_email](http://xircles.codehaus.org/manage_email)

–  
Blog: [http://www.bloglines.com/blog/ThomasEEnebo](http://www.bloglines.com/blog/ThomasEEnebo)  
Email: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) , [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [November 12, 2008, 4:50pm UTC](https://www.ruby-forum.com/t/rails-rack-aot-rackinitializationexception-io-error/152949/5 "2008-11-12T16:50:15Z")

</div>

Thanks,

I think the problem may be in jruby rack, not with Glassfish, the  
exception is rised when trying to read the compiled ruby scripts. I  
will try it on Tomcat too, and see what I can get. I haven’t tried  
with mongrel neither. I will see what I can find and post the results.  
In the wiki there is a little explanation I followed to get where I am  
right now.  
I’ll keep researching.

Thanks again,

RaY

El 12/11/2008, a las 16:37, Nick S.  
escribió:

> > > I’ve packed the application into a war with warble, and deployed  
> > > ;\_ThreadName  
> > > active\_support/  
> > > callbacks.rb:161:in `call’  
> > > from  
> > > /root/glassfishv2/domain1/applications/j2ee-modules/test/WEB-INF/
> > > 
> > > ```
> > > at
> > > 
> > > ```
> > > 
> > > .rack.DefaultRackDispatcher.process(DefaultRackDispatcher.java:  
> > > 230)  
> > > can’t, mainly because it is in java bytecode. After looking a

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```
