ClassLoader + tomcat

Discussion in 'Java' started by read-the-signature@send-spam-to-dev-null.com, Jul 13, 2003.

  1. Guest

    Greetings,

    I don't know if this is the right group to pose this question to or not.
    If there is a better group, let me know.

    I'm developing a web application run under tomcat and am using jar files.
    For some reason. I'm let to believe that by default tomcat makes available
    through its class loader all java classes in jar files at
    $CATALINA_HOME/webapps/app/WEB-INF/lib.

    --
    John J. Rushford
    j j r { a t } a l i s a { d o t } o r g
    http://www.cs.du.edu/~jjr
    , Jul 13, 2003
    #1
    1. Advertising

  2. Guest

    Greetings,

    Excuse the follow up to my own post but my newsreader program went beserk
    and posted prematurely.

    I don't know if this is the right group to pose this question to or not.
    If there is a better group, let me know.

    I'm developing a web application run under tomcat and am using jar files.
    I'm let to believe that by default tomcat makes available through its class
    loader all java classes in jar files at
    $CATALINA_HOME/webapps/app/WEB-INF/classes/lib.
    I'm finding that this is not the case on the tomcat instance that I'm using
    as I've jar'd up a mysql driver, DbConnectionBroker, and various utiliity
    classes that I've written and place this jar file at the above location.
    After several restarts of tomcat, the application is not finding these
    classes in the jar file.

    I thought tomcat automatically made available jar files to the application
    installed in this directory. Is there some configuration that I must perform
    in tomcat to make these jar files visible

    --
    John J. Rushford
    j j r { a t } a l i s a { d o t } o r g
    http://www.cs.du.edu/~jjr
    , Jul 13, 2003
    #2
    1. Advertising

  3. Wendy S Guest

    wrote:

    > I'm developing a web application run under tomcat and am using jar files.
    > I'm let to believe that by default tomcat makes available through its
    > class loader all java classes in jar files at
    > $CATALINA_HOME/webapps/app/WEB-INF/classes/lib.
    > I'm finding that this is not the case on the tomcat instance that I'm
    > using as I've jar'd up a mysql driver, DbConnectionBroker, and various
    > utiliity classes that I've written and place this jar file at the above
    > location. After several restarts of tomcat, the application is not finding
    > these classes in the jar file.


    What version of Tomcat, what version of the JDK (and whose) are you using?
    List the contents of the .jar file, are the classes properly arranged in
    directories matching their package structure? (They _are_ packaged,
    right?) What exact error message are you seeing?

    Can you write a simple Java class with a main method that does basically the
    same thing you're trying to do from a Servlet? (IOW, have your classes
    already been tested thoroughly before you add Tomcat to the mix?)

    Check the common directories and make sure there's nothing in there that
    conflicts with the classes you're trying to load. (Did you maybe drop a
    mysql driver in common/lib previously?)

    --
    Wendy in Chandler, AZ
    Wendy S, Jul 13, 2003
    #3
  4. Guest

    Wendy S <> wrote:
    > wrote:
    >
    >> I'm developing a web application run under tomcat and am using jar files.
    >> I'm let to believe that by default tomcat makes available through its
    >> class loader all java classes in jar files at
    >> $CATALINA_HOME/webapps/app/WEB-INF/classes/lib.
    >> I'm finding that this is not the case on the tomcat instance that I'm
    >> using as I've jar'd up a mysql driver, DbConnectionBroker, and various
    >> utiliity classes that I've written and place this jar file at the above
    >> location. After several restarts of tomcat, the application is not finding
    >> these classes in the jar file.

    >
    > What version of Tomcat, what version of the JDK (and whose) are you using?
    > List the contents of the .jar file, are the classes properly arranged in
    > directories matching their package structure? (They _are_ packaged,
    > right?) What exact error message are you seeing?
    >
    > Can you write a simple Java class with a main method that does basically the
    > same thing you're trying to do from a Servlet? (IOW, have your classes
    > already been tested thoroughly before you add Tomcat to the mix?)
    >
    > Check the common directories and make sure there's nothing in there that
    > conflicts with the classes you're trying to load. (Did you maybe drop a
    > mysql driver in common/lib previously?)
    >


    I'm using tomcat 4.1.24 and Sun's jdk version 1.3.1-p8 built for a FreeBSD
    4.8 system. The classes are listed and arranged properly. I moved the
    mysql driver and DbConnectionBroker class to common/lib/mysql.jar and the
    application finds these two classes but, I am using util.MySqlConnection a
    class that I wrote and is jar'd up at
    $CATALINA_HOME/webapps/myapp/WEB-INF/classes/lib/util.jar

    $ jar tvf util.jar

    0 Sun Jul 13 11:50:52 CDT 2003 META-INF/
    71 Sun Jul 13 11:50:52 CDT 2003 META-INF/MANIFEST.MF
    0 Sun Jul 13 11:50:40 CDT 2003 util/
    1161 Sun Jul 13 11:43:18 CDT 2003 util/MySqlConnection.class

    If I move util.jar to common/lib and restart tomcat, the application
    works fine. But when I put the util.jar where I want it with the application
    at myapp/WEB-INF/classes/lib/util.jar, I run into the problem.

    The docmentation I'm reading says that the class loader should load the util.jar
    from this location but its not. Do you know what I should check with the
    tomcat configuration?

    thanks
    --
    John J. Rushford
    j j r { a t } a l i s a { d o t } o r g
    http://www.cs.du.edu/~jjr
    , Jul 13, 2003
    #4
  5. Nigel Wade Guest

    wrote:

    > wrote:
    >> I'm using tomcat 4.1.24 and Sun's jdk version 1.3.1-p8 built for a
    >> FreeBSD
    >> 4.8 system. The classes are listed and arranged properly. I moved the
    >> mysql driver and DbConnectionBroker class to common/lib/mysql.jar and the
    >> application finds these two classes but, I am using util.MySqlConnection
    >> a class that I wrote and is jar'd up at
    >> $CATALINA_HOME/webapps/myapp/WEB-INF/classes/lib/util.jar
    >>

    >
    > I found the problem. The jar should be at
    > $CATALINA_HOME/webapps/myapp/WEB-INF/lib.
    >


    Correct. Jars go in WEB-INF/lib and classes in WEB-INF/classes.

    That's for servlet specific code. If you want the jars/classes to be
    available to all servlets then you can put them in
    $CATALINA_HOME/common/{lib,classes}.

    --
    Nigel Wade, System Administrator, Space Plasma Physics Group,
    University of Leicester, Leicester, LE1 7RH, UK
    E-mail :
    Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
    Nigel Wade, Jul 14, 2003
    #5
  6. Nigel Wade Guest

    Nigel Wade wrote:

    > wrote:
    >
    >> wrote:
    >>> I'm using tomcat 4.1.24 and Sun's jdk version 1.3.1-p8 built for a
    >>> FreeBSD
    >>> 4.8 system. The classes are listed and arranged properly. I moved the
    >>> mysql driver and DbConnectionBroker class to common/lib/mysql.jar and
    >>> the application finds these two classes but, I am using
    >>> util.MySqlConnection a class that I wrote and is jar'd up at
    >>> $CATALINA_HOME/webapps/myapp/WEB-INF/classes/lib/util.jar
    >>>

    >>
    >> I found the problem. The jar should be at
    >> $CATALINA_HOME/webapps/myapp/WEB-INF/lib.
    >>

    >
    > Correct. Jars go in WEB-INF/lib and classes in WEB-INF/classes.
    >
    > That's for servlet specific code. If you want the jars/classes to be
    > available to all servlets then you can put them in
    > $CATALINA_HOME/common/{lib,classes}.
    >


    Woops, that should read $CATALINA_HOME/shared/{lib,classes}.

    They can go in common, but that's supposed to be for classes which are
    needed by both Tomcat itself and serlvets.


    --
    Nigel Wade, System Administrator, Space Plasma Physics Group,
    University of Leicester, Leicester, LE1 7RH, UK
    E-mail :
    Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
    Nigel Wade, Jul 15, 2003
    #6
    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. Mr. Miguel

    classloader in tomcat

    Mr. Miguel, Jul 11, 2003, in forum: Java
    Replies:
    2
    Views:
    583
    Miguel De Anda
    Jul 14, 2003
  2. Mikito Harakiri

    Tomcat ClassLoader/Compile nightmare

    Mikito Harakiri, Nov 6, 2003, in forum: Java
    Replies:
    0
    Views:
    326
    Mikito Harakiri
    Nov 6, 2003
  3. Mark F

    Tomcat classloader problem

    Mark F, Mar 5, 2004, in forum: Java
    Replies:
    0
    Views:
    468
    Mark F
    Mar 5, 2004
  4. Moiristo

    Tomcat classloader

    Moiristo, Jun 21, 2006, in forum: Java
    Replies:
    0
    Views:
    321
    Moiristo
    Jun 21, 2006
  5. Moiristo

    Tomcat classloader

    Moiristo, Jun 21, 2006, in forum: Java
    Replies:
    2
    Views:
    537
    Moiristo
    Jun 21, 2006
Loading...

Share This Page