Building .war with JRuby and warbler - ruby-on-rails-3

I have been trying for hours to get a JRuby Rails application packaged as a war that actually works, without success... (JRuby 1.6.7, warbler 1.3.5, Rails 3.2.2)
Issue #1: Warbler seems to like to lump all libraries in one root folder rather than respecting the subdirectories they originally came from. For example, the Rails app itself runs fine but the war is broken when libraries are referenced as
require "lib/foo/bar.jar"
require "lib/baz.rb"
Mind you, foo/bar.jar and baz.rb are actually present in WEB-INF/lib, I just don't know how to configure Warbler to wire things up so the requires work right.
Issue #2: If I condescend to change all the requires to
require "bar.jar"
require "baz.rb"
, all is well if I build an executable war file, but if I try dropping the war into a Tomcat 6.0.20 installation, the application fails to initialize:
SEVERE: Error: application initialization failed
java.lang.NullPointerException
at org.jruby.RubyInstanceConfig$ArgumentProcessor.processArguments(RubyInstanceConfig.java:711)
No amount of Googling has shed light on what the problem is. Presumably the war is missing something or misconfigured somehow, but what is it?

I can't say for sure this would cause your error - however I remember that there was a known bug between Jruby and Rails 3.2.x - which was apparently fixed in Jruby 1.7.
I had tried using Rails 3.2 with Jruby 1.6.7 before and came across this:
JIRA-Ticket-JRUBY-3986
Hope that may at least help a little

Related

Jruby 1.7.x compatibility with Warbler gemjar

I have an application using JRuby 1.6.7, Ruby 1.9.2, Rails 3.1.3 and Warbler 1.4.0.beta2
For a while now, I have been trying to update the application to use JRuby 1.7.x. Every time I tried (with versions 1.7.3, 1.7.4, and most recently 1.7.6) I would get the following error:
org.jruby.rack.RackInitializationException: No such file or directory - /home/production/var/tmp/Jetty_0_0_.war/webapp/WEB-INF/lib/gems.jar!/gems/activesupport-3.1.3/lib/active_support/locale/en.yml
After some help from this question here: Warble not including active support locale files, pin pointed that that issue was with the warbler configuration in my application. We had enabled the following configuration:
config.features = %w(gemjar executable compiled)
Specifically, the gemjar feature was the one causing the issue. With that feature disabled, everything works fine (the WAR deploys perfectly)
I am wondering, if anyone else has run into this, or if anyone knows what the issue might be?
And then more specifically, what are the disadvantages to disabling the gemjar feature of Warbler? From what I can tell, there shouldn't theoretically be anything devastating by disabling it... but I may be overlooking something.
(I do also wonder if the full warbler 1.4.0 release might fix this... but I can't find anything about when a release might be coming out)
there are none - actually running a .war with gemjar might have issues on some servers (esp. if they do not expand the deployed .war, since then it's quite hard to reference files/resources packaged in a .war while still inside a .jar). on the other hand it should roll fine if things are expanded (even with gemjar) ...
you should definitely report this with Warbler's repository (if not reported already).
it should not be hard to fix - likely a one liner, I know a PR would be most welcome :)
NOTE: on the other hand if it worked in a previous JRuby and updating 1.7.x is the issue, than it might be a "regression" on JRuby's side and they might actually fix this if they knew about it ...

Sidekiq "needs X11" in a rails project

I'm trying to use sidekiq in a project but have run into an unusual problem that makes no sense.
I've got multiple rails applications on my laptop, many of which are using sidekiq, and are running fine without any problems.
This application also uses sidekiq, and used to work however I'm not running into a problem. I've not touched the project for a while, but the only difference between now, and when it used to work is the upgrade from OS X Lion, to Mountain Lion. This however hasn't effected other projects, so I'm not sure what's going on. When I try to launch Sidekiq, I get an alert stating
To open "sidekiq," you need to install X11.
Would you like to install X11 now?
It's the standard Apple alert, however I don't understand why Sidekiq is supposedly trying to use X11, and why it isn't using it on my other projects?
I'm using
Rails 3.2.8
Ruby 1.9.3p125
Sidekiq 2.13.1
Any help would be really appreciated :)
Got it running. Turned out it wasn't an issue with Sidekiq, but rather ruby for some reason. After I updated ruby to 2.0.0 and fixed other gem issues, the app started up again and is now running. No idea what was going on but it's sorted :)

Create an installer for a Rails JRuby app

I have a Ruby On Rails 3 app that is installed under a Tomcat in Windows XP. I used jruby and warbler to create the war file.
I need to make an installer (Which means getting the code from a git repository, configuring, executing warbler, configure warbler and copy the output to Tomcat.
Can you help me with that? What is the correct approach for this requirement? A batch file and a EXE that executes it?
Simple question: You really have to use Tomcat under Windows?
This question because with Torquebox you could solve your problem in a super simple way. All rake tasks for deploying are there, you could deploy as a war or exploded folder. Otherwise you could use Stompbox to deploy the Heroku style with git.
Look at the documentation for more details: http://torquebox.org/documentation/current/deployment.html

Upgrade Rails 2.3.14 to Rails 3.1.0, or re-write app fresh in Rails 3.1.0

I have upgraded my app to Rails 3.1.0, and while I have solved many compatibility issues, but I have also noticed that there are many redundant files, junk codes, and some features I have to recode again.
I am just wondering if I should just rewrite my app from fresh in Rails 3.1.0, or continue modifying and fixing after the upgrade? The former one will produce a cleaner app, but more work, and the latter one will be faster, but will also take some time to clean up the mess. What is my best approach?
Thanks.
what I do is create a fresh empty rails 3.1 app. Install my gems with bundler. Then I copy over my migrations, my models and my spec tests. Run my tests. Get tests passing, resolve any incompatibility issues. Repeat with config/routes, controllers, views, etc.

Jruby 1.6.0.RC2 + Rails3 + Glassfish-gem = big fail

Having problems getting glassfish to even run on my server. jRuby is absoutely maddening to begin with, but this is killing me.
I have a pretty complex app, so I won't go into too many details, other than to say the Rails2 version is working under jRuby 1.5.1.
When I start and do the first hit on the server I get the following error:
Feb 19, 2011 12:20:14 AM com.sun.grizzly.jruby.RackGrizzlyAdapter dispatchRequest
WARNING: (NoMethodError) undefined method `call' for nil:NilClass
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `call' for nil:NilClass
at Rack::Handler::Grizzly.call(/usr/local/rvm/gems/jruby-1.6.0.RC2/gems/glassfish-1.0.3.dev-universal-java/lib/rack/handler/grizzly.rb:55)
I have tried starting glassfish every way since sunday and have also swapped out various gems. It seems bundler 1.0.10 also has some issues. It broke my Rails2 app.
Any insite anywhere as to where to even start looking would be appreciated.
The app works just fine when running webrick.
The jRuby stack still has a long way to go. Finally figured this debacle out. Turns out the rackup.rb file pulled into glassfish from an as yet unidentified source (I hacked it for now and moved on) has logic that only supports rack in development, test or production. I was using a multistage environment so I could test things out. I had a, shocker, staging environment. So this all worked fine under the old glassfish that detected and ran rails separately but created a host of issues for the rails3 application running with a config.ru rack file.
I will post an update to my blog when I get this nailed down correctly. You can't monkey patch this because glassfish loads from the installed gem location not your own project or even bundle repository.