Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > ClassLoader + tomcat

Reply
Thread Tools

ClassLoader + tomcat

 
 
read-the-signature@send-spam-to-dev-null.com
Guest
Posts: n/a
 
      07-13-2003
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
 
Reply With Quote
 
 
 
 
read-the-signature@send-spam-to-dev-null.com
Guest
Posts: n/a
 
      07-13-2003
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
 
Reply With Quote
 
 
 
 
Wendy S
Guest
Posts: n/a
 
      07-13-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) 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

 
Reply With Quote
 
read-the-signature@send-spam-to-dev-null.com
Guest
Posts: n/a
 
      07-13-2003
Wendy S <(E-Mail Removed)> wrote:
> (E-Mail Removed) 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
 
Reply With Quote
 
Nigel Wade
Guest
Posts: n/a
 
      07-14-2003
(E-Mail Removed) wrote:

> (E-Mail Removed) 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 : (E-Mail Removed)
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
 
Reply With Quote
 
Nigel Wade
Guest
Posts: n/a
 
      07-15-2003
Nigel Wade wrote:

> (E-Mail Removed) wrote:
>
>> (E-Mail Removed) 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 : (E-Mail Removed)
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tomcat classloader Moiristo Java 2 06-21-2006 06:14 PM
Tomcat classloader Moiristo Java 0 06-21-2006 02:26 PM
Tomcat classloader problem Mark F Java 0 03-05-2004 02:33 PM
Tomcat ClassLoader/Compile nightmare Mikito Harakiri Java 0 11-06-2003 11:10 PM
classloader in tomcat Mr. Miguel Java 2 07-14-2003 06:18 PM



Advertisments