java DefaultListableBeanFactory 抛出异常

lucasli 发布于 2011/10/07 16:48
阅读 1K+
收藏 0

今天在hibernate里面增加了一个hbm和一个bean,结果直接引起DefaultListableBeanFactory抛出异常,异常信息如下:

applicationContext.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:jaxws="http://cxf.apache.org/jaxws"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

   
   
   
   
    <context:annotation-config />
    <context:component-scan base-package="com.netlog" />
   
    <bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:../config/config.properties</value>
            </list>
        </property>
    </bean>

    <!-- 数据库连接池配置 -->
  <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${dataSource.driverClass}" />
    <property name="jdbcUrl" value="${dataSource.jdbcUrl}" />
    <property name="user" value="${dataSource.user}" />
    <property name="password" value="${dataSource.password}" />
    <!-- 连接池中保留的最小连接数 -->
    <property name="minPoolSize" value="10" />
    <!-- 连接池中保留的最大连接数 -->
    <property name="maxPoolSize" value="50" />
    <!-- 初始化时获取5个连接,取值应在minPoolSize与maxPoolSize之间 -->
    <property name="initialPoolSize" value="10" />
    <!-- 最大空闲时间,3000秒内未使用则连接被丢弃。若为0则永不丢弃 -->
    <property name="maxIdleTime" value="3000" />
    <property name="loginTimeout" value="5000" />
    <!-- 当连接池中的连接耗尽的时候c3p0一次同时获取的连接数 -->
    <property name="acquireIncrement" value="5" />
    <!-- 每30秒检查所有连接池中的空闲连接 -->
    <property name="idleConnectionTestPeriod" value="30" />
    <!-- 当连接池用完时客户端调用getConnection()后等待获取新连接的时间 0为无限期等待 -->
    <property name="checkoutTimeout" value="6000" />
  </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocations">
            <list>
                <value>classpath*:hibernate.cfg.xml</value>
            </list>
        </property>
        <!--<property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property> -->
    </bean>

    <bean id="hibernateTemplate"
        class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

    <bean id="txManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
     
    <tx:annotation-driven transaction-manager="txManager" />

    <import resource="quartz.xml"/>
    <import resource="classpath*:**/netlog-dao.xml" />
    <import resource="classpath*:**/netlog-service.xml" />

</beans>

hibernate.cfg.xml内容如下:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
    <property name="connection.driver_class">
        com.mysql.jdbc.Driver
    </property>
    <property name="hibernate.query.substitutions">
        true 1,false 0
    </property>

    <property name="show_sql">true</property>
    <property name="dialect">
        org.hibernate.dialect.MySQLDialect
    </property>
    <property name="hibernate.cache.use_second_level_cache">
        false
    </property>
    <mapping resource="com/netlog/pojo/TCategoryGroup.hbm.xml" />
    <mapping resource="com/netlog/pojo/TCategory.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmData.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmFilter.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmItem.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmDefine.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmKnowledge.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmLevel.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmStyle.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmTemplate.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmTemplateItem.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmType.hbm.xml" />
    <mapping resource="com/netlog/pojo/TAlarmTypeDefine.hbm.xml" />
    <mapping resource="com/netlog/pojo/TOperateObject.hbm.xml" />
    <mapping resource="com/netlog/pojo/TGroup.hbm.xml" />
    <mapping resource="com/netlog/pojo/THost.hbm.xml" />
    <mapping resource="com/netlog/pojo/THostCategory.hbm.xml" />
    <mapping resource="com/netlog/pojo/THostGroup.hbm.xml" />
    <mapping resource="com/netlog/pojo/THostType.hbm.xml" />
    <mapping resource="com/netlog/pojo/TOidDesc.hbm.xml" />
    <mapping resource="com/netlog/pojo/TOperateLogs.hbm.xml" />
    <mapping resource="com/netlog/pojo/TResourceMonitor.hbm.xml" />
    <mapping resource="com/netlog/pojo/TRole.hbm.xml" />
    <mapping resource="com/netlog/pojo/TSyslog.hbm.xml" />
    <mapping resource="com/netlog/pojo/TWinevent.hbm.xml" />
    <mapping resource="com/netlog/pojo/TPreference.hbm.xml" />
    <mapping resource="com/netlog/pojo/TUser.hbm.xml" />
    <mapping resource="com/netlog/pojo/TUserGroup.hbm.xml" />
    <mapping resource="com/netlog/pojo/TSystemCommand.hbm.xml" />
    <mapping resource="com/netlog/pojo/TSystemProcess.hbm.xml" />
    <mapping resource="com/netlog/pojo/TSnmpTrap.hbm.xml" />
</session-factory>
</hibernate-configuration>

新增的TCategoryGroup.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.netlog.pojo">
    <class name="TCategoryGroup" table="t_category_group">
     <id name="id" type="java.lang.Long">
     <column name="ID" />
      <generator class="assigned"/>
     </id>
     <property name="name" type="java.lang.String">
      <column length="64" name="NAME"/>
     </property>
     <property name="valid" type="java.lang.Integer">
      <column name="VALID"/>
     </property>
    </class>
</hibernate-mapping>

新增的TCategory.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.netlog.pojo">
 <class name="TCategory" table="t_category">
  <id name="id" type="java.lang.Long">
   <column name="id"/>
   <generator class="assigned"/>
  </id>
  <property column="group_id" generated="never" lazy="false"
   name="groupId" type="java.lang.Integer">
   <column name="group_id"/>
  </property>
  <property generated="never" lazy="false" name="name" type="java.lang.String">
   <column length="64" name="name"/>
  </property>
  <property generated="never" lazy="false" name="component" type="java.lang.String">
   <column name="component"/>
  </property>
  <property generated="never" lazy="false" name="status" type="java.lang.Integer">
   <column name="status"/>
  </property>
  <property generated="never" lazy="false" name="icon" type="java.lang.String">
   <column length="64" name="icon"/>
  </property>
  <property generated="never" lazy="false" name="firstVersion" type="java.lang.Integer">
   <column name="first_version"/>
  </property>
  <property generated="never" lazy="false" name="secondVersion" type="java.lang.Integer">
   <column name="second_version"/>
  </property>
  <property generated="never" lazy="false" name="remark" type="java.lang.String">
   <column length="64" name="remark"/>
  </property>
 </class>
</hibernate-mapping>

这两个表定义如下:
drop table if exists `t_category_group`;
create table `t_category_group`
(
    `id` int(11) not null,
    `name` varchar(64) not null,
    `valid` tinyint default 1 #1:enable,0:disable
)ENGINE=InnoDB DEFAULT CHARSET=gbk;

/*
 table structure for table `t_category`
*/

drop table if exists `t_category`;
create table `t_category`
(
    `id` int(11) not null,
    `group_id` int(11) not null,
    `name` varchar(64) not null,
    `component` varchar(255),
    `status` tinyint default 2, #0:disable 1:running 2:stop
    `icon` varchar(255),
    `first_version` tinyint default 1,
    `second_version` tinyint default 0,
    `remark` varchar(255)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;

java 类定义如下:

public abstract class AbstractTCategory implements
        java.io.Serializable {

    // Fields

    private Long id;
    private Integer groupId;
    private String name;
    private String component;
    private Integer status;
    private String icon;
    private Integer firstVersion;
    private Integer secondVersion;
    private String remark;
    private Integer selected;

    // Constructors
    public AbstractTCategory() {
       
    }
    /** minimal constructor */
    public AbstractTCategory(Long id, Integer groupId, String name, String component,
            Integer status, String icon,
            Integer firstVersion, Integer secondVersion,
            String remark, Integer selected) {
        this.id = id;
        this.groupId = groupId;
        this.name = name;
        this.component = component;
        this.status = status;
        this.icon = icon;
        this.firstVersion = firstVersion;
        this.secondVersion = secondVersion;
        this.remark = remark;
        this.selected = selected;
    }

    public AbstractTCategory(Long id) {
        this.id = id;
    }
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    public Integer getGroupId() {
        return groupId;
    }
   
    public void setGroupId(Integer groupid) {
        this.groupId = groupid;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getComponent() {
        return component;
    }

    public void setComponent(String component) {
        this.component = component;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public Integer getFirstVersion() {
        return firstVersion;
    }

    public void setFirstVersion(Integer firstVersion) {
        this.firstVersion = firstVersion;
    }

    public Integer getSecondVersion() {
        return secondVersion;
    }

    public void setSecondVersion(Integer secondVersion) {
        this.secondVersion = secondVersion;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getSelected() {
        return selected;
    }

    public void setSelected(Integer selected) {
        this.selected = selected;
    }



}
public abstract class AbstractTCategoryGroup implements
        java.io.Serializable {

    // Fields

    private Long id;
    private String name;
    private Integer valid;

    // Constructors

    /** default constructor */
    public AbstractTCategoryGroup() {
       
    }
    public AbstractTCategoryGroup(Long id, String name, Integer valid) {
        this.id = id;
        this.name = name;
        this.valid = valid;
    }

    public AbstractTCategoryGroup(Long id) {
        this.id = id;
    }
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
   
    public Integer getValid() {
        return this.valid;
    }

    public void setValid(Integer valid) {
        this.valid = valid;
    }

}

我对hibernate不太懂,这些配置完全在别人做好的基础上修改的,在网上查了一些资料大多是里面大小写的问题,但是我并没有看出里面有哪些大小写出错了。

恳请高手指点,多谢多谢了。。。

加载中
0
lucasli
lucasli
也不知道怎么摆置摆置,问题就解决了,唉,,
返回顶部
顶部