Tomcat: Setting the JRuby version

This might be a stupid question, but how do you tell Tomcat (5.5) to use
a
specific version of JRuby? I have tried searching the web, and looking
though the verious config files, but found nothing.

View this message in context:
http://www.nabble.com/Tomcat%3A-Setting-the-JRuby-version-tp24166536p24166536.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

2009/6/23 F2Andy [email protected]:

This might be a stupid question, but how do you tell Tomcat (5.5) to use a
specific version of JRuby? I have tried searching the web, and looking
though the verious config files, but found nothing.

Normally, you would put JRuby jars in your webapp, in WEB-INF/lib.
What does your app look like; e.g. is it rails and you are using
warbler to build a WAR file?

Cheers,

James


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Yes, this is Rails, packaged with Warbler. I see that Warbler has put
two
versions of JRuby in WEB-INF\lib (jruby-complete-1.3.0RC1.jar and
jruby-complete-1.1.6.jar). How does Tomcat decide which to use? It
currently
picks jruby-complete-1.1.6.jar. How does Warbler choose which ones to
pack?
Why does it not pack jruby-complete-1.3.0RC2.jar? My project is actually
inside the jruby-1.3.0RC2 directory, by the way.

James A. wrote:

warbler to build a WAR file?


View this message in context:
http://www.nabble.com/Tomcat%3A-Setting-the-JRuby-version-tp24166536p24167034.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Tue, Jun 23, 2009 at 9:27 AM, F2Andy [email protected]
wrote:

Yes, this is Rails, packaged with Warbler. I see that Warbler has put two
versions of JRuby in WEB-INF\lib (jruby-complete-1.3.0RC1.jar and
jruby-complete-1.1.6.jar). How does Tomcat decide which to use? It
currently
picks jruby-complete-1.1.6.jar. How does Warbler choose which ones to pack?
Why does it not pack jruby-complete-1.3.0RC2.jar? My project is actually
inside the jruby-1.3.0RC2 directory, by the way.

Whoops, there should only be one version. Did you specify a version
somehow,
or did Warbler accidentally pick two up from somewhere?

/Nick

There are some good resources out there on how Tomcat’s classloading
works. The official ones are on the tomcat site, for example:
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html

See also: Java Classloader - Wikipedia

I think the classloaders for Tomcat, etc. usually load jars in the order
that they were returned from java.io.File.list() and this order is not
guaranteed, so basically, as much as possible you especially want to try
to avoid situations where there are two versions of the same jar loaded
by the same classloader (in this case, the same classloader was loading
from jars in the webapp’s WEB-INF/lib I assume).

So, enough of all of that since you just want to know how to fix?

As Nick described in the example config for jruby-rack jar, you can
configure Warbler to include specific versions of jruby and jruby-rack
jars by doing this in warble.rb:

Additional Java .jar files to include. Note that if .jar files are

placed

in lib (and not otherwise excluded) then they need not be mentioned

here.

JRuby and JRuby-Rack are pre-loaded in this list. Be sure to include

your

own versions if you directly set the value

config.java_libs += FileList[“lib/java/*.jar”]

config.java_libs.delete_if {|f| f =~ /jruby-rack/ || f =~
/jruby-complete/ }
config.java_libs += FileList[“lib/jruby-complete*.jar”]
config.java_libs += FileList[“lib/jruby-rack*.jar”]

This example removes any jars containing jruby-rack and jruby-complete
in the filenames, and then adds only the ones you put into your lib
directory. You could change that to whatever best fits.

I think Nick said that he is going to probably remove those from being
packaged by warbler in a future release.

Be sure that if you do this that you are using the same version of JRuby
(and jruby-rack) in your lib (which will be packaged in the war) as the
one for your tests!

Gary

P.S.- another example here if you’re interested in using the latest
jruby trunk:
http://stufftohelpyouout.blogspot.com/2009/06/how-to-get-warbler-to-include-custom.html

F2Andy wrote:

2009/6/23 F2Andy [email protected]:
Cheers,


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email