You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Honza Spurný <sp...@master.cz> on 2004/05/03 10:26:18 UTC

Setting classpath out of the webapp directory

Hi there,

I'have been trying to set the classpath of the webapp out of the directory
of this webapp. This is for me little important, since some classes I'd like
to use (I have to use) in other webapps. I want to have only one file of
this class -- I don't want to copy classes between the webapps.

I'm sure it is possible to do it, as I need it, but I don't know how. Would
be anybody so kind and help me with this?

I would also like to "export" the lib directory of webapp out of the webapp
directory so that the shared libaries could be presented as file only once.
This is probably the same problem as above.

Could anybody help me? Thanks a lot.

Best Regards.
Honza Spurny


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Setting classpath out of the webapp directory

Posted by Honza Spurný <sp...@master.cz>.
I've done:

- in the common directory I've created "src" directory
- into the src dir I've copied all shared java-sourced classes
- i've compiled them into the common/classes directory
- i've copied some shared libaries into the common/lib
- i've removed whole directory webapps/MyApp/WEB-INF/classes/ (classes
direcotry is still presented, but it is almost empty -- except the
messageResources files -- these were leaved in the original space)
- i've restarted tomcat

Now no error occures. But after I want to connect to the webapp, that has
some classes in the common/classes directory, the blank page in the browser
occures and on the tomcat-terminal is written: java.lang.ClassCastException.
This means, as I know, that tomcat can find this classes in the
common/classes directory. :(

Does anybody know, what I should set in the tomcat variables to let tomcat
could search the common/classes directory for classes?

Thanks a lot for help
Honza S.

Eric Noel wrote:
> On 5/3/2004 4:26 PM, Honza Spurný wrote:
>
>> Hi there,
>>
>> I'have been trying to set the classpath of the webapp out of the
>> directory of this webapp. This is for me little important, since
>> some classes I'd like to use (I have to use) in other webapps. I
>> want to have only one file of this class -- I don't want to copy
>> classes between the webapps.
>>
>> I'm sure it is possible to do it, as I need it, but I don't know
>> how. Would be anybody so kind and help me with this?
>>
>> I would also like to "export" the lib directory of webapp out of the
>> webapp directory so that the shared libaries could be presented as
>> file only once. This is probably the same problem as above.
>>
>> Could anybody help me? Thanks a lot.
>>
>> Best Regards.
>> Honza Spurny
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
>
> $CATALINA_HOME/common/lib - jars
> $CATALINA_HOME/common/classes - classes
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Setting classpath out of the webapp directory

Posted by Honza Spurný <sp...@master.cz>.
Eric Noel wrote:
> On 5/3/2004 4:26 PM, Honza Spurný wrote:
>
>> Hi there,
>>
>> I'have been trying to set the classpath of the webapp out of the
>> directory of this webapp. This is for me little important, since
>> some classes I'd like to use (I have to use) in other webapps. I
>> want to have only one file of this class -- I don't want to copy
>> classes between the webapps.
>>
>> I'm sure it is possible to do it, as I need it, but I don't know
>> how. Would be anybody so kind and help me with this?
>>
>> I would also like to "export" the lib directory of webapp out of the
>> webapp directory so that the shared libaries could be presented as
>> file only once. This is probably the same problem as above.
>>
>> Could anybody help me? Thanks a lot.
>>
>> Best Regards.
>> Honza Spurny
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
>
> $CATALINA_HOME/common/lib - jars
> $CATALINA_HOME/common/classes - classes
>

After I did so, tomcat stops to work at all. Should I set some settings in
tomcat or what is wrong, does anybody know about it. The error that occures
is "java.lnag.NoSuchMethodException:
org.apache.catalina.startup.Catalina.setAwait(boolean).

Only things I did are:
- in the common directory I've created "src" directory
- into the src dir I've copied all shared java-sourced classes
- i've compiled them into the common/classes directory
- i've copied some shared libaries into the common/lib
- i've removed whole directory webapps/MyApp/WEB-INF/classes/ (classes
direcotry is still presented, but it is almost empty -- except the
messageResources files -- these were leaved in the original space)
- i've restarted tomcat
- errors occures

Please can anybody help.

Thanks a lot
Best Regards
Honza S.

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Setting classpath out of the webapp directory

Posted by Eric Noel <er...@mylife.ph>.
On 5/3/2004 4:26 PM, Honza Spurný wrote:

> Hi there,
> 
> I'have been trying to set the classpath of the webapp out of the directory
> of this webapp. This is for me little important, since some classes I'd like
> to use (I have to use) in other webapps. I want to have only one file of
> this class -- I don't want to copy classes between the webapps.
> 
> I'm sure it is possible to do it, as I need it, but I don't know how. Would
> be anybody so kind and help me with this?
> 
> I would also like to "export" the lib directory of webapp out of the webapp
> directory so that the shared libaries could be presented as file only once.
> This is probably the same problem as above.
> 
> Could anybody help me? Thanks a lot.
> 
> Best Regards.
> Honza Spurny
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 

$CATALINA_HOME/common/lib - jars
$CATALINA_HOME/common/classes - classes

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Setting classpath out of the webapp directory

Posted by Tim Funk <fu...@joedog.org>.
Place your classes in common/lib or shared/lib

But you need to be careful. The common/lib and shared/lib classloaders cannot 
see the WEB-INF classloader - which means that you can easily get the no 
class found errors.

Multiple copies of JAR files in each classloader is OK. You can do that via 
symlinks or better - make the copy of the libraries (or classes) as part of 
you ant build script. If its part of your ant build script - there is not 
extra work to do.


http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html

-Tim

Honza Spurný wrote:
> Hi there,
> 
> I'have been trying to set the classpath of the webapp out of the directory
> of this webapp. This is for me little important, since some classes I'd like
> to use (I have to use) in other webapps. I want to have only one file of
> this class -- I don't want to copy classes between the webapps.
> 
> I'm sure it is possible to do it, as I need it, but I don't know how. Would
> be anybody so kind and help me with this?
> 
> I would also like to "export" the lib directory of webapp out of the webapp
> directory so that the shared libaries could be presented as file only once.
> This is probably the same problem as above.
> 
> Could anybody help me? Thanks a lot.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Setting classpath out of the webapp directory

Posted by Chris Wahl <po...@SoftHome.net>.
it's easy :)
put your classes or jars to be *shared by your webapps* into 
the directory ---%TOMCAT_HOME%\shared\classes or 
%TOMCAT_HOME%\shared\lib

Regards,
Potomac


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Setting classpath out of the webapp directory

Posted by Mazin Safadi <ms...@massar.com>.
I know with Tomcat if you have shared classes, you can put them in the
shared lib dir under tomcat.
 
Your application classes >> %catalina_home%/webapps/root/WEB-INF/lib
Shared classes	>> %catalina_home%/lib




-----Original Message-----
From: Honza Spurn‎ [mailto:spurny@master.cz] 
Sent: Monday, May 03, 2004 10:26
To: Tomcat Maillisting
Subject: Setting classpath out of the webapp directory

Hi there,

I'have been trying to set the classpath of the webapp out of the
directory
of this webapp. This is for me little important, since some classes I'd
like
to use (I have to use) in other webapps. I want to have only one file of
this class -- I don't want to copy classes between the webapps.

I'm sure it is possible to do it, as I need it, but I don't know how.
Would
be anybody so kind and help me with this?

I would also like to "export" the lib directory of webapp out of the
webapp
directory so that the shared libaries could be presented as file only
once.
This is probably the same problem as above.

Could anybody help me? Thanks a lot.

Best Regards.
Honza Spurny


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org