[spring] org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljav 解决

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V

严重: Error listenerStart
2011-2-15 20:09:18 org.apache.catalina.core.StandardContext start
严重: Context [/h1] startup failed due to previous errors
2011-2-15 20:09:18 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2011-2-15 20:09:18 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2011-2-15 20:09:18 org.apache.catalina.loader.WebappClassLoader loadClass
信 息: Illegal access: this web application instance has been stopped already.  Could not load java.net.BindException.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1244)

2011-2-15 20:09:18 org.apache.catalina.loader.WebappClassLoader loadClass
信 息: Illegal access: this web application instance has been stopped already.  Could not load com.mysql.jdbc.Util.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1244)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)

2011-2-15 20:09:18 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-2-15 20:09:18 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/125  config=null
2011-2-15 20:09:18 org.apache.catalina.startup.Catalina start
信息: Server startup in 6798 ms



在使用Spring的AOP编程时,会用到这几个lib:
asm-2.2.2.jar
asm-commons-2.2.2.jar
asm-util-2.2.2.jar
Hibernate使用如果lib:
asm.jar
asm-attrs.jar
其中asm-2.2.2.jar与asm.jar存在类上的冲突!!!
使用其中之一或两者都使用,可能会出现如下错误:
java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
java.lang.NoClassDefFoundError: org/objectweb/asm/commons/EmptyVisitor
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit。。。。。。
解决办法是:
1.去掉类路径上的关于Hibernate的3个lib
asm.jar
asm-attrs.jar
cglib-2.1.3.jar
2.加入Spring中的以下4个lib
asm-2.2.2.jar
asm-commons-2.2.2.jar
asm-util-2.2.2.jar
cglib-nodep-2.1_3.jar

原文地址:https://www.cnblogs.com/lonelywolfmoutain/p/5117450.html