tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: WebappClassLoaderBase.addTransformer and servlet 3.0
Date Fri, 04 Sep 2015 07:55:09 GMT
On 04/09/2015 08:22, Bryn Cooke wrote:
> Hi,
> I've recently been looking at using the class transformer functionality
> in Tomcat 8.0.26 and came across a subtle interaction with servlet 3.0.
> I am registering my transformer in a ServletContainerInitializer via
> InstrumentableClassLoader.addTransformer, but couldn't understand why
> some classes appeared to not undergo transformation. It turned out they
> were annotated and were being passed in to another
> ServletContextInitializer by virtue of it using @HandlesTypes. This
> meant that the class had already been loaded before I had a chance to
> register the transformer.
> 
> I can't think of a nice way around this, but was wondering if there
> there was any appetite for creating a mechanism to register transformers
> directly after WebAppClassLoader is set up, perhaps via the
> ServiceLoader mechanism?

You aren't the first to hit this problem:
https://bz.apache.org/bugzilla/show_bug.cgi?id=58143

> Or perhaps there is another way of registering the transformer earlier?

Only if you provide a custom class loader implementation (which is also
non-trivial for deployment).

> Ideally I would like to avoid the javaagent route as it will interfere
> with other wep apps that are deployed on the same tomcat instance and
> make deployment less easy.

The cleanest way to do this would be to add an option to the Context to
list the transformer classes that should be applied. I'd suggest
re-opening BZ 58143 as an enhancement, documenting your proposal and
adding something to the references Spring issue asking for input from
the Spring community.

Mark


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


Mime
View raw message