You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Pat McGroin <ba...@go.com> on 2003/03/27 20:20:49 UTC
shared resources
Hello.
I am trying to reference a few JAR files from an out-of-process Tomcat 4.1.18 application.
The Tomcat 4.1 documentation says that unpacked shared classes and resources will be loaded out of the <tomcat_root>/shared/classes directory and packed shared resources are loaded out of <tomcat_root>/shared/lib:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html
I put a few JAR files in <tomcat_root>/shared/lib but they are never loaded.
I can move them into my <webapp root>/WEB-INF/lib and they are loaded without problems.
Am I misunderstanding how resources are found in Tomcat 4.1?
The context I am using is not within <tomcat_home>/webapps. It is in an entirely diferent directory. Could that be the problem?
I posted a simliar question a few days ago but was not yet properly subscribed so I apologize for the duplication.
Thanks in advance for any help!
___________________________________________________
GO.com Mail
Get Your Free, Private E-mail at http://mail.go.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: shared resources
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Thu, 27 Mar 2003, Pat McGroin wrote:
> Date: Thu, 27 Mar 2003 11:20:49 -0800 (PST)
> From: Pat McGroin <ba...@go.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: shared resources
>
> Hello.
>
> I am trying to reference a few JAR files from an out-of-process Tomcat
> 4.1.18 application.
>
> The Tomcat 4.1 documentation says that unpacked shared classes and
> resources will be loaded out of the <tomcat_root>/shared/classes
> directory and packed shared resources are loaded out of
> <tomcat_root>/shared/lib:
>
> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html
>
> I put a few JAR files in <tomcat_root>/shared/lib but they are never
> loaded. I can move them into my <webapp root>/WEB-INF/lib and they are
> loaded without problems.
>
> Am I misunderstanding how resources are found in Tomcat 4.1? The
> context I am using is not within <tomcat_home>/webapps. It is in an
> entirely diferent directory. Could that be the problem?
>
> I posted a simliar question a few days ago but was not yet properly
> subscribed so I apologize for the duplication.
>
> Thanks in advance for any help!
>
When accessing resources with getResource()/getResourceAsStream(), it is
important to remember that there are two different implementations of
these things, which operate quite differently:
ServletContext.getResource() and ServletContext.getResourceAsStream():
* Can be used to access static resources within your web application
* Resources is specified as a context-relative URI starting with "/"
* For example, to read the web.xml file as a resource, you would use
a resource path of "/WEB-INF/web.xml"
* It doesn't matter whether your webapp is running from an unpacked
directory or a WAR file, or where the directory/WAR is actually
located.
ClassLoader.getResource() and ClassLoader.getResourceAsStream():
* Can be used to access resources embedded within the class loader
(or class loader hierarchy)
* For a standalone app, that means somewhere on your classpath
* For a webapp installed in Tomcat 4.1, and assuming you're starting
with the webapp class loader, it checks there and up the hierarchy
as described in the Tomcat documentation.
* Resource path must match the directory or package structure of
the resource to be retrieved.
* Resource resolution works just like class loading resolution in
terms of which class loader is searched first.
To access a resource from a JAR file in shared/lib, then, you will want to
make sure you're using the second kind of resource retrieval methods.
After getting the right methods called, the next most common problem is
getting your resource path to match the nested directory structure within
whatever JAR file is holding the resource.
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org