Tomcat 6 javagent 类加载器问题
我正在使用 Salve 依赖注入库来检测 Web 应用程序的字节代码。我在 Tomcat VM 选项中指定了 -javaagent 并将其指向 Salve 代理 jar。
代理 jar 被加载,但随后它抛出 java.lang.NoClassDefFoundError 无法找到位于我的 Web 应用程序的 WEB-INF/lib 文件夹中的其他 Salve jar 中的类。
我可以通过将这些 JAR 放在 Tomcat/endorsed 文件夹中来解决这个问题。但是,其中一些 jar 依赖于第三方库,例如 Spring 和 servlet-api.jar。因此,我被迫将所有这些依赖项也放入 Tomcat/endorsed 中。
有人能建议一种更好的方法来处理 Tomcat javaagent 的依赖关系吗?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这听起来很奇怪。代理通常不依赖于其他类,因为这会使它们完全无用。我认为你误解了这个错误。依赖项是否有可能来自已检测的类,并且最终检测了错误的类?
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?
药膏?搞什么?使用 AspectJ。
“依赖于 Spring 的依赖注入框架” - o_O ?!
Salve? WTF? Use AspectJ.
"Dependency injection framework that depends on Spring" - o_O ?!
Salve 库由多个 JAR 组成。其中一些依赖于第三方库,例如Spring。我最终将这些 JAR 从 tomcat/endorsed 移至我的 web 应用程序的 WEB-INF/lib。我的发现和最终工作目录结构记录在此处?
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?