This post was first published on the imedo.de devblog. The blog went offline in 2012, so I migrated the posts to my personal blog.
If you try to deploy your Rails app which is using Rails Engines with JRuby in an Java application server, you end up with errors on the first request. Basically JRuby is complaining that it cannot create directories. This is due to the fact that engines tries to copy over assets from the plugins into the public dir of the rails app.
In an application server the rails directory structure is "turned inside out" as Nick Sieger calls it. So the public directory is actually inside the base dir of the deployed app and the class files are in the WEB-INF dir.
You can easily fix that if you put the following code right after your engines require in your environment.rb (or inside an initializer file):
if Object.const_defined?("PUBLIC_ROOT")
Engines.public_directory = PUBLIC_ROOT
end
PUBLIC_ROOT is defined inside JRuby (or warble) and set to the correct path by warble.
I found out about this behavouir in the Rails Tutorial Session Take the Jruby Challenge: Deploy Your Rails Application With JRuby and Taste the Difference with the helping hand of Nick Sieger
Related Posts
- Stop writing tutorials - start writing Vagrantfiles or Dockerfiles - Make use of modern tools to make tutorials understandable as well as executable
- The missing piece: Operating Systems for web scale Cloud Apps - Operating systems that are optimised for cloud applications regarding configuration support and the distributed nature of apps are not there yet.
- There will be no reliable cloud (part 3) - How I stopped worrying and love the cloud