« Return to Thread: Tomcat: Setting the JRuby version

Re: Tomcat: Setting the JRuby version

by Gary Weaver :: Rate this Message:

Reply to Author | View in Thread

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: http://en.wikipedia.org/wiki/Classloader

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:

> 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 Abley wrote:
>  
>> 2009/6/23 F2Andy <andy.joel@...>:
>>    
>>> 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
>>
>>
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Tomcat: Setting the JRuby version