java - VerifyError when instrumenting webapp on WildFly 8 -


i'm working on project, trying insert additional log4j logging statements running webapp. realise that, start java agent via jvm parameter when launching wildfly:

-javaagent:path/to/agent.jar 

the agent's premain method receives instrumentation object , establishes mbean remote access. logging insertion achieved using instrumentation , javassist. far, works perfectly. however, keep working, agent.jar has reside in webapp's war file on deployment, since log4j logger class used logging ships jar. if not, verifyerror when class definition updated instrumentation api. trying load e.g. classes java.lang inserting code "math.random()" works expected.
it's important notice agent classes loaded appclassloader parent of application's moduleclassloader. therefore i'm wondering why classes residing in agent.jar can't loaded delegation through moduleclassloader. these observation brought me assumption webapp module needs declare explicit dependency on external jars, if classes known parent appclassloader. security issues make sense me.

can confirm these assumptions or have idea or experience causes behavior?

thanks!

---------------- edit ---------------------

playing around wildfly classloading mechanism helped me describe problem more in detail. assuming want load class named com.example.loggerclass (residing in agent.jar!) using moduleclassloader in managedbean belonging webapp:

class<?> aclass = this.getclass().getclassloader().loadclass("com.example.loggerclass"); 

this results in classnotfoundexxception! delegating underlying appclassloader manually works perfectly:

class<?> aclass = this.getclass().getclassloader().getparent().loadclass("com.example.loggerclass"); 

now jboss docs concerning moduleclassloader's loadclass method tell following:

find class, possibly delegating other loader(s)

this may explain behavior showed above, assuming moduleclassloader not delegate class loading because of security issues. there way override , make moduleclassloader delegate appclassloader in cases?

an java agent loaded system class loader. of dependencies must available on class path. if howver experienceing verifier error, byte code illegal verification happens before loading completes. means, problem not class loader related.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -