Erwan, On 9/19/16 11:36 AM, Erwan Cancouet wrote: > Hi, > > i'm using Tomcat 7.0.70 on ubuntu 15.10. > > I have created a SampleClassLoader : > > package com.axway.tnt.compliance; > > import org.apache.catalina.loader.WebappClassLoader; > > import java.io.File; import java.io.IOException; > > public class SampleClassLoader extends WebappClassLoader { public > SampleClassLoader() { super(); } > > public SampleClassLoader(final ClassLoader parent) { > super(parent); } > > @Override protected boolean validateJarFile(final File file) throws > IOException { System.out.println("-----------Load: " + > file.getName()); return super.validateJarFile(file); } } > > I have put it in a jar in ../apache-tomcat/lib > > I have a webapp : apache-tomcat/lwebapps/sample > > I have modified apache-tomcat/lwebapps/sample/meta-inf/context.xml > to use this classloader : > > > <Context> > > <!-- Default set of monitored resources --> > <WatchedResource>WEB-INF/web.xml</WatchedResource> > > <!-- Fix Tomcat startup issue due to noteable change. In 7.0.51 > onwards, the web application class loader is now a higher priority > for loading classes than the system class loader. With this > attribute set to true, the class loader follow the standard Java2 > delegation model, and attempt to load classes from parent class > loaders before looking inside the web application. --> <Loader > delegate="true" > loaderClass="com.axway.tnt.compliance.SampleClassLoader"/> > > </Context> > > > And it's working fine. > > But i don't want to modify my tomcat, i want to put my classloader > in my webapp/lib and in this case i have : > > > java.lang.ClassNotFoundException: > com.axway.tnt.compliance.SampleClassLoader at > java.net.URLClassLoader.findClass(URLClassLoader.java:381) at > java.lang.ClassLoader.loadClass(ClassLoader.java:424) at > java.lang.ClassLoader.loadClass(ClassLoader.java:357) at > org.apache.catalina.loader.WebappLoader.createClassLoader(WebappLoader .java:723) > > at org.apache.catalina.loader.WebappLoader.startInternal(WebappLoader.java: 582) > Caused by: org.apache.catalina.LifecycleException: Failed to start > component [WebappLoader[/sample]] at > org.apache.catalina.loader.WebappLoader.startInternal(WebappLoader.jav a:632) > > Caused by: java.lang.ClassNotFoundException: com.axway.tnt.compliance.SampleClassLoader > at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at > java.lang.ClassLoader.loadClass(ClassLoader.java:424) at > java.lang.ClassLoader.loadClass(ClassLoader.java:357) at > org.apache.catalina.loader.WebappLoader.createClassLoader(WebappLoader .java:723) > > at org.apache.catalina.loader.WebappLoader.startInternal(WebappLoader.java: 582) > > > Any idea to do that ?
Sorry, this is not possible, because otherwise your SampleClassLoader would have to load itself. You will have to package your custom ClassLoader and install it into Tomcat's lib/ directory. - -chris Hi, thanks for the response even if it is'nt the one i was expected :-). Erwan