-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Xavier,
On 1/30/20 5:00 AM, Xavier (Apache) wrote: > >> On 30 Jan 2020, at 00:09, Christopher Schultz >> <ch...@christopherschultz.net> wrote: >> > Xavier, > > On 1/29/20 3:23 PM, Xavier (Apache) wrote: >>>> Hello Tomcat list, >>>> >>>> I’m struggling with a classpath problem. I have a webapp >>>> deployed under Tomcat. I have setup multiple tests (3 to be >>>> exact). They are all running 9.0.20, one under macOS, and the >>>> other 2 under Debian (same version for both). My app requires >>>> the jar lib to be loaded in a specific order. What I was able >>>> to gather so far is that I should do that customisation in >>>> myapp/WEB-INF/context.xml (it looks like I don’t need to tell >>>> Tomcat to look for that file) >>>> >>>> I’m looking for some sample code to better understand how to >>>> do it. >>>> >>>> So far I tried >>>> >>>> <?xml version="1.0" encoding="UTF-8"?> <Context >>>> docBase="\webapps\CloudManager"> <Loader >>>> className="org.apache.catalina.loader.VirtualWebappLoader"/> >>>> <lib>xxxxxx</lib> <lib>yyyyyy</lib> ... </Context> >>>> >>>> xxxxxx and yyyyyy are jar files in >>>> myapp/WEB-INF/lib/xxxxxx.jar >>>> >>>> but without any luck. >>>> >>>> I’m probably missing something obvious, but I just can’t find >>>> it. > > Tomcat has no facility to force the loading of specific JARs in a > specific order. There has been no consensus that e.g. "alphabetic" > ordering should be enforced. There is no (servlet) spec-defined > order, either. > > If you have some special libraries that must be loaded before > others (rather than a complete and total ordering), you can use > the <PreResources>[1] facility to establish a directory where some > libraries are loaded first. I suppose you could use many > PreResources, in order, to achieve a total ordering, but it will be > a lot of typing. > > The VirtualWebappLoader has been deprecated for a long time. I > can't even find the class in any currently-supported branch of > Tomcat. > > -chris > > [1] > http://tomcat.apache.org/tomcat-9.0-doc/config/resources.html#Nested_C om > <http://tomcat.apache.org/tomcat-9.0-doc/config/resources.html#Nested_ Com> > > ponents >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org <mailto:users-unsubscr...@tomcat.apache.org> >> For additional commands, e-mail: users-h...@tomcat.apache.org >> <mailto:users-h...@tomcat.apache.org> > > Thanks for the pointers Christopher. > > Here’s what I have so far, but I don’t understand why it doesn’t > work (I get a java.lang.ClassNotFoundException for a class that is > in the prelib jars) > > -I added a directory mywebapp/WEB-INF/prelib with all the jars that > should be loaded first (the ones that should be loaded after are in > the usual mywebapp/WEB-INF/lib directory) > -mywebapp/WEB-INF/context.xml contains > > <?xml version="1.0" encoding="UTF-8"?> <Context> <Resources> > <PreResources > className="org.apache.catalina.webresources.DirResourceSet" > base=“/WEB-INF/prelib" webAppMount="/WEB-INF/lib" /> The "base" needs to be a fully-qualified path. I assume you haven't placed your files in /WEB-INF/prelib, but instead have them in "/home/tomcat/webapps/yourwebapp/WEB-INF/prelib" or something similar. It is not relative to the web application's "root". This also means that it can't be loaded from within a WAR file. There are other ResourceSet implementations that *may* work for reading files our of a WAR file. - -chris -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl40dGsACgkQHPApP6U8 pFhxVQ/9ELtLXAxRXjwOqLkWOQPhzkju/2wWzo/Fg0YYZLEP6uqOMlIZ5Wx4m7qz lcNS3YmY7BTXaT+r7F0G3eEVkxTaQA31FHJuNUwFQxlLduIPLbm/oAlbjUeOp+Iy HRpCGZyT8Ya1l6LXEA7926x1PyvadNcSS0TsnYp8aTPlPc5vF4yQbBLAjSquMPix +w2rH2Br9wf+F1/jsBDUWYbDW57DQ1qdC+kexKVcYOJaVIMopR8MLkEHVnN0grSp Pn0LprTy50Woiw1QYIQEF98e3mP4JOS0yrR2EfaBL+LNTzR6P0/YvTRylegDzlwm 4LMON1XO3ZjEkXWat7XVnD+F500chgwWc3VNrSrfbDpJ0n4oyyaUhhgit3pPISQ3 EYzB52oODJhqtZsHgjQqwQ9Cau9uyyGp7MYe76j2ZMmTsCDqM1O24ydVaTXDY0r0 IrFxBuwY9H9UIVPbMGNh67+pY8jWZ6ylqcHX0cgmAGKrjuweaQCJNC2QsEnys48l e3b8FeI8mWqMSsVzDqcJb3UTB29iPLgWdHxs9MOckG9udC4vb+EwmmCNH9FVLQjg Sb04wMmF/tNFlT0TsYjpgAPVHTp5uqXSMBRiKKsTD/US7m2N49qmFEcm48gbPaSi hdQYVagy3SupzfU5KGay8HvDEdZooiUYcgVC+pHsfQwofr4o1Jo= =SmRx -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org