当前位置: 代码迷 >> J2EE >> Cannot resolve reference to bean 'sessionFactory' while setting bean property 's解决方案
  详细解决方案

Cannot resolve reference to bean 'sessionFactory' while setting bean property 's解决方案

热度:704   发布时间:2016-04-22 01:17:39.0
Cannot resolve reference to bean 'sessionFactory' while setting bean property 's
struts1.X,hibernate3.2,Spring 2.x
一直包上面的错误,也按照网上说的,删除hibernate的asm,用spring下的asm开头的3个jar
可以程序还是报错,如下:
Java code
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userinfoDaoImpl' defined in file [E:\workspace\jail_Locate\WebRoot\WEB-INF\classes\applicationContext-beans.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [E:\workspace\jail_Locate\WebRoot\WEB-INF\classes\applicationContext-common.xml]: Invocation of init method failed; nested exception is java.lang.UnsupportedClassVersionError: Bad version number in .class fileCaused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [E:\workspace\jail_Locate\WebRoot\WEB-INF\classes\applicationContext-common.xml]: Invocation of init method failed; nested exception is java.lang.UnsupportedClassVersionError: Bad version number in .class fileCaused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file    at java.lang.ClassLoader.defineClass1(Native Method)    at java.lang.ClassLoader.defineClass(Unknown Source)    at java.security.SecureClassLoader.defineClass(Unknown Source)    at java.net.URLClassLoader.defineClass(Unknown Source)    at java.net.URLClassLoader.access$100(Unknown Source)    at java.net.URLClassLoader$1.run(Unknown Source)    at java.security.AccessController.doPrivileged(Native Method)    at java.net.URLClassLoader.findClass(Unknown Source)    at java.lang.ClassLoader.loadClass(Unknown Source)    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)    at java.lang.ClassLoader.loadClass(Unknown Source)    at java.lang.ClassLoader.loadClassInternal(Unknown Source)    at java.lang.Class.forName0(Native Method)    at java.lang.Class.forName(Unknown Source)    at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:57)    at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)    at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)    at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:410)    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1203)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:267)    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)    at com.telezone.jail.servicesImplTestCase.UserinfoImplTestCase.testSaveUserinfo(UserinfoImplTestCase.java:16)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)    at java.lang.reflect.Method.invoke(Unknown Source)    at junit.framework.TestCase.runTest(TestCase.java:168)    at junit.framework.TestCase.runBare(TestCase.java:134)    at junit.framework.TestResult$1.protect(TestResult.java:110)    at junit.framework.TestResult.runProtected(TestResult.java:128)    at junit.framework.TestResult.run(TestResult.java:113)    at junit.framework.TestCase.run(TestCase.java:124)    at junit.framework.TestSuite.runTest(TestSuite.java:232)    at junit.framework.TestSuite.run(TestSuite.java:227)    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
  相关解决方案