Tomcat: Setting the JRuby version

View: New views
6 Messages — Rating Filter:   Alert me  

Tomcat: Setting the JRuby version

by F2Andy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

Re: Tomcat: Setting the JRuby version

by James Abley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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



Re: Tomcat: Setting the JRuby version

by F2Andy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@f2chemicals.com>:
>
> 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


Re: Tomcat: Setting the JRuby version

by Nick Sieger-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jun 23, 2009 at 9:27 AM, F2Andy <andy.joel@...> 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



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
>
>
>
>

--
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




Re: Tomcat: Setting the JRuby version

by Gary Weaver :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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



Re: Tomcat: Setting the JRuby version

by Charles Oliver Nutter-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jun 23, 2009 at 9:57 AM, Nick Sieger<nicksieger@...> wrote:

> On Tue, Jun 23, 2009 at 9:27 AM, F2Andy <andy.joel@...> 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?

Maybe try wiping out the tmp/war dir and rebuilding the war file?
Maybe you have two jruby-complete jars in the gem location for
warbler?

The short answer here is that "it depends"...as Gary Weaver said, it
could be loaded in any order, and the first one in Tomcat's webap
classpath will be the one that gets used.

- Charlie

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

    http://xircles.codehaus.org/manage_email