Forum: JRuby warbler: using a jar included in the built jar

71c85a662af0764df3a77cc00db166c9?d=identicon&s=25 Raphael B. (raphael_b)
on 2014-01-13 16:19
(Received via mailing list)
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
http://stackoverflow.com/questions/11122130/jar-ge...).

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
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 christian (Guest)
on 2014-01-13 16:31
(Received via mailing list)
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
71c85a662af0764df3a77cc00db166c9?d=identicon&s=25 Raphael B. (raphael_b)
on 2014-01-13 16:41
(Received via mailing list)
On Mon, Jan 13, 2014 at 4:30 PM, christian <m.kristian@web.de> 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


> 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
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 christian (Guest)
on 2014-01-13 16:51
(Received via mailing list)
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.
71c85a662af0764df3a77cc00db166c9?d=identicon&s=25 Raphael B. (raphael_b)
on 2014-01-13 17:09
(Received via mailing list)
On Mon, Jan 13, 2014 at 4:50 PM, christian <m.kristian@web.de> 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
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 christian (Guest)
on 2014-01-13 17:16
(Received via mailing list)
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
71c85a662af0764df3a77cc00db166c9?d=identicon&s=25 Raphael B. (raphael_b)
on 2014-01-13 17:25
(Received via mailing list)
On Mon, Jan 13, 2014 at 5:15 PM, christian <m.kristian@web.de> 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.
71c85a662af0764df3a77cc00db166c9?d=identicon&s=25 Raphael B. (raphael_b)
on 2014-01-17 14:42
(Received via mailing list)
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
B05d3cbc64b0031a24c2887fb6ddc173?d=identicon&s=25 christian (Guest)
on 2014-01-17 15:00
(Received via mailing list)
thanx for the follow-up - did know that detail ;)

- christian
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.