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).
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
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.
On Mon, Jan 13, 2014 at 4:30 PM, christian [email protected] 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
On Mon, Jan 13, 2014 at 4:50 PM, christian [email protected] 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
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.
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
On Mon, Jan 13, 2014 at 5:15 PM, christian [email protected] 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.
thanx for the follow-up - did know that detail
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