啥原因

FreezingCoffin 2012-06-05 12:18:50
严重: 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>不把错 加了就报错
...全文
203 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
FreezingCoffin 2012-06-05
  • 打赏
  • 举报
回复
补充:
<bean id="CartProductDaoService" class="com.shen.ec.service.impl.CreateOrderServiceImpl">
<property name="dao">
<ref local="productQueryDao" />
</property>
</bean>


好像这段出问题了 注释掉就不报错了
FreezingCoffin 2012-06-05
  • 打赏
  • 举报
回复
严重: 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 'CartProductDaoService' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.shen.ec.dao.impl.ProductQueryDAOImpl] to required type [com.shen.ec.dao.OrderDao] for property 'dao'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.shen.ec.dao.impl.ProductQueryDAOImpl] to required type [com.shen.ec.dao.OrderDao] for property 'dao': no matching editors or conversion strategy found
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.shen.ec.dao.impl.ProductQueryDAOImpl] to required type [com.shen.ec.dao.OrderDao] for property 'dao'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.shen.ec.dao.impl.ProductQueryDAOImpl] to required type [com.shen.ec.dao.OrderDao] for property 'dao': no matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [com.shen.ec.dao.impl.ProductQueryDAOImpl] to required type [com.shen.ec.dao.OrderDao] for property 'dao': no matching editors or conversion strategy found

这又是什么原因
py911118 2012-06-05
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]

com.shen.ec.entity.CartItem 是没映射。。。在applicationContext里配好了就OK
[/Quote]
可能是CartItem.hbm.xml 根本就没有这个文件 - -
py911118 2012-06-05
  • 打赏
  • 举报
回复
com.shen.ec.entity.CartItem 是没映射。。。在applicationContext里配好了就OK
FreezingCoffin 2012-06-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

你order.hbm.xml文件中com.shen.ec.entity.CartItem配置错误。
[/Quote]

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


木有用 还是老样子
FreezingCoffin 2012-06-05
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

order.hbm.xml你这个映射配置再检查检查,感觉像是映射类的时候出错了
[/Quote]



<one-to-many class="CartItem"/>这句有错?
古布 2012-06-05
  • 打赏
  • 举报
回复
<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"/>

========================================================
type="integer" ==> type="java.lang.Integer"
type="string" ==> type="java.lang.String"


cao447214075 2012-06-05
  • 打赏
  • 举报
回复
你order.hbm.xml文件中com.shen.ec.entity.CartItem配置错误。
Think.Chen 2012-06-05
  • 打赏
  • 举报
回复
order.hbm.xml你这个映射配置再检查检查,感觉像是映射类的时候出错了
cxw3152 2012-06-05
  • 打赏
  • 举报
回复
CartItem
配置有问题。。
古布 2012-06-05
  • 打赏
  • 举报
回复
[com.shen.ec.dao.impl.ProductQueryDAOImpl] 没有 extends/implements[com.shen.ec.dao.OrderDao] 吧。

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧