You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Borut Hadžialić <bo...@gmail.com> on 2006/08/22 15:25:02 UTC

Tomcat 5.5 class loader question.

Hello, I have a question related to class loading in tomcat.

http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html
Tomcat documentation says this:

***
Therefore, from the perspective of a web application,
class or resource loading looks in the following repositories,
in this order:

Bootstrap classes of your JVM
System class loader classses (described above)
/WEB-INF/classes of your web application
/WEB-INF/lib/*.jar of your web application
$CATALINA_HOME/common/classes
$CATALINA_HOME/common/endorsed/*.jar
$CATALINA_HOME/common/i18n/*.jar
$CATALINA_HOME/common/lib/*.jar
$CATALINA_BASE/shared/classes
$CATALINA_BASE/shared/lib/*.jar
***

But while installing Jira (a popular web application for issue tracking),
we seem to have observed different behaviour.

We have set up a Tomcat instance for Jira (in some directory, lets
call it CATALINA_BASE).

Jira has a set of jar files that contain dependencies, that are not
included in Jira's /WEB-INF/lib directory.
Jira manual states that these jars should be copied to
CATALINA_HOME/common/lib directory.
When those files are copied to CATALINA_HOME/common/lib, Jira works fine.

However, when we move those Jira dependencies from
$CATALINA_HOME/common/lib/ to $CATALINA_BASE/shared/lib/
Jira starup fails - it throws several ClassDefNotFoundException
(for org.postgresql.Driver and other classes)

All this happened while the Jira instance was the only Tomcat instance
on the server,
and while $CATALINA_HOME/conf xml config files did not contain any
entries specific for Jira or
any other aplication other than those that come with Tomcat ba default.

Accoring to what Tomcat help stated this should not be happening,
because jar were only moved to another directory which is also
included in the search path of the class loader.

Does anyone know why is this happening?

redhat 4.1
Java jdk1.5.0_07
Tomcat 5.5.x, probably 5.5.17
atlassian-jira-standard-3.6.3

-- 
Why?
Because YES!

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 5.5 class loader question.

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Borut Hadžialić wrote:
> Jira has a set of jar files that contain dependencies, that are not
> included in Jira's /WEB-INF/lib directory.
> Jira manual states that these jars should be copied to
> CATALINA_HOME/common/lib directory.
> When those files are copied to CATALINA_HOME/common/lib, Jira works fine.
>
> However, when we move those Jira dependencies from
> $CATALINA_HOME/common/lib/ to $CATALINA_BASE/shared/lib/
> Jira starup fails - it throws several ClassDefNotFoundException
> (for org.postgresql.Driver and other classes)

You are doing things not the way the manual says so. And why do you 
expect everything to work? ;-)

org.postgresql.Driver is a JDBC driver, probably application setups a 
JNDI datasource, so the driver has to be visible by the common/lib 
classloader.

-- 
Mikolaj Rydzewski <mi...@ceti.pl>


Re: Tomcat 5.5 class loader question.

Posted by David Smith <dn...@cornell.edu>.
If you setup your Postgres SQL database as a JNDI resource in the 
context xml file, Tomcat itself will need access to the driver class.  
Hence the need to place such drivers in common/lib.

--David

Borut Hadžialić wrote:

> Why would Catalina classloader need to see application specific jar 
> files?
>
> On 8/23/06, Mark Thomas <ma...@apache.org> wrote:
>
>> Borut Hadžialić wrote:
>> > However, when we move those Jira dependencies from
>> > $CATALINA_HOME/common/lib/ to $CATALINA_BASE/shared/lib/
>> > Jira starup fails - it throws several ClassDefNotFoundException
>> > (for org.postgresql.Driver and other classes)
>> >
>> > Does anyone know why is this happening?
>>
>> Probably because the Catalina classloader also needs to be able to see
>> those classes. If they are in shared, they are not visible to the core
>> Tomcat code.
>>
>> Mark
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 5.5 class loader question.

Posted by Borut Hadžialić <bo...@gmail.com>.
Why would Catalina classloader need to see application specific jar files?

On 8/23/06, Mark Thomas <ma...@apache.org> wrote:
> Borut Hadžialić wrote:
> > However, when we move those Jira dependencies from
> > $CATALINA_HOME/common/lib/ to $CATALINA_BASE/shared/lib/
> > Jira starup fails - it throws several ClassDefNotFoundException
> > (for org.postgresql.Driver and other classes)
> >
> > Does anyone know why is this happening?
>
> Probably because the Catalina classloader also needs to be able to see
> those classes. If they are in shared, they are not visible to the core
> Tomcat code.
>
> Mark

-- 
Why?
Because YES!

Re: Tomcat 5.5 class loader question.

Posted by Mark Thomas <ma...@apache.org>.
Borut Hadžialić wrote:
> However, when we move those Jira dependencies from
> $CATALINA_HOME/common/lib/ to $CATALINA_BASE/shared/lib/
> Jira starup fails - it throws several ClassDefNotFoundException
> (for org.postgresql.Driver and other classes)
> 
> Does anyone know why is this happening?

Probably because the Catalina classloader also needs to be able to see
those classes. If they are in shared, they are not visible to the core
Tomcat code.

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org