You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Xavier (Apache)" <ap...@anazys.com> on 2020/01/29 20:23:50 UTC
[Classpath] - Ordering issue
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.
Thanks for your help,
Xavier
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [Classpath] - Ordering issue
Posted by "Xavier (Apache)" <ap...@anazys.com>.
> On 30 Jan 2020, at 11:00, Xavier (Apache) <ap...@anazys.com> wrote:
>
>>
>> On 30 Jan 2020, at 00:09, Christopher Schultz <chris@christopherschultz.net <ma...@christopherschultz.net>> wrote:
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>> 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_Com <http://tomcat.apache.org/tomcat-9.0-doc/config/resources.html#Nested_Com> <http://tomcat.apache.org/tomcat-9.0-doc/config/resources.html#Nested_Com <http://tomcat.apache.org/tomcat-9.0-doc/config/resources.html#Nested_Com>>
>> ponents
>> -----BEGIN PGP SIGNATURE-----
>> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ <https://www.enigmail.net/> <https://www.enigmail.net/ <https://www.enigmail.net/>>
>>
>> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4yEJMACgkQHPApP6U8
>> pFiUiw//ae5zTje1y7YE0wTnBxIVwlM7mz2KaGsZnONEUUMtGsscx7hfgHHIcs+j
>> R6mHSmeoH2YKlvG3qarcCvb0UpNXGjfORslbPcj1U4GQzUcftatcFPLGMejlWVBy
>> xFUcpmGe52zJ4NUWt0zW+3Bq8HfuD2eBJ+eUky9jQ5qS3sOFjrjafiWx2ftjvikd
>> E1qv1haoCq2Y9UwHq4K2gFoS8OTWvs3AHxZyrRYPoyKyQvSg3FTkNvy1DiNEeAqg
>> E6ZDl3FWryur/2PtOV4LhbRE/0UoifCIchrRomHxnbep4cqDx+DivLPgsG8ms4Iv
>> XQJiuWD3lWD3/GHm5ymEMgRNssZsO8EEIwoYkSk0ZueX4TaTWyYO4KEY4YHlukXt
>> igaGjZCcKUVfEJnS8ZcWOhViwn8qNbZHTHi12m/3w/So+TBvbYilcvgGSNf1B6LT
>> yqmPFccFuKYSGeiGhUxo0z0nYTbgXgR07Dwj82DzFmd0pOd8a+KLoYavLaWXnE2u
>> 6oNWTtzXGfNjH0P0s4qqv0vSySxZZ/iP6NNIM0C2uJV4XtSeJGWCQ5R7ozAaNG9U
>> 77VYBojXk/8LmO+asEeqFqex+vZAkVA/wpW1RW47NfgLhtnWY4LE3xeDuKLeclnM
>> EBwyA3DObWdRiqzXv+ydlF9fliQFVEgxD3EaO//vk32Uif0Zbeo=
>> =2Y4Q
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org <ma...@tomcat.apache.org> <mailto:users-unsubscribe@tomcat.apache.org <ma...@tomcat.apache.org>>
>> For additional commands, e-mail: users-help@tomcat.apache.org <ma...@tomcat.apache.org> <mailto:users-help@tomcat.apache.org <ma...@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" />
> </Resources>
> </Context>
> -I also tried with an absolute path for “base” without success (also I’d really need a path relative to the webapp or at least the Tomcat installation, is base=$CATALINA_BASE/webapps/mywebapp/WEB-INF/prelib” correct?)
>
> Any idea about what I’m doing wrong?
>
> Thanks a lot,
>
> Xavier
I’m still struggling with this context.xml file.
So far, it doesn’t load what is in the “prelib” folder, even if I put an absolute path.
Anyone with a working sample? (ideally with a path relative to either Tomcat or the webapp)
Thanks,
Xavier
Re: [Classpath] - Ordering issue
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----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-unsubscribe@tomcat.apache.org
<ma...@tomcat.apache.org>
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> <ma...@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [Classpath] - Ordering issue
Posted by "Xavier (Apache)" <ap...@anazys.com>.
> On 30 Jan 2020, at 00:09, Christopher Schultz <ch...@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> 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_Com <http://tomcat.apache.org/tomcat-9.0-doc/config/resources.html#Nested_Com>
> ponents
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ <https://www.enigmail.net/>
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4yEJMACgkQHPApP6U8
> pFiUiw//ae5zTje1y7YE0wTnBxIVwlM7mz2KaGsZnONEUUMtGsscx7hfgHHIcs+j
> R6mHSmeoH2YKlvG3qarcCvb0UpNXGjfORslbPcj1U4GQzUcftatcFPLGMejlWVBy
> xFUcpmGe52zJ4NUWt0zW+3Bq8HfuD2eBJ+eUky9jQ5qS3sOFjrjafiWx2ftjvikd
> E1qv1haoCq2Y9UwHq4K2gFoS8OTWvs3AHxZyrRYPoyKyQvSg3FTkNvy1DiNEeAqg
> E6ZDl3FWryur/2PtOV4LhbRE/0UoifCIchrRomHxnbep4cqDx+DivLPgsG8ms4Iv
> XQJiuWD3lWD3/GHm5ymEMgRNssZsO8EEIwoYkSk0ZueX4TaTWyYO4KEY4YHlukXt
> igaGjZCcKUVfEJnS8ZcWOhViwn8qNbZHTHi12m/3w/So+TBvbYilcvgGSNf1B6LT
> yqmPFccFuKYSGeiGhUxo0z0nYTbgXgR07Dwj82DzFmd0pOd8a+KLoYavLaWXnE2u
> 6oNWTtzXGfNjH0P0s4qqv0vSySxZZ/iP6NNIM0C2uJV4XtSeJGWCQ5R7ozAaNG9U
> 77VYBojXk/8LmO+asEeqFqex+vZAkVA/wpW1RW47NfgLhtnWY4LE3xeDuKLeclnM
> EBwyA3DObWdRiqzXv+ydlF9fliQFVEgxD3EaO//vk32Uif0Zbeo=
> =2Y4Q
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org <ma...@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org <ma...@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" />
</Resources>
</Context>
-I also tried with an absolute path for “base” without success (also I’d really need a path relative to the webapp or at least the Tomcat installation, is base=$CATALINA_BASE/webapps/mywebapp/WEB-INF/prelib” correct?)
Any idea about what I’m doing wrong?
Thanks a lot,
Xavier
Re: [Classpath] - Ordering issue
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
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_Com
ponents
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl4yEJMACgkQHPApP6U8
pFiUiw//ae5zTje1y7YE0wTnBxIVwlM7mz2KaGsZnONEUUMtGsscx7hfgHHIcs+j
R6mHSmeoH2YKlvG3qarcCvb0UpNXGjfORslbPcj1U4GQzUcftatcFPLGMejlWVBy
xFUcpmGe52zJ4NUWt0zW+3Bq8HfuD2eBJ+eUky9jQ5qS3sOFjrjafiWx2ftjvikd
E1qv1haoCq2Y9UwHq4K2gFoS8OTWvs3AHxZyrRYPoyKyQvSg3FTkNvy1DiNEeAqg
E6ZDl3FWryur/2PtOV4LhbRE/0UoifCIchrRomHxnbep4cqDx+DivLPgsG8ms4Iv
XQJiuWD3lWD3/GHm5ymEMgRNssZsO8EEIwoYkSk0ZueX4TaTWyYO4KEY4YHlukXt
igaGjZCcKUVfEJnS8ZcWOhViwn8qNbZHTHi12m/3w/So+TBvbYilcvgGSNf1B6LT
yqmPFccFuKYSGeiGhUxo0z0nYTbgXgR07Dwj82DzFmd0pOd8a+KLoYavLaWXnE2u
6oNWTtzXGfNjH0P0s4qqv0vSySxZZ/iP6NNIM0C2uJV4XtSeJGWCQ5R7ozAaNG9U
77VYBojXk/8LmO+asEeqFqex+vZAkVA/wpW1RW47NfgLhtnWY4LE3xeDuKLeclnM
EBwyA3DObWdRiqzXv+ydlF9fliQFVEgxD3EaO//vk32Uif0Zbeo=
=2Y4Q
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org