首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

啥原因解决方法

2013-09-11 
啥原因严重: Exception sending context initialized event to listener instance of class org.springfra

啥原因
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: com.shen.ec.entity.CartItem
Caused by: org.hibernate.MappingException: Association references unmapped class: com.shen.ec.entity.CartItem
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2503)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2782)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1716)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1423)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
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:1201)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)




<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/shoping"></property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>



<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="mappingResources">
<list>
<value>com/shen/ec/entity/user.hbm.xml</value>
<value>com/shen/ec/entity/order.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>


<bean id="userDao" class="com.shen.ec.dao.impl.UserDaoImpl">
<constructor-arg ref="sessionFactory"/>
</bean>
<bean id="userService" class="com.shen.ec.service.impl.UserServiceImpl">
<property name="dao">
<ref bean="userDao" />
</property>
</bean>



 <bean id="orderDao" class="com.shen.ec.dao.impl.OrderDAOImp">
<constructor-arg ref="sessionFactory"/>
</bean>
<bean id="orderDaoService" class="com.shen.ec.service.impl.CreateOrderServiceImpl">
<property name="dao">
<ref bean="orderDao" />
</property>
</bean>

<hibernate-mapping package="com.shen.ec.entity">
<class name="Order" table="d_order">
<id name="id" column="id" type="integer">
<generator class="native"/>
</id>
<property name="orderNo" column="order_no" type="string"/>
<property name="recevieName" column="order_name" type="string"/>
<property name="recevieAddress" column="order_address" type="string"/>
<property name="postCode" column="order_post_code" type="string"/>
<property name="tel" column="order_tel" type="string"/>
<property name="phone" column="order_phone" type="string"/>
<property name="price" column="order_price" type="string"/>
<property name="createDate" column="order_create_date" type="date"/>
<property name="endDate" column="order_end_date" type="date"/>
<property name="orderDesc" column="order_desc" type="string"/> 
<many-to-one lazy="false" name="user" class="User" column="user_id" cascade="save-update"/>
<set lazy="false" name="cartItems" cascade="save-update">
<key column="order_id"></key>
<one-to-many class="CartItem"/>
</set>
</class>
</hibernate-mapping>



不加<value>com/shen/ec/entity/order.hbm.xml</value>不把错 加了就报错

[解决办法]

探讨

com.shen.ec.entity.CartItem 是没映射。。。在applicationContext里配好了就OK

我的异常网推荐解决方案:org.hibernate.MappingException: Association references unmapped class,http://www.myexception.cn/j2ee/326371.html

热点排行