This Is A FineDay

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            93 隨筆 :: 0 文章 :: 69 評論 :: 0 Trackbacks

          java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass

          Problem with Spring 1.2.6 and Hibernate 3.1 : HbmBinder$SecondPass

          今天又遇到了這個問題,真是讓人郁悶了老半天。一心揪出它的根本原因,經過了好半天的刺撓終于找到了就是(hibernate3.jar和hibernate-annotations.jar)的問題,簡單主法把hibernate-annotations.jar直接干掉就OK了。
          好果有用到這個包就得去找個高點version的去用了。
          不知道大家有沒有更好的解決方法呀

          Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
          java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java :620)
          at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader .java:260)
          at java.net.URLClassLoader.access$100(URLClassLoader. java:56)
          at java.net.URLClassLoader$1.run(URLClassLoader.java: 195)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:268)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
          at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
          at org.hibernate.cfg.Configuration.add(Configuration. java:385)
          at org.hibernate.cfg.Configuration.addInputStream(Con figuration.java:426)
          at org.springframework.orm.hibernate3.LocalSessionFac toryBean.afterPropertiesSet(LocalSessionFactoryBea n.java:654)
          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1059)
          at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:363)
          at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
          at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
          at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:269)
          at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:320)
          at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:87)
          at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:72)
          at org.stockfi.persistence.orm.hibernate.core.Main.ma in(Main.java:57)
          ?
          ?
          reason is:It seems that org\hibernate\cfg\HbmBinder$SecondPass.class no longer exists in hibernate3.jar.
          Specifically, the hibernate3.jar that ships with Spring 1.2.7 appears to be Hibernate v3.0.5. This version of the jar does indeed include the org/hibernate/cfg/HbmBinder$SecondPass class. When I remove this version of hibernate3.jar and replace it with the latest and greatest hibernate3.jar this problem arises. The latest version of Hibernate (hibernate3.jar) is v3.1.3.

          By simply inspecting the contents of the hibernate3.jar files you will see this problem.

          This leads me to believe that we must use the hibernate3.jar that ships with Spring v.1.2.7 (or whatever version people are using with respect to 1.2.x).

          My immediate concern is that itermixing Hibernate 3.1.3 support/dependency jars with a v3.0.5 hibernate3.jar may cause issues. I suppose I will need to download and use Hibernate 3.0.5 to be safe but I'd like very much to use Hibernate 3.1.3 w/o concern.

          Any ideas on whether a patch/update will be made available to get around this issue.

          ?
          See if there's been any issue raised on this topic. I know this topic has been discussed several times but always the solution was using the proper jars (and eliminating old ones which were used as dependencies as already noted in this thread).
          I've used spring with HB 3.1.3 and 3.0.5 without problems and by looking at the stacktrace, the problem is with hibernate (which actually calls the missing class) and not with Spring.
          posted on 2006-08-10 09:23 Peter Pan 閱讀(7202) 評論(8)  編輯  收藏 所屬分類: SSH

          評論

          # re: java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass 2006-12-30 21:18 qiuxi
          太謝謝了,我也是遇到這個問題,弄了兩天沒有結果,沒辦法,就把所報錯的內容,一個個的google,搜到了這里,刪掉hibernate-annotations果然又用了,真是郁悶,spring+Hibernate就是問題多,沒辦法,有點想投奔EJB去  回復  更多評論
            

          # re: java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass 2008-09-12 17:18 袁建華
          是啊,我也是遇到這個問題,我把我自己的項目都刪了,以為是我的項目問題,郁悶,現在可以了,唉,太謝謝了  回復  更多評論
            

          # re: java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass 2008-10-27 15:27 yac
          多謝,多謝,問題已經解決.  回復  更多評論
            

          # re: java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass 2008-12-02 22:18 ruan
          我快被這個問題整瘋了,刪掉這個包,一切ok了。謝謝!  回復  更多評論
            

          # re: java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass[未登錄] 2008-12-03 17:05 哈哈
          太感謝了 我也快被這個問題整瘋了   回復  更多評論
            

          # re: java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass 2008-12-03 20:38 ys
          3q  回復  更多評論
            

          # re: java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass 2009-02-20 22:45 hufengjiao
          可是那兩個是匹配的呢,我找了好多總是不對啊,郁悶中  回復  更多評論
            

          # re: java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass 2009-09-30 13:32 范德薩的
          在我這刪除那個包不能解決問題啊h----怎么辦?  回復  更多評論
            

          主站蜘蛛池模板: 潼关县| 林甸县| 萨嘎县| 昌宁县| 贵阳市| 元谋县| 罗田县| 温宿县| 多伦县| 理塘县| 洛扎县| 吐鲁番市| 凤山市| 无极县| 安国市| 山西省| 汽车| 繁峙县| 望奎县| 吉木萨尔县| 三河市| 黑水县| 株洲市| 大同县| 孟州市| 平定县| 望江县| 山东省| 和静县| 周口市| 黔东| 郓城县| 龙川县| 吉安市| 博乐市| 辽中县| 鸡东县| 闻喜县| 宁德市| 台北市| 河西区|