-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Akram,

On 4/16/19 16:21, Akram Hussain wrote:
> Hi Christopher,
> 
> I have almost 27-30 apps in my tomcat.
> 
> Do I need to declare in every applications's META-INF\context.xml.

Yes. If every application needs those libraries, then you'll need to
configure them. Just like you had to configure your custom class
loader for each application in the past.

Why not simply put the JAR files into the applications as usual? Then
each web application is self-contained and you don't have to go
through all these back-flips.

> And also I have a listener class which is in tomcat\lib folder,
> which also access these shared classes using CustomSharedLibrary.

Then you can put all the libraries into Tomcat's lib/ directory and
you don't have to do any of this.

> How can I access those shared libraries in listener which is in
> tomcat\lib folder?

What does your Listener do? You might not even need it...

- -chris

> On Wed, Apr 17, 2019 at 1:02 AM Christopher Schultz < 
> ch...@christopherschultz.net> wrote:
> 
> Akram,
> 
> On 4/16/19 12:41, Akram Hussain wrote:
>>>> I have gone through it, But it was not clear to me.
>>>> 
>>>> If an example is provided, how to pass resources to 
>>>> SharedClassLoader, it could be helpful.
> 
> If you configure something like this in your META-INF/context.xml:
> 
> <Resources> <PostResources webAppMount="/WEB-INF/classes" 
> base="/path/to/your/shared/libraries" 
> className="org.apache.catalina.webresources.DirResourceSet" /> 
> </Resources>
> 
> That should allow your application to load JAR files from your 
> /path/to/your/shared/libraries directory.
> 
> You should completely remove your custom class loader. Completely.
> 
> -chris
> 
>>>> On Tue, Apr 16, 2019 at 7:57 PM Christopher Schultz < 
>>>> ch...@christopherschultz.net> wrote:
>>>> 
>>>> Akram,
>>>> 
>>>> On 4/16/19 06:29, Akram Hussain wrote:
>>>>>>> I have Custom SharedClassLoader in Tomcat 7 to load
>>>>>>> shared library jars, which is used by different
>>>>>>> applications in that tomcat. We migrated to Tomcat 9,
>>>>>>> now it is not working. How to achieve the same
>>>>>>> functionality in tomcat 9.
>>>> 
>>>> Have a look at the <Resources> which should be able to do
>>>> what you need without any custom code:
>>>> 
>>>> http://tomcat.apache.org/tomcat-9.0-doc/config/resources.html
>>>>
>>>>>>>
>>>> 
In Tomcat 9 it expects resources to be passed. I don't find
>>>>>>> any sample Code on how to populate resources.
>>>>>>> 
>>>>>>> I tried like below
>>>>>>> 
>>>>>>> public CustomSharedClassLoader(ClassLoader parent)
>>>>>>> throws Exception { super(parent); //The below three
>>>>>>> lines are added by me to work for Tomcat 9.
>>>>>>> StandardRoot standardRoot = new StandardRoot();
>>>>>>> standardRoot.addPreResources(new DirResourceSet());
>>>>>>> setResources(standardRoot);// End for tomcat 9
>>>>>>> changes.
>>>>>>> 
>>>>>>> for (URL urlForJars : getClassPath(SHARED_LIB)) { 
>>>>>>> addURL(urlForJars); } start(); }
>>>>>>> 
>>>>>>> It didn't work.
>>>>>>> 
>>>>>>> public class CustomSharedClassLoader extends 
>>>>>>> WebappClassLoader{//Which takes shared folder libarary,
>>>>>>> it returns those classes.}
>>>> 
>>>> You should be able to ditch your custom ClassLoader
>>>> entirely.
>>>> 
>>>> -chris
>>>>> 
>>>>> ------------------------------------------------------------------
- ---
>>>>>
>>>>>
>
>>>>> 
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>>>> For additional commands, e-mail:
>>>>> users-h...@tomcat.apache.org
>>>>> 
>>>>> 
>>>> 
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>> 
>> 
> 
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAly2RzgACgkQHPApP6U8
pFilIA/+NvG9+sG1tPbWyAXvy9bwGnRATgTZqxGGWvGZ2XL2Knkt+lPaoh7Vtum9
jYm4ZUIWNrkg4APxCwHXnfNlkLEF36igANlytDlBBUoVKBqEgngWUqR2w19yeRma
8GS7YbDS6bUJ/KQTBEkeTeyf7EdLHVfJwrnKZ6qxV2QmC+IBwCr7I2vlWwx59qac
CqCL97FzRjtwDa6sHsC5PYsdu0fy8z4NzI4Ro4bcKNjDnvsQ0LSaKR0WM6OlaHAW
wFayoV/oUK8uRbDrS3q4pOtAnLxwF+CVrk0x7clpyPnqlSO0TIebZ+ejOEe4lsHK
gC33pK+vpKtl3d68WNf4aZfjXdrqsnF0IvnPPayAThVysHHOfJqGyYL2wdtmFru9
vOKKIPqM4TT6V0BWZiX4lrE/kbF8c4KhpdtdIkFyf8KqWtezYBZIjIlEEaoiqlSO
KWdnrxRQ3Y2gJMUBAUDK0CiEl8Rw/L030CUmeLabNvN8MORpva2GOIGUk2wUVRwB
gSWShGDgaUC1KsdEPNf8Sawb9J1yVOAxdQH2U05Z0cf2gMcmHVgrJQ0+mSZMvvhJ
CiEumW37P4Z0jkcKyeISrE0T7p90rvaXQLrwSNIqTuzDKQXhmUXWUofktdH51541
WQvgsg15JV3OH13xtjftrQDLZwZ8HYrn47kpTlOXrpfM0ITzvuM=
=N2Dl
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to