# Warbler: using a jar included in the built jar

**URL:** <https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485>\
**Category:** JRuby\
**Created:** [January 13, 2014, 4:19pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485 "2014-01-13T16:19:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [January 13, 2014, 4:19pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485/1 "2014-01-13T16:19:01Z")

</div>

Hi,

The code I’m trying to package in a jar with warbler uses jar files in  
the  
lib/ directory.

I replaced the code of the script running fine in the terminal  
Dir[“#{File.dirname( **FILE** )}/…/lib/_/_.jar”].each { |jar| puts jar;  
require jar }  
by this  
Dir[“lib/_/_.jar”].each { |jar| puts jar; $CLASSPATH \<\< jar }

(as mentioned on  
[jruby - JAR generated by warbler cannot access included internal JAR library - Stack Overflow](http://stackoverflow.com/questions/11122130/jar-generated-by-warbler-cannot-access-included-internal-jar-library)).

The java\_imports run fine, but there is still an error (not present when  
running the script in the terminal):

3199 [main] WARN org.eclipse.jetty.webapp.StandardDescriptorProcessor -  
Could not instantiate listener  
org.eclipse.jetty.servlet.listener.ELContextCleaner  
java.lang.ClassNotFoundException:  
org.eclipse.jetty.servlet.listener.ELContextCleaner

and again the same message about  
org.eclipse.jetty.servlet.listener.IntrospectorCleaner .  
These classes are in a jar under /lib, that was added to the classpath.  
Other classes loaded from jar files seem to be accessible.

Is $CLASSPATH \<\< jar sufficient or should I issue another command?  
And why are other classes apparently accessible?

Thx for your help

Raph

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [January 13, 2014, 4:31pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485/2 "2014-01-13T16:31:17Z")

</div>

so you are running jetty and is jetty not finding some classes ?

CLASSPATH environment feels wrong especially if jetty tries to setup  
some  
context-classloaders for the webapp.

- christian

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [January 13, 2014, 4:41pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485/3 "2014-01-13T16:41:48Z")

</div>

On Mon, Jan 13, 2014 at 4:30 PM, christian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> so you are running jetty and is jetty not finding some classes ?
> 
> yes. I pasted the full error message at [http://pastie.org/8629602](http://pastie.org/8629602)

> CLASSPATH environment feels wrong especially if jetty tries to setup some  
> context-classloaders for the webapp.

Do you mean I should not modify the classpath?

I added a java\_import for each problematic class in the code and these  
are  
successful:

java\_import ‘org.eclipse.jetty.servlet.listener.ELContextCleaner’  
java\_import ‘org.eclipse.jetty.servlet.listener.IntrospectorCleaner’

I wonder why jetty doesn’t find them…

Raph

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [January 13, 2014, 5:09pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485/4 "2014-01-13T17:09:16Z")

</div>

On Mon, Jan 13, 2014 at 4:50 PM, christian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> this is warfile or jarfile ?

This is a jarfile. The ruby code instantiates a Jetty server.

> loading classes into the jruby-classloader does not make jetty find them  
> since the webapp-classloader is probably the parent-classloader of the  
> jruby-classloader.
> 
> make warble pack your jar into the WEB-INF/lib directory - assuming you  
> build a wargfile with warbler.

and for a jar?

thx for your help

Raph

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [January 13, 2014, 4:51pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485/5 "2014-01-13T16:51:44Z")

</div>

this is warfile or jarfile ?

loading classes into the jruby-classloader does not make jetty find them  
since the webapp-classloader is probably the parent-classloader of the  
jruby-classloader.

make warble pack your jar into the WEB-INF/lib directory - assuming you  
build a wargfile with warbler.

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [January 13, 2014, 5:16pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485/6 "2014-01-13T17:16:52Z")

</div>

hmm.

I guess that is more a jetty problem, i.e. where to put the jars and how  
to  
setup the context config for jetty. I doubt jetty will be able to load  
jar  
packed inside a jar - that is jruby only feature !!!

I guess you need to explode the webapp for jetty somewhere and run it  
from  
the filesystem.

-christian

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [January 13, 2014, 5:25pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485/7 "2014-01-13T17:25:03Z")

</div>

On Mon, Jan 13, 2014 at 5:15 PM, christian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hmm.
> 
> I guess that is more a jetty problem, i.e. where to put the jars and how  
> to setup the context config for jetty. I doubt jetty will be able to load  
> jar packed inside a jar - that is jruby only feature !!!

ok I see. thx for your help.

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [January 17, 2014, 3:00pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485/8 "2014-01-17T15:00:01Z")

</div>

thanx for the follow-up - did know that detail 😉

- christian

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [January 17, 2014, 2:42pm UTC](https://www.ruby-forum.com/t/warbler-using-a-jar-included-in-the-built-jar/238485/9 "2014-01-17T14:42:08Z")

</div>

FYI, it is possible to specify the class loader to be used by a jetty  
context:  
web\_context.setClassLoader(JRuby.runtime.jruby\_class\_loader)

This solved the problem I had

Cheers

raph
