[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tomcat-user
Subject:    Re: classloader for components in META-INF/context.xml?
From:       Konstantin Kolinko <knst.kolinko () gmail ! com>
Date:       2017-03-22 12:39:42
Message-ID: CABzHfVmvUcgO=2o3yWcPOBD_0OPVf9+fZCqHzVrjJKkAJ5MAPw () mail ! gmail ! com
[Download RAW message or body]

2017-03-17 23:21 GMT+03:00 Mike Wilson <mikewse@hotmail.com>:
>
> I also ran into [1].
>
> Some Tomcat configuration with custom components (Valves, Managers etc) may
> be done from a webapp's META-INF/context.xml. But currently if those classes
> are your own custom implementations they will not be found if residing
> inside the webapp's war (but are f ex found if placed in <tomcat>/lib).
>
> Would it make sense for Tomcat to use the webapp classloader for components
> that are specified in META-INF/context.xml?
>
> Best regards
> Mike Wilson
>
> [1]
> http://stackoverflow.com/questions/10924715/creating-a-custom-tomcat-session
> -manager-without-putting-the-jar-in-the-catalina
>

Besides the security issues that Mark mentions,

Note that Web application's classloader is only available when the web
application is running.

It means that

1) All those custom classes (Listeners, Valves etc.) cannot be created
at the time when context.xml is parsed, and must be replaced with some
stub objects.

2) They cannot process "destroy" event (when the application is
undeployed), as the classloader is stopped earlier - on "stop" event.

http://tomcat.apache.org/tomcat-8.5-doc/api/org/apache/catalina/Lifecycle.html

3) As Webapp classloader has priority over Tomcat classloader, you
cannot really create any component before Webapp classloader is
started - as the same class can be redefined in the web application.

http://tomcat.apache.org/tomcat-8.5-doc/class-loader-howto.html

4) Some objects are needed before Webapp classloader is started.

If context.xml redefines / reconfigures classloader implementation
(Loader element) - when is it created, and how?
What classloader is used to load and create it and why?

http://tomcat.apache.org/tomcat-8.5-doc/config/loader.html

A Listener can reconfigure web application before it is started. Some
of those will be broken.

E.g. a listener can perform the same actions as "PreResources" or
"PostResources" elements to inject additional JARs into webapp
classpath. It is better to do that before starting a web application
class loader.

http://tomcat.apache.org/tomcat-8.5-doc/config/resources.html

5) Configuration of a web application can be performed externally, via JMX API.

What objects will be exposed via JMX and starting with what moment / state?

http://tomcat.apache.org/tomcat-8.5-doc/monitoring.html

Best regards,
Konstantin Kolinko

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic