Cannot set JRuby to run in 1.9 mode
If I uncomment this line in config/warbler.rb
# Set JRuby to run in 1.9 mode.
config.webxml.jruby.compat.version = "1.9"
Then $ warble throws
warble aborted!
undefined method `jruby' for nil:NilClass
(eval):119:in `initialize'
/Users/beigaedg/.rvm/gems/jruby-1.6.5@global/gems/warbler-1.3.2/lib/warbler/config.rb:171:in `initialize'
(eval):5:in `initialize'
org/jruby/RubyKernel.java:1088:in `eval'
I am using JRuby 1.6.5 and I tried this with warbler 1.3.2 and master (both have these erros).
What am I doing wrong?
I have the same problem. It only happens (at least for me) if your application is not a web-app.
I'm having a desktop app, and I want the .jar to use 1.9, and I can't figure out how to do that. I think this options is only for web apps. Is there another way to use 1.9 with .jar?
I looked a bit into the source of Warbler, but didn't find an easy fix for this. I hope the main dev notices this bug report and commits a patch soon..
I have an error with the well known "to_yaml" method issue when using 1.9 compat mode. It sucks that warbler only compiles jruby 1.8 web apps >_< there are an alternative to warbler?
This is odd. Just to thicken the plot, we use the same versions of JRuby and Warbler that you do, and we set config.webxml.jruby.compat.version to 1.9 just as you do, and do not receive the same error. WARs are created and appear to run in 1.9 mode as expected.
I also cannot reproduce this, and have a JRuby app right now in development that builds with warbler and uses 1.9.
Further details:
- the Ruby app is NOT a web-application! -- 3 folders: bin, lib, config -- 2 files: warble.rb, app.rb -- no config.ru
- Operating System is Mac OS X Snow Leo
I got the same issue as gottlike. My app is not an webapp, have only bin and lib folders, and got the same error.
I also am encountering this issue. Any resolution?
check this quick fix which enable you to run the jar in 1.9 mode
https://github.com/jruby/warbler/issues/61#issuecomment-2735080
java -Djruby.compat.version=1.9 -jar yourjar.jar
Thx maismail, much appreciated!
+1 same problem here.
So, the jar and war use different Java main programs to launch JRuby. The war reads a property file and sets Java system properties, and this property file can be generated from warbler configs.
The jar main doesn't do anything of the sort.
I was able to hack around this entirely by writing my own main program:
class Main {
public static void main(String[] args) {
System.setProperty("jruby.compat.version", "1.9");
JarMain.main(args);
}
}
You can then do this:
JRUBY_OPTS=--1.9 warble compiled jar
cp /path/to/Main.java .
javac -cp myscript.jar Main.java
jar ufe myscript.jar Main Main.class
rm Main.*
The reason for copying Main.java in from elsewhere is that the Java source doesn't need to be in the jar. Won't hurt anything if it is, it just doesn't need to be.
If there are simpler ways to do this, I'd love to know. The obvious solution would be to patch warbler to allow something like this in JarMain directly, rather than bootstrapping it in this somewhat awkward way, but this may be useful to anyone who needs to actually build a working jar right now.
+1, this should seriously be fixed and given a general option.
I ran into this same issue tonight. Fun times first time using Warbler.
I have to admit, I'm a bit disappointed that it's been 5 months since I first posted my workaround (and an explanation of what's actually going on), and there seems to have been no movement on this. Yeah, yeah, patches welcome, I'll probably end up having to fix this myself. But this has got to be easier for anyone who actually knows the Warbler architecture.
Yes, I am going to have to fix this myself to do the deployment that I am planning. I need the bundle to just run with java -jar ... since this is going into third-party environments. If I have to, I will fork the project, prepare a fix and issue a pull request back for it. However, I am brand new to JRuby and Warbler - as of yesterday - so that does seem a little silly to have to do.
It's funny to me because when I really started in using Ruby, I was learning on Ruby 1.9 and the latest Rails 3. So I really never used 1.8 and definitely do not have legacy code to support. So perhaps these defaults make sense to other people?
@masover @rietta I want to merge #117 but looks like it breaks the test suite, if someone can look and fix it I will merge inmediatly
@rietta: The workaround I posted will make it run with just 'java -jar'. It's just that it makes the compile steps worse.
The defaults make sense because Warbler hasn't been updated in awhile, I guess? There's also the fact that 1.8 has always been more stable on JRuby, but I don't think that's true anymore, either. I don't mind 1.9 not being a default, but I do mind having to hack on the jarfile just to get it working.