解决org/hibernate/cfg/HbmBinder$SecondPass有关问题
解决org/hibernate/cfg/HbmBinder$SecondPass问题
java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
Problem with Spring 1.2.6 and Hibernate 3.1 : HbmBinder$SecondPass
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
【解决方法】
从hibernate网站下载最新的hibernate-annotations.jar包,此包与你下载的hibernate3.jar的文件是相对应的,下载地址是:http://prdownloads.sourceforge.net/hibernate/?sort_by=date&sort=desc
替换掉原来lib目录下的hibernate-annotations.jar,一切就正常了
【原文】
java.lang.NoClassDefFoundError: org/hibernate/cfg/HbmBinder$SecondPass
Problem with Spring 1.2.6 and Hibernate 3.1 : HbmBinder$SecondPass
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)
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.
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.
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.
url:http://forum.springframework.org/showthread.php?t=20553
1 楼
yangpeihai
2008-06-20
谢谢。。。。不过我按照你的方法还是不行。。。。郁闷。。。。请指点一下。。。。