Jetty, WEB-INF/lib, jars and the classpath

S

Steve Sobol

[Posted to the Jetty-support mailing list, but I'm not expecting a reply
real soon due to mail server issues at Sourceforge.]

Ok, I can't figure this out.

I'm using Jetty 5.1.2.

I have a JAR, containing a couple beans I'm using to support a web app.
This JAR uses several JDom classes.

I have a web app elsewhere on my server that requires an earlier version
of JDom, so I put that earlier version of JDom in the WEB-INF/lib
directory for that app and it works fine.

Back to the app I'm having problems with. I created a JAR with some
support classes for this app, and in the manifest I have

Class-Path: jdom-xpath.jar

(I specifically renamed the newer jdom.jar to jdom-xpath.jar so I wouldn't
get the two jars mixed up. The older jdom jar doesn't have xpath support.)

I've also tried

Class-Path: ./jdom-xpath.jar

Neither one works. I have both my jar and jdom-xpath.jar in the
WEB-INF/lib directory of my webapp, but when I try to use my jar, I end up
with a NoClassDefFoundError - the classloader can't find org.jdom.Text,
and I've checked - and org/jdom/Text.class *is* sitting in jdom-xpath.jar.

I suspect I'm doing something wrong, but what?

Here's another data point. I created a test class and packaged it up in a
jar file, and in the manifest I put Class-Path: jdom-xpath.jar.

This test class has a constructor that, when the class is loaded, prints
the contents of java.class.path to stdout. When I call it from a JSP using
<jsp:useBean>, the only classpath entry I see, besides the entries that
Jetty got from my CLASSPATH environment variable, is the directory from
which I started Jetty. No jdom-xpath.jar anywhere in the output.

What am I doing wrong? :(
 
R

Raymond DeCampo

Steve said:
[Posted to the Jetty-support mailing list, but I'm not expecting a reply
real soon due to mail server issues at Sourceforge.]

Ok, I can't figure this out.

I'm using Jetty 5.1.2.

I have a JAR, containing a couple beans I'm using to support a web app.
This JAR uses several JDom classes.

I have a web app elsewhere on my server that requires an earlier version
of JDom, so I put that earlier version of JDom in the WEB-INF/lib
directory for that app and it works fine.

Back to the app I'm having problems with. I created a JAR with some
support classes for this app, and in the manifest I have

Class-Path: jdom-xpath.jar

(I specifically renamed the newer jdom.jar to jdom-xpath.jar so I wouldn't
get the two jars mixed up. The older jdom jar doesn't have xpath support.)

I've also tried

Class-Path: ./jdom-xpath.jar

Neither one works. I have both my jar and jdom-xpath.jar in the
WEB-INF/lib directory of my webapp, but when I try to use my jar, I end up
with a NoClassDefFoundError - the classloader can't find org.jdom.Text,
and I've checked - and org/jdom/Text.class *is* sitting in jdom-xpath.jar.

In theory, if both the jars are in the WEB-INF/lib, there is no need to
include a Class-Path in the MANIFEST, because everything in the
WEB-INF/lib should be included already. Perhaps the entry is confusing
things?
I suspect I'm doing something wrong, but what?

Here's another data point. I created a test class and packaged it up in a
jar file, and in the manifest I put Class-Path: jdom-xpath.jar.

This test class has a constructor that, when the class is loaded, prints
the contents of java.class.path to stdout. When I call it from a JSP using
<jsp:useBean>, the only classpath entry I see, besides the entries that
Jetty got from my CLASSPATH environment variable, is the directory from
which I started Jetty. No jdom-xpath.jar anywhere in the output.

Keep in mind that application servers use a multitude of class loaders.
The class loader used for your web application will not be based on
the java.class.path property. So the experiment is worthless :-/
What am I doing wrong? :(

HTH,
Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top