-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 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 -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJX4EzJAAoJEBzwKT+lPKRYvpEQAMf4y//nZFE+kresOJcdLLnR Twf4f+rRte9ZKyhSOcY+1Wl+LyzIJnyyiuNQSjBHJtDV32i7D57L/bDsfFB7+fAN 1wkaYGMLAD3LdmReD8j7xgh8iejOGewGO8rN4g1RlSo7JBU3UaqFzJCiURi97980 N7ZAwB0CtOAfo4ag/qWTUVoyynfenfMBbYoOcK5zyv7KgeGSnmJJ1Tl4Kpx3GmQq yoFwyNfiadL0T5TC5+0Aw0PbrRsLXdqwyh6oYGjSTVah3sx+kO5BsNFBlTRQsi9b 7iNVXmWDRPDbLU7uLJj/bqKwpWwncep0eUaneUP2cTOctGAtXNKap36S2e1a8gEx i3hKB1kIAo3kv/sOlkpAOGOv1eTNMvO10lqVxy6GFd4BaD+py/1LpH/5IFS8QzPz YHE6/h/29fZzSvLE/6rj5+TUTa8eC29baiIrmR62CTyrijWxiQ7k8MummpLb7X+O eGPbiKk3+TlEZQn7nGAKt2OrIEywfXMMuDlZro9zRtGqaAIRakHSpn02vQhfBdxi FVgMRakHqbKa7gKNVeUfda/bibAFb5irSntIMROzwsDVgR8UYeoZ+vh2CFho5/8M x8DfeWrtX3aeFa7NzGT26O1FD4zDBOxF9Dagsb1BjFnh3RTZu7f8P5aG8vaRQY9r lJNV48fNdVnUXP4iG+ve =2y4c -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org