AOP Tomcat7.0 版本报错解决问题 这是个BUG 问题SPR-11446

来源:互联网 发布:网络it培训 编辑:程序博客网 时间:2024/06/03 06:30

折腾半天  其他版本好用 ,JETTY 好用  就是Tomcat7  版本不要用。

错入如下: 

       Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed; nested exception is java.lang.IllegalStateException: ClassLoader [org.apache.catalina.loader.WebappClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar



VM 参数同样添加  javaanegt 参数:



 解决 :


    

I have tested successfully to enable load-time-weaving in Tomcat 7.0.52 by adding spring-instrument-tomcat-3.2.8.RELEASE.jar to Tomcat's libdirectory and the following context.xml to the META-INF directory of my webapp:

1
2
3
4
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/test">
  <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
</Context>

Note: The InstrumentableClassLoader mentioned in SPR-10788 does not exist neither in Tomcat 7.0.52 nor its current 7.0.x trunk (http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk) but only in the main trunk (http://svn.apache.org/repos/asf/tomcat/trunk).

referee added a comment - 22/Sep/14 11:51 PM

7.0.55 - same issue

Jose Enrique Garcia added a comment - 27/Nov/14 10:22 AM

Founded this issue in 7.0.52-1 and try to apply solution without success. If I added the previous line in my context, say 
" Caused by: java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation "

If try to add -javaagent and failed, seems the jar miss some field in the Manifest (sorry no remember which one) and tomcat no start.

So, what is the correct way to have iLoad Time Weaver working?

Upgrade the tomcat version it's no possible, by the moment.

0 0