views:

183

answers:

2

I am using Salve Dependency Injection library that instruments the byte code of the web application. I specified -javaagent in Tomcat VM options and pointed it to the Salve agent jar.

The agent jar gets loaded, but then it throws a java.lang.NoClassDefFoundError unable to find classes that are in other Salve jars which are located in WEB-INF/lib folder of my web app.

I can solve this problem by putting those JARs in Tomcat/endorsed folder. However, some of those jars depend on third-party libraries, such as Spring and servlet-api.jar. Therefore, I am forced to put all these dependencies in Tomcat/endorsed as well.

Could anybody suggest a better way for handling dependencies of a Tomcat javaagent?

Thanks.

A: 

This sounds very weird. Agents usually do not depend on other classes, as it would make them completely useless. I think you are misunderstanding the error. Is it possible that the dependency is from the instrumented classes and wrong classes are ending up instrumented?

Jevgeni Kabanov
Salve library consists of several JARs. Some of them depend on third-party libraries, such as Spring. I ended up moving those JARs from tomcat/endorsed to my webapp's WEB-INF/lib. My findings and the final working directory structure are documented here http://groups.google.com/group/salve-disc/browse_thread/thread/2c70e1b24c277246?
alecswan
A: 

Salve? WTF? Use AspectJ.

"Dependency injection framework that depends on Spring" - o_O ?!

artemv