hibernate.cfg.xml 加载映射文件有,tomcat无法启动
<property name="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</property>
<property name="hibernate.show_sql">true</property>
<mapping resource="com/pro/models/Users.hbm.xml" />
<mapping resource="com/pro/models/Admin.hbm.xml" />
<mapping resource="com/pro/models/Car.hbm.xml" />
<mapping resource="com/pro/vo/UsercarCar.hbm.xml" /> //加入这一行就会出错,这个是视图
出错信息:
ERROR (org.springframework.web.context.ContextLoader:215) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext_user.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
UsercarCar.hbm.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping package="com.pro.vo">
<class name="UsercarCar" table="usercarcar" lazy="false">
<id name="mid">
<generator class="native"></generator>
</id>
<property name="carid" type="java.lang.String">
<column name="carid" length="50" />
</property>
<property name="userid" type="java.lang.String">
<column name="userid" length="50" />
</property>
<property name="gpssn" type="java.lang.String">
<column name="gpssn" length="12" />
</property>
<property name="minv" type="java.lang.Short">
<column name="minv" />
</property>
<property name="sim" type="java.lang.String">
<column name="sim" length="50" />
</property>
<property name="creattime" type="java.sql.Timestamp">
<column name="creattime" length="23" />
</property>
<property name="authphones" type="java.lang.String">
<column name="authphones" length="50" />
</property>
<property name="rectregions" type="java.lang.String">
<column name="rectregions" length="50" />
</property>
<property name="name" type="java.lang.String">
<column name="name" length="50" />
</property>
<property name="location" type="java.lang.String">
<column name="location" length="50" />
</property>
<property name="gprsLasttime" type="java.sql.Timestamp">
<column name="GPRS_lasttime" length="23" />
</property>
<property name="gpsLasttime" type="java.sql.Timestamp">
<column name="GPS_lasttime" length="23" />
</property>
<property name="fixdata" type="java.lang.String">
<column name="fixdata" length="50" />
</property>
<property name="carmid" type="java.lang.Long">
<column name="carmid" />
</property>
<property name="curpostime" type="java.lang.String">
<column name="curpostime" length="17" />
</property>
<property name="latitude" type="java.lang.String">
<column name="latitude" length="12" />
</property>
<property name="longitude" type="java.lang.String">
<column name="longitude" length="10" />
</property>
<property name="speed" type="java.lang.String">
<column name="speed" length="5" />
</property>
<property name="mileage" type="java.lang.String">
<column name="mileage" length="16" />
</property>
<property name="acctime" type="java.lang.String">
<column name="acctime" length="8" />
</property>
<property name="code" type="java.lang.String">
<column name="code" length="10" />
</property>
<property name="direction" type="java.lang.String">
<column name="direction" length="5" />
</property>
<property name="overspeed" type="java.lang.Short">
<column name="overspeed" />
</property>
<property name="flag" type="java.lang.String">
<column name="flag" length="8" />
</property>
<property name="property" type="java.lang.String">
<column name="property" length="8" />
</property>
<property name="fuel" type="java.lang.String">
<column name="fuel" length="4" />
</property>
<property name="gpstype" type="java.lang.String">
<column name="gpstype" length="2" />
</property>
</class>
</hibernate-mapping>
[解决办法]
你确定你的视图有主键?
[解决办法]
检查UsercarCar.hbm.xml与对应的实体类UsercarCar里面的字段是否一一对应,并且有相应的get/set方法
[解决办法]
lib中有没有 javassist.jar ?
如果有,那么是你的hbm.xml出错了
记得 bean类,一定要有默认的构造函数,即不带参数的构造函数
[解决办法]
检查UsercarCar.hbm.xml与对应的实体类UsercarCar里面的字段是否一一对应
我的异常网推荐解决方案:Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer],http://www.myexception.cn/eclipse/174629.html