现在的位置: 首页 > 综合 > 正文

1. 出现如下的错误

2013年10月14日 ⁄ 综合 ⁄ 共 2429字 ⁄ 字号 评论关闭

1.       出现如下的错误

Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/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

解决问题的方法:

发现是由于Spring中的“asm-2.2.3.jar”和Hibernate中的“asm.jar”包冲突。解决办法是移除Spring2.0 AOP Libraries中的“asm-2.2.3.jar”即可

2.出现一下的错误

(1)java.lang.NoClassDefFoundError: org/hibernate/context/CurrentSessionContext

原因:出现这错误时,请更改hibernate的包,更新至最新或3.1以上

2)java.lang.NoClassDefFoundError: javax/transaction/TransactionManager

原因:缺少jta.jar 或者是找不到hbm.xml文件导致sessionfactory出错,检查hbm文件路径是否正确,文件是否存在

(3)org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not insert: [com.yourcompany.model.Login]; bad SQL grammar [insert into mysql__login (name, password) values (?, ?)]; nested exception is java.sql.SQLException: Table 'mysql.mysql__login' doesn't exist
java.sql.SQLException: Table 'mysql.mysql__login' doesn't exist

原因:把hbm文件里面的catalog="'mysql"去掉即可!

(4)org.springframework.orm.hibernate3.HibernateQueryException: undefined alias

原因:在spring配置文件中,可能你设置了<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>,指定了HQL的解释器,请删除或更改另一个解释器org.hibernate.hql.ast.ASTQueryTranslatorFactory, 如果没有设置,请确认是否有写错了HQL语句,是否与POJO里的属性一样。注意区分大小写。

(5)quartz报错:
Caused by: java.lang.NoSuchMethodError: org.apache.commons.collections.SetUtils.orderedSet(Ljava/util/Set;)Ljava/util/Set;
的原因是由于使用的commons-collections.jar版本太低导致的要使用3.*的才行,下载地址为:http://commons.apache.org/downloads/download_collections.cgi
选Binary下的zip下载,下载后将里的的commons-collections-x.x.x.jar放置到你的classpath里即可。记得删除旧的那个jar包

(6)org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.mchange.v2.c3p0.ComboPooledDataSource] for bean
这是因为你的sping配置文件是使用c3p0作数据池,而你的classpath里没有找到这个c3p0的jar包而导致的,下载一个jar导入classpath即可。地址为:http://sourceforge.net/project/showfiles.php?group_id=25357&package_id=88527,如果是windows的就选择zip的下载。

(7)The Network Adapter could not establish the connection
请检查你的url,user,pwd,dialect等等是否正确

(8)java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
原因:你更新了hibernate3.2的包,但你的classpath里可能存在hibernate-annotations.jar的包,删除之或更新至最新版本的包即可。

9)java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.<init>()V from class org.hibernate.cache.EhCacheProvider
原因:可能你更新了hiberante的包,导致原来的原来ehcache不行了,原来使用的是1.1的版本,换成1.5以上的正常,另还需要一个javassist.jar包

抱歉!评论已关闭.