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

Discussion in 'Java' started by Steve Sobol, Aug 10, 2005.

  1. Steve Sobol

    Steve Sobol Guest

    [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? :(

    --
    Steve Sobol, Professional Geek 888-480-4638 PGP: 0xE3AE35ED
    Company website: http://JustThe.net/
    Personal blog, resume, portfolio: http://SteveSobol.com/
    E: Snail: 22674 Motnocab Road, Apple Valley, CA 92307
     
    Steve Sobol, Aug 10, 2005
    #1
    1. Advertising

  2. Steve Sobol wrote:
    > [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

    --
    XML is the programmer's duct tape.
     
    Raymond DeCampo, Aug 10, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim
    Replies:
    2
    Views:
    884
  2. Hans
    Replies:
    3
    Views:
    2,620
    Ryan Stewart
    May 16, 2004
  3. Ike
    Replies:
    6
    Views:
    1,099
    Andrew Thompson
    Sep 24, 2004
  4. Replies:
    5
    Views:
    9,115
  5. JavaEnquirer
    Replies:
    2
    Views:
    549
    JavaEnquirer
    Feb 22, 2006
Loading...

Share This Page