tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryn Cooke <>
Subject WebappClassLoaderBase.addTransformer and servlet 3.0
Date Fri, 04 Sep 2015 07:22:08 GMT
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?
Or perhaps there is another way of registering the transformer earlier?

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.

Many thanks,


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message