欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Java框架缺包异常总结 博客分类: 日常累计 Java框架BeanSpringAOP 

程序员文章站 2024-03-21 20:29:04
...

编程时使用的struts,spring,hibernate等框架时,经常被一些异常误导,找了很长时间,得出个结论"缺包".


以下异常可以帮助编程者解决部分缺包问题:
---------------------------------------------------------------------------------
异常1:
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.web.context.ContextLoader.<clinit>(ContextLoader.java:146)
at org.springframework.web.context.ContextLoaderListener.createContextLoader(ContextLoaderListener.java:53)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:44)

需要加上:commons-logging.jar,log4j-1.2.11.jar
---------------------------------------------------------------------------------
异常2:
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:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logBean' defined in class path resource [spring.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:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logBean' defined in class path resource of ServletContext: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
java.lang.NoClassDefFoundError: javax/transaction/TransactionManager

需要加上:jta.jar
---------------------------------------------------------------------------------
异常6:
java.lang.NoClassDefFoundError: org/dom4j/Attribute
需要加上:dom4j.jar
---------------------------------------------------------------------------------
异常7:
java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
需要加上:ehcache.jar
---------------------------------------------------------------------------------
异常8:
java.lang.NoClassDefFoundError: net/sf/cglib/core/KeyFactory
需要加上:cglib-full.jar
---------------------------------------------------------------------------------