spring常见异常

出现的问题解决:
问题  1    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframework.util.ClassUtils.<clinit>(  ClassUtils.java:67  )   at org.springframework.core.io.DefaultResourceLoader.<init>(  DefaultResourceLoader.java:52  ) at org.springframework.context.support.AbstractApplicationContext.<init>( AbstractApplicationContext.java:184  ) at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(  AbstractRefreshableApplicationContext.java:80  ) at org.springframework.context.support.AbstractXmlApplicationContext.<init>(  AbstractXmlApplicationContext.java:58  )   at
需要加上:  commons-logging.jar log4j-1.2.11.jar
 
问题  2    Exception in thread "main"  org.springframework.beans.factory.BeanDefinitionStoreException  : Unexpected exception parsing XML document from class path resource [text.xml]; nested exception is java.lang.NoClassDefFoundError:  org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
Caused by: java.lang.NoClassDefFoundError:  org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
    at java.lang.Class.forName0(  Native Method  )
 
需要加上:  aspectjweaver.jar
 
问题  3    Exception in thread "main"  org.springframework.beans.factory.BeanCreationException  : Error creating bean with name 'logBean' defined in class path resource [text.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException  : Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
Caused by:  org.springframework.aop.framework.AopConfigException  : Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
需要加上:  cglib-2.1.3.jar
 
 
问题  4    xception in thread "main"  org.springframework.beans.factory.BeanCreationException  : Error creating bean with name 'logBean' defined in class path resource [text.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/Type
Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/Type
    at net.sf.cglib.core.TypeUtils.parseType(  TypeUtils.java:180  )
需要加上:  asm.jar


错误:java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor的解决方法

在使用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


你可能感兴趣的:(spring,thread,exception,Class,nested,initialization)