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 阅读(7183) 评论(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----怎么办?  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: