You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Akram Hussain <ak...@gmail.com> on 2019/04/16 10:29:01 UTC

Upgrade from Tomcat 7 to Tomcat 9.0.17

Hi,

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.

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.}


Regards,

Akram.

Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Akram Hussain <ak...@gmail.com>.
Hi  Luis,

But a Listener, which is defined in tomcat\lib, cannot access the
shared\lib folder files.

Regards,
Akram.

On Wed, Apr 17, 2019 at 12:43 PM Luis Rodríguez Fernández <uo...@gmail.com>
wrote:

> Hello Akram,
>
> If you can not put the jars inside each webapp perhaps you could define a
> shared.loader in your catalina.properties [1]. It works for us.
>
> Hope it helps,
>
> Luis
>
> [1]
>
> https://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html#Advanced_configuration
>
>
>
>
>
>
>
> El mar., 16 abr. 2019 a las 23:21, Christopher Schultz (<
> chris@christopherschultz.net>) escribió:
>
> > -----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 <
> > > chris@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 <
> > >>>> chris@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-unsubscribe@tomcat.apache.org
> > >>>>> For additional commands, e-mail:
> > >>>>> users-help@tomcat.apache.org
> > >>>>>
> > >>>>>
> > >>>>
> > >>
> > >> ---------------------------------------------------------------------
> > >>
> > >>
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > >> For additional commands, e-mail: users-help@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-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
> --
>
> "Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."
>
> - Samuel Beckett
>

Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Luis Rodríguez Fernández <uo...@gmail.com>.
Hello Akram,

If you can not put the jars inside each webapp perhaps you could define a
shared.loader in your catalina.properties [1]. It works for us.

Hope it helps,

Luis

[1]
https://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html#Advanced_configuration







El mar., 16 abr. 2019 a las 23:21, Christopher Schultz (<
chris@christopherschultz.net>) escribió:

> -----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 <
> > chris@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 <
> >>>> chris@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-unsubscribe@tomcat.apache.org
> >>>>> For additional commands, e-mail:
> >>>>> users-help@tomcat.apache.org
> >>>>>
> >>>>>
> >>>>
> >>
> >> ---------------------------------------------------------------------
> >>
> >>
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

-- 

"Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better."

- Samuel Beckett

Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----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 < 
> chris@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 < 
>>>> chris@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-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail:
>>>>> users-help@tomcat.apache.org
>>>>> 
>>>>> 
>>>> 
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Akram Hussain <ak...@gmail.com>.
Hi Christopher,

I have almost 27-30 apps in my tomcat.

Do I need to declare in every applications's META-INF\context.xml.

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

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

Regards,
Akram.



On Wed, Apr 17, 2019 at 1:02 AM Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> 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 <
> > chris@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-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAly2LbIACgkQHPApP6U8
> pFj7hA//T4xw27FJxUCRXMM7KGJDu6AYcetov1tC7IqwNkjtSds7DJW3ijFCfimv
> sRd92bEinM6miZy5sVOAnlTZje/vL6NCJSJRuGvLk8YBmbJop2wl566L6gSeH8Co
> L9zV3HOOSNq7v+K2nIfrCbrrKNmYQ/15TLFrOJhXHmiLNv3Fq5cvJzdko5qfllWy
> qIQNlrQLm+vluIHnuITGo53D2EVxrYJHVb2xOO8PoAKSc2PYaJ0C7M0YRycc4Bw9
> zLVXlY2xqsG/3r6CpqFebTzNqhDdIhlB9pDwRKXGhlocvYOQyS4SFAM0obRP1KWz
> hNYzCe2JeJJBWkxANkrUdwxoLqwb2bWoOK7FIbzObeJ+sCbqIz55hz/FVoF5SQur
> iS2k7oqyWH63SSZXBsY6GkVIS9qb6Od7ve3Pk789ueG3JbXQs726msu4DXZDtOSp
> g+Vbwd+5lczSl3zW8iRqKlxxqcBVqxI3Sd4KfblehrWdf/qKbIvqfdv2wriPfC9L
> IAEaZLGIrRG42p2rBkj0RM/xSGQC85S8CjxULgIUsTuUuUXl1PBwNnJhpidGAZlH
> bXvqqsUP7JHupun67a1P438MppGDekvSp5L/iH1aXXldE2nk/VZTPU0ugl5ksXx/
> VLPCabwgEJmeeFzaQG3BuZCRf77xDR9aKWjqrQ2ohElkWEtV+LM=
> =CFOr
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Mark Thomas <ma...@apache.org>.
On 22/04/2019 12:32, Akram Hussain wrote:
> Hi,
> 
> So how can I access the file in shared\lib folder from tomcat\lib folder.
> 
> I have a class in tomcat\lib which will access the class which is in
> tomcat\shared folder.

If you want the classes in shared\lib to be visible to both web
applications and Tomcat then perhaps the simplest solution is to add
/path/to/shared/lib/*.jar to the definition of the common.loader in
$CATALINA_BASE/conf/catalina.properties

Mark

> 
> Regards,
> Akram.
> 
> On Mon, Apr 22, 2019 at 4:32 PM Mark Thomas <ma...@apache.org> wrote:
> 
>> On 22/04/2019 06:41, Akram Hussain wrote:
>>> Hi Mark,
>>>
>>> Actually, I am declaring a Loader in tomcat\conf\context.xml file as
>>
>> Don't do that.
>>
>>> for Tomcat 7.0.68, It was working fine.
>>
>> <snip/>
>>
>>>
>> -----------------------------------------------------------------------------------------------------------------------
>>>
>>> After upgrade to tomcat 9.0.17.
>>>
>>> The start method of SharedClassLoader.java is expecting resources
>> variable
>>> needs to be populated.
>>>
>>> How can I pass the Resources to above SharedClassLoader?
>>
>> With difficulty and an awful lot of work. The resources implementation
>> was completely re-written for Tomcat 8 onwards.
>>
>>> Any idea?
>>
>> Follow the advice in my previous mail.
>>
>> <snip/>
>>
>>> On Fri, Apr 19, 2019 at 4:09 AM Mark Thomas <ma...@apache.org> wrote:
>>>> The OP is trying to load JARs so the /path/to/your/shared/libraries
>>>> directory needs to be mounted at WEB-INF/lib, not WEB-INF/classes.
>>>>
>>>> We (OK I since I wrote this stuff) should probably have better
>>>> documented which implementation to pick.
>>>>
>>>> You pick the implementation based on where the files you want to insert
>>>> are located.
>>>>
>>>> If you want to insert a single file, use FileResourceSet
>>>> If you want to insert a directory tree, use DirResourceSet
>>>> If you want to insert files from inside an archive (JAR) then use a
>>>> JarResourceSet.
>>>>
>>>> Note: Using a JarResourceSet effectively unpacks the archive as far as
>>>> Tomcat is concerned so Tomcat sees directories and files, not a single
>>>> JAR file.
>>>>
>>>> In this case you have a directory of JAR files so you want a
>>>> DirResourceSet.
>>>>
>>>> Assuming you want those JAR files to be treated as if they were placed
>>>> in WEB-INF/lib then you want:
>>>>
>>>> <Resources>
>>>>   <PostResources
>>>>       webAppMount="/WEB-INF/lib"
>>>>       base="/path/to/your/shared/libraries"
>>>>       className="org.apache.catalina.webresources.DirResourceSet"
>>>>   />
>>>> </Resources>
>>>>
>>>> That has the same effect as copying the entire contents of
>>>> /path/to/your/shared/libraries to WEB-INF/lib.
>>>>
>>>> If you want this to apply to every web application you deploy then add
>>>> the above to global context.xml in CATALINA_BASE/conf/context.xml
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 


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


Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Akram Hussain <ak...@gmail.com>.
Hi,

So how can I access the file in shared\lib folder from tomcat\lib folder.

I have a class in tomcat\lib which will access the class which is in
tomcat\shared folder.

Regards,
Akram.

On Mon, Apr 22, 2019 at 4:32 PM Mark Thomas <ma...@apache.org> wrote:

> On 22/04/2019 06:41, Akram Hussain wrote:
> > Hi Mark,
> >
> > Actually, I am declaring a Loader in tomcat\conf\context.xml file as
>
> Don't do that.
>
> > for Tomcat 7.0.68, It was working fine.
>
> <snip/>
>
> >
> -----------------------------------------------------------------------------------------------------------------------
> >
> > After upgrade to tomcat 9.0.17.
> >
> > The start method of SharedClassLoader.java is expecting resources
> variable
> > needs to be populated.
> >
> > How can I pass the Resources to above SharedClassLoader?
>
> With difficulty and an awful lot of work. The resources implementation
> was completely re-written for Tomcat 8 onwards.
>
> > Any idea?
>
> Follow the advice in my previous mail.
>
> <snip/>
>
> > On Fri, Apr 19, 2019 at 4:09 AM Mark Thomas <ma...@apache.org> wrote:
> >> The OP is trying to load JARs so the /path/to/your/shared/libraries
> >> directory needs to be mounted at WEB-INF/lib, not WEB-INF/classes.
> >>
> >> We (OK I since I wrote this stuff) should probably have better
> >> documented which implementation to pick.
> >>
> >> You pick the implementation based on where the files you want to insert
> >> are located.
> >>
> >> If you want to insert a single file, use FileResourceSet
> >> If you want to insert a directory tree, use DirResourceSet
> >> If you want to insert files from inside an archive (JAR) then use a
> >> JarResourceSet.
> >>
> >> Note: Using a JarResourceSet effectively unpacks the archive as far as
> >> Tomcat is concerned so Tomcat sees directories and files, not a single
> >> JAR file.
> >>
> >> In this case you have a directory of JAR files so you want a
> >> DirResourceSet.
> >>
> >> Assuming you want those JAR files to be treated as if they were placed
> >> in WEB-INF/lib then you want:
> >>
> >> <Resources>
> >>   <PostResources
> >>       webAppMount="/WEB-INF/lib"
> >>       base="/path/to/your/shared/libraries"
> >>       className="org.apache.catalina.webresources.DirResourceSet"
> >>   />
> >> </Resources>
> >>
> >> That has the same effect as copying the entire contents of
> >> /path/to/your/shared/libraries to WEB-INF/lib.
> >>
> >> If you want this to apply to every web application you deploy then add
> >> the above to global context.xml in CATALINA_BASE/conf/context.xml
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Mark Thomas <ma...@apache.org>.
On 22/04/2019 06:41, Akram Hussain wrote:
> Hi Mark,
> 
> Actually, I am declaring a Loader in tomcat\conf\context.xml file as

Don't do that.

> for Tomcat 7.0.68, It was working fine.

<snip/>

> -----------------------------------------------------------------------------------------------------------------------
> 
> After upgrade to tomcat 9.0.17.
> 
> The start method of SharedClassLoader.java is expecting resources variable
> needs to be populated.
> 
> How can I pass the Resources to above SharedClassLoader?

With difficulty and an awful lot of work. The resources implementation
was completely re-written for Tomcat 8 onwards.

> Any idea?

Follow the advice in my previous mail.

<snip/>

> On Fri, Apr 19, 2019 at 4:09 AM Mark Thomas <ma...@apache.org> wrote:
>> The OP is trying to load JARs so the /path/to/your/shared/libraries
>> directory needs to be mounted at WEB-INF/lib, not WEB-INF/classes.
>>
>> We (OK I since I wrote this stuff) should probably have better
>> documented which implementation to pick.
>>
>> You pick the implementation based on where the files you want to insert
>> are located.
>>
>> If you want to insert a single file, use FileResourceSet
>> If you want to insert a directory tree, use DirResourceSet
>> If you want to insert files from inside an archive (JAR) then use a
>> JarResourceSet.
>>
>> Note: Using a JarResourceSet effectively unpacks the archive as far as
>> Tomcat is concerned so Tomcat sees directories and files, not a single
>> JAR file.
>>
>> In this case you have a directory of JAR files so you want a
>> DirResourceSet.
>>
>> Assuming you want those JAR files to be treated as if they were placed
>> in WEB-INF/lib then you want:
>>
>> <Resources>
>>   <PostResources
>>       webAppMount="/WEB-INF/lib"
>>       base="/path/to/your/shared/libraries"
>>       className="org.apache.catalina.webresources.DirResourceSet"
>>   />
>> </Resources>
>>
>> That has the same effect as copying the entire contents of
>> /path/to/your/shared/libraries to WEB-INF/lib.
>>
>> If you want this to apply to every web application you deploy then add
>> the above to global context.xml in CATALINA_BASE/conf/context.xml

Mark

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


Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Akram Hussain <ak...@gmail.com>.
Hi Mark,

Actually, I am declaring a Loader in tomcat\conf\context.xml file as

--------------------------------------------------------------------------------------------------------------------
<Loader
className="com.teradata.viewpoint.portal.container.loader.SharedClasspathWebappLoader"
/>

in its startInternal() method, we are creating SharedClassLoader as like
this.

Field field = WebappLoader.class.getDeclaredField("parentClassLoader");
field.setAccessible(true);
field.set(this, SharedClassLoader.getInstance());

The SharedClassLoader returns its instance, through this code.

sharedClassLoader = new
SharedClassLoader(WebappLoader.class.getClassLoader());

Its constructor is like this

public SharedClassLoader(ClassLoader parent) throws Exception
    {
        super(parent);
        this.parentClassLoader = parent;
        for (URL url : parseClassPath(SHARED_LOCATION))
        {
            addURL(url);
        }
        start();
    }

for Tomcat 7.0.68, It was working fine.
-----------------------------------------------------------------------------------------------------------------------

After upgrade to tomcat 9.0.17.

The start method of SharedClassLoader.java is expecting resources variable
needs to be populated.

How can I pass the Resources to above SharedClassLoader?

Any idea?

Regards,
Akram.






On Fri, Apr 19, 2019 at 4:09 AM Mark Thomas <ma...@apache.org> wrote:

> On 16/04/2019 20:32, Christopher Schultz 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.
>
> The OP is trying to load JARs so the /path/to/your/shared/libraries
> directory needs to be mounted at WEB-INF/lib, not WEB-INF/classes.
>
> We (OK I since I wrote this stuff) should probably have better
> documented which implementation to pick.
>
> You pick the implementation based on where the files you want to insert
> are located.
>
> If you want to insert a single file, use FileResourceSet
> If you want to insert a directory tree, use DirResourceSet
> If you want to insert files from inside an archive (JAR) then use a
> JarResourceSet.
>
> Note: Using a JarResourceSet effectively unpacks the archive as far as
> Tomcat is concerned so Tomcat sees directories and files, not a single
> JAR file.
>
> In this case you have a directory of JAR files so you want a
> DirResourceSet.
>
> Assuming you want those JAR files to be treated as if they were placed
> in WEB-INF/lib then you want:
>
> <Resources>
>   <PostResources
>       webAppMount="/WEB-INF/lib"
>       base="/path/to/your/shared/libraries"
>       className="org.apache.catalina.webresources.DirResourceSet"
>   />
> </Resources>
>
> That has the same effect as copying the entire contents of
> /path/to/your/shared/libraries to WEB-INF/lib.
>
> If you want this to apply to every web application you deploy then add
> the above to global context.xml in CATALINA_BASE/conf/context.xml
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Mark Thomas <ma...@apache.org>.
On 16/04/2019 20:32, Christopher Schultz 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.

The OP is trying to load JARs so the /path/to/your/shared/libraries
directory needs to be mounted at WEB-INF/lib, not WEB-INF/classes.

We (OK I since I wrote this stuff) should probably have better
documented which implementation to pick.

You pick the implementation based on where the files you want to insert
are located.

If you want to insert a single file, use FileResourceSet
If you want to insert a directory tree, use DirResourceSet
If you want to insert files from inside an archive (JAR) then use a
JarResourceSet.

Note: Using a JarResourceSet effectively unpacks the archive as far as
Tomcat is concerned so Tomcat sees directories and files, not a single
JAR file.

In this case you have a directory of JAR files so you want a DirResourceSet.

Assuming you want those JAR files to be treated as if they were placed
in WEB-INF/lib then you want:

<Resources>
  <PostResources
      webAppMount="/WEB-INF/lib"
      base="/path/to/your/shared/libraries"
      className="org.apache.catalina.webresources.DirResourceSet"
  />
</Resources>

That has the same effect as copying the entire contents of
/path/to/your/shared/libraries to WEB-INF/lib.

If you want this to apply to every web application you deploy then add
the above to global context.xml in CATALINA_BASE/conf/context.xml

Mark

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


Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

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 < 
> chris@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-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
>> 
> 
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAly2LbIACgkQHPApP6U8
pFj7hA//T4xw27FJxUCRXMM7KGJDu6AYcetov1tC7IqwNkjtSds7DJW3ijFCfimv
sRd92bEinM6miZy5sVOAnlTZje/vL6NCJSJRuGvLk8YBmbJop2wl566L6gSeH8Co
L9zV3HOOSNq7v+K2nIfrCbrrKNmYQ/15TLFrOJhXHmiLNv3Fq5cvJzdko5qfllWy
qIQNlrQLm+vluIHnuITGo53D2EVxrYJHVb2xOO8PoAKSc2PYaJ0C7M0YRycc4Bw9
zLVXlY2xqsG/3r6CpqFebTzNqhDdIhlB9pDwRKXGhlocvYOQyS4SFAM0obRP1KWz
hNYzCe2JeJJBWkxANkrUdwxoLqwb2bWoOK7FIbzObeJ+sCbqIz55hz/FVoF5SQur
iS2k7oqyWH63SSZXBsY6GkVIS9qb6Od7ve3Pk789ueG3JbXQs726msu4DXZDtOSp
g+Vbwd+5lczSl3zW8iRqKlxxqcBVqxI3Sd4KfblehrWdf/qKbIvqfdv2wriPfC9L
IAEaZLGIrRG42p2rBkj0RM/xSGQC85S8CjxULgIUsTuUuUXl1PBwNnJhpidGAZlH
bXvqqsUP7JHupun67a1P438MppGDekvSp5L/iH1aXXldE2nk/VZTPU0ugl5ksXx/
VLPCabwgEJmeeFzaQG3BuZCRf77xDR9aKWjqrQ2ohElkWEtV+LM=
=CFOr
-----END PGP SIGNATURE-----

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


Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Akram Hussain <ak...@gmail.com>.
Hi Christofer,

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.

Regards,
Akram.

On Tue, Apr 16, 2019 at 7:57 PM Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> 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
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAly15l4ACgkQHPApP6U8
> pFj9eRAAruPoNK9CF2Cy/aVM9eBuBWtlAC8j5Zgr/UGIb5XEQsYg/fw0SxiWC6lW
> c7SV9jeUdptkqKPvqGDMb07/LSHobbuN1wrF/oWxDKJA9a8IltcI775ZxiCFAA7C
> Fl//zP8rv/jXhGB+IyiH6OqbFRsC3tc630rsi4bVYMkaK58DuhvL9BpBWiobC7rF
> YEQT+yNjqqLHO/SxN70Ar2/p7zNAiNdkv/wDkVFzdWhvqIYIekgeVMQr4GkcCLH6
> 9eNZb+lw9DBhTqJYYSBoolAs7nadYp3hTBgxRm5vyXl7ODSV0gZHXFoG9aEDYkgU
> GCtltrGi0b32l+D3YDnMPjpdf1nc9A5No5cHXXdLi5LI1msEKcsfdHUA3Y30kxE3
> p1m/Y7iVD8R8jLYp1g0JPwXnwfoBhSd0WVTZhlB6i6MP4o/mAAgsqQ1bDlvNlWOL
> 3l6drzE02zxJVk2RAVjSN/s1sCpsTOlldq8PwplQz8IZy3BHtrG2B2qMOVFkg4G2
> mupFaB+/E5Lay1VWzPdsSECB2aMtf/sTtix+E0MmwmlVK2NLA1AEZGPuim7cHY8h
> lW8JyXp/DdfqCL7qA1SSDZhPefeNQkN41y0vfKNUurkYUTnYgcmtMYzZjm00udhR
> QzDL4qfnn/DXen+SXp8YpbfsvCc8bIaWlxmVrnFB4+DZ2KpyYb4=
> =XVmW
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Upgrade from Tomcat 7 to Tomcat 9.0.17

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

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
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAly15l4ACgkQHPApP6U8
pFj9eRAAruPoNK9CF2Cy/aVM9eBuBWtlAC8j5Zgr/UGIb5XEQsYg/fw0SxiWC6lW
c7SV9jeUdptkqKPvqGDMb07/LSHobbuN1wrF/oWxDKJA9a8IltcI775ZxiCFAA7C
Fl//zP8rv/jXhGB+IyiH6OqbFRsC3tc630rsi4bVYMkaK58DuhvL9BpBWiobC7rF
YEQT+yNjqqLHO/SxN70Ar2/p7zNAiNdkv/wDkVFzdWhvqIYIekgeVMQr4GkcCLH6
9eNZb+lw9DBhTqJYYSBoolAs7nadYp3hTBgxRm5vyXl7ODSV0gZHXFoG9aEDYkgU
GCtltrGi0b32l+D3YDnMPjpdf1nc9A5No5cHXXdLi5LI1msEKcsfdHUA3Y30kxE3
p1m/Y7iVD8R8jLYp1g0JPwXnwfoBhSd0WVTZhlB6i6MP4o/mAAgsqQ1bDlvNlWOL
3l6drzE02zxJVk2RAVjSN/s1sCpsTOlldq8PwplQz8IZy3BHtrG2B2qMOVFkg4G2
mupFaB+/E5Lay1VWzPdsSECB2aMtf/sTtix+E0MmwmlVK2NLA1AEZGPuim7cHY8h
lW8JyXp/DdfqCL7qA1SSDZhPefeNQkN41y0vfKNUurkYUTnYgcmtMYzZjm00udhR
QzDL4qfnn/DXen+SXp8YpbfsvCc8bIaWlxmVrnFB4+DZ2KpyYb4=
=XVmW
-----END PGP SIGNATURE-----

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