Perhaps this info will help: - Custom class loaders are supposed to be possible but very poorly documented. I was never able to make them work properly. You might have some luck if you study the source code of Tomcat itself, as it does implement them.
- Webapps really expect all custom library jars to be loaded from web-inf/lib. - up to Java 8 you could write code to dynamically add to the class path. I used to use that ability extensively, even though I was not really using a custom classloader. Starting in Java 9 they broke that capability. - In tomcat/conf/catalina.prooerties you can add jars and folders to the common class path. It is discouraged but it might get you out of trouble in a pinch. Get Outlook for Android<https://aka.ms/AAb9ysg> ________________________________ From: Mark Thomas <ma...@apache.org> Sent: Monday, April 17, 2023 5:13:44 AM To: users@tomcat.apache.org <users@tomcat.apache.org> Subject: Re: How to have a custom classloader outside Tomcat's own lib-dir? On 16/04/2023 12: 36, Thorsten Schöning wrote: > Hi everyone, > > I have some app consisting of a directory layout with some bundled > Tomcat, containing at least one exploded webapp. For various reasons, What are those reasons? ZjQcmQRYFpfptBannerStart CAUTION: This Message Is From an External Source This message originated outside the Chickasaw Nation. Do not click links or open attachments unless you recognize the sender and know the content is safe! <https://us-phishalarm-ewt.proofpoint.com/EWT/v1/IMeFMrRG1GeY!JdtefBv6lkGaCCOnym3mtjzgmrjMjSYDB5WKcB11z7TBBrnWuL4Jtfa62KewlWqxRNdE_fW-DtvIVBInDg5L3XkWe9I8yWgbNjAAnqx-$> Report Suspicious ZjQcmQRYFpfptBannerEnd On 16/04/2023 12:36, Thorsten Schöning wrote: > Hi everyone, > > I have some app consisting of a directory layout with some bundled > Tomcat, containing at least one exploded webapp. For various reasons, What are those reasons? I'm wondering if the reasons have any impact on the answer. > that webbapp needs its own classloader, which is currently configured > in context.xml of Tomcat and stored in its own lib-dir. I don't like > putting custom JARs into the default deployment of Tomcat too much. > >> <!-- use own classloader, reading classpath file --> >> <Loader loaderClass="[...]" delegate="true"/> > > So, is there some way to put the JAR elsewhere? Yes, as long as you tell Tomcat where to find it. > Whatever I tested didn't work, e.g. adding the JAR to "common.loader". That should have worked and is the approach I'd recommend. Exactly what did you change when you tried this? > But I must admit that I didn't fully understand if common.loader is > used to load the custom loader at all or only afterwards and stuff. > > Or is there some way to not use Tomcat's "Loader" above and only > maintain a custom, webapp-specific classloader in the one webapp > needing it? No. Tomcat needs to be able to load the custom class loader in order to configure it. Mark > > I've searched for somethign like "setClassLoader" and found it for > some servlet containers, but it doesn't seem to be standard and > supported by Tomcat. > > Thanks for your input! > > Mit freundlichen Grüßen > > Thorsten Schöning > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org