spring+hibernate出错小结:

(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包

(10)Connections could not be acquired from the underlying database
大概的意思是说:不能连接当前所配置的数据库,检查你的URL链接字符串是否正确,另,可参考这个网址的内 容:http://www.javaeye.com/topic/28230

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值