BeanCreationException:创建类路径资源[spring / core / root-context.xml]中定义的名为'transactionManager'的bean时出错

时间:2015-07-16 15:22:11

标签: java spring hibernate maven spring-mvc

我正在开发一个春季的Web应用程序,Hibernate with Maven。当我尝试使用tomcat 8进行部署时,我得到以下异常:

20:39:25.820 [localhost-startStop-1] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [spring/core/root-context.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 class path resource [spring/core/root-context.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: class com.smartwcm.navigation.commons.helperbean.TemplateSelectorHelperBean not found while looking for property: sl_layo_sele_id
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1469) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) ~[spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) ~[spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4720) [catalina.jar:8.0.18]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154) [catalina.jar:8.0.18]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.0.18]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [catalina.jar:8.0.18]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399) [catalina.jar:8.0.18]
    at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_31]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_31]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_31]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring/core/root-context.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: class com.smartwcm.navigation.commons.helperbean.TemplateSelectorHelperBean not found while looking for property: sl_layo_sele_id
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    ... 24 common frames omitted
Caused by: org.hibernate.MappingException: class com.smartwcm.navigation.commons.helperbean.TemplateSelectorHelperBean not found while looking for property: sl_layo_sele_id
    at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:232) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:300) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:449) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:382) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:321) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:172) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    at org.hibernate.cfg.Configuration.add(Configuration.java:771) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:606) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:618) ~[spring-orm-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:189) ~[spring-orm-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    ... 31 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.smartwcm.navigation.commons.helperbean.TemplateSelectorHelperBean
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305) ~[catalina.jar:8.0.18]
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157) ~[catalina.jar:8.0.18]
    at java.lang.Class.forName0(Native Method) ~[na:1.8.0_31]
    at java.lang.Class.forName(Unknown Source) ~[na:1.8.0_31]
    at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:228) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
    ... 42 common frames omitted

我曾尝试多次清理和重新部署,但错误仍然相同。 在错误开始时,将一个类指定为未找到,并且此路径在每个新部署上不断更改。我成功地完成了这个项目直到今天早上,并在重启我的日食后发现了这个问题。我没有对我使用的任何配置进行任何更改,因此我坚信这与任何与项目关联的XML文件都无关。

我的root-context.xml文件的一部分是:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:tx="http://www.springframework.org/schema/tx" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">


<context:property-placeholder location="classpath*:properties/smartwcmAdmin/application.properties"/>


<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="dataSource" ref="dataSource" />
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="dataSource" ref="dataSource" />
</bean>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://*******/*****" />
<property name="username" value="*******" />
<property name="password" value="*******" />
</bean>

<!-- Hibernate session factory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>              

<value>/hibernatemappings/smartwcmAdmin/webcontentdefinition/WebContentDefinition.hbm.xml</value>
<value>/hibernatemappings/smartwcmAdmin/webcontentdefinition/WebContentDefinitionHistory.hbm.xml</value>
<value>/hibernatemappings/smartwcmAdmin/siteproperty/SiteProperty.hbm.xml</value>
<!-- <value>/hibernatemappings/smartwcmAdmin/user/user.hbm.xml</value> -->
</list>
</property>

</bean>
<context:annotation-config />
<context:component-scan base-package="com" />
<tx:annotation-driven/>

<bean id="contextPropertyService" class="com.smartwcm.core.common.property.service.impl.ContextPropertyServiceImpl"> 

</bean>

0 个答案:

没有答案