On 22/04/2019 12:32, Akram Hussain wrote: > Hi, > > So how can I access the file in shared\lib folder from tomcat\lib folder. > > I have a class in tomcat\lib which will access the class which is in > tomcat\shared folder.
If you want the classes in shared\lib to be visible to both web applications and Tomcat then perhaps the simplest solution is to add /path/to/shared/lib/*.jar to the definition of the common.loader in $CATALINA_BASE/conf/catalina.properties Mark > > Regards, > Akram. > > On Mon, Apr 22, 2019 at 4:32 PM Mark Thomas <ma...@apache.org> wrote: > >> On 22/04/2019 06:41, Akram Hussain wrote: >>> Hi Mark, >>> >>> Actually, I am declaring a Loader in tomcat\conf\context.xml file as >> >> Don't do that. >> >>> for Tomcat 7.0.68, It was working fine. >> >> <snip/> >> >>> >> ----------------------------------------------------------------------------------------------------------------------- >>> >>> After upgrade to tomcat 9.0.17. >>> >>> The start method of SharedClassLoader.java is expecting resources >> variable >>> needs to be populated. >>> >>> How can I pass the Resources to above SharedClassLoader? >> >> With difficulty and an awful lot of work. The resources implementation >> was completely re-written for Tomcat 8 onwards. >> >>> Any idea? >> >> Follow the advice in my previous mail. >> >> <snip/> >> >>> On Fri, Apr 19, 2019 at 4:09 AM Mark Thomas <ma...@apache.org> wrote: >>>> The OP is trying to load JARs so the /path/to/your/shared/libraries >>>> directory needs to be mounted at WEB-INF/lib, not WEB-INF/classes. >>>> >>>> We (OK I since I wrote this stuff) should probably have better >>>> documented which implementation to pick. >>>> >>>> You pick the implementation based on where the files you want to insert >>>> are located. >>>> >>>> If you want to insert a single file, use FileResourceSet >>>> If you want to insert a directory tree, use DirResourceSet >>>> If you want to insert files from inside an archive (JAR) then use a >>>> JarResourceSet. >>>> >>>> Note: Using a JarResourceSet effectively unpacks the archive as far as >>>> Tomcat is concerned so Tomcat sees directories and files, not a single >>>> JAR file. >>>> >>>> In this case you have a directory of JAR files so you want a >>>> DirResourceSet. >>>> >>>> Assuming you want those JAR files to be treated as if they were placed >>>> in WEB-INF/lib then you want: >>>> >>>> <Resources> >>>> <PostResources >>>> webAppMount="/WEB-INF/lib" >>>> base="/path/to/your/shared/libraries" >>>> className="org.apache.catalina.webresources.DirResourceSet" >>>> /> >>>> </Resources> >>>> >>>> That has the same effect as copying the entire contents of >>>> /path/to/your/shared/libraries to WEB-INF/lib. >>>> >>>> If you want this to apply to every web application you deploy then add >>>> the above to global context.xml in CATALINA_BASE/conf/context.xml >> >> Mark >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org