ryman1981
Mar 31st, 2008, 11:53 PM
Hello,I have a problem about integrate Hibernate3.2,Spring2.5 and Struts2.0 .
when i integrate them, my tomcat5.5 can not start my application.
Can you help me ?Thanks a lot!
This is my web.xml
<code>
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>
</web-app>
</code>
and this is my applicationContext.xml .
My User.hbm.xml is in the directory of web-inf/classes/com/cpic/xj/user/
<code>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerD ataSource"
destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/dev;SHUTDOWN=true
</value>
</property>
<property name="username" value="root" />
<property name="password" value="nihao123" />
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFac toryBean">
<property name="dataSource" ref="myDataSource" />
<property name="mappingResources">
<list>
<value>com/cpic/xj/user/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.pool_size">0</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>
</beans>
</code>
this is my User.hbm.xml
<code>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.cpic.xj.user" >
<class name="User" table="oc_user">
<id name="id" column="id" type="long">
<generator class="native" />
</id>
<property name="userId" column="userid" type="string" unique="true" />
<property name="passWord" column="pwd" type="string" not-null="true" length="12" />
<property name="userName" column="username" type="string" not-null="true" />
<property name="email" column="email" type="string" />
<property name="address" column="address" type="string" not-null="true" />
<property name="phone" column="phone" type="string" not-null="true" />
<property name="cell" column="cell" type="string" />
<property name="zipcode" column="zipcode" type="string" />
</class>
</hibernate-mapping>
</code>
this is my lib list
http://www.xjcpic.cn/yyyy.jpg
when i integrate them, my tomcat5.5 can not start my application.
Can you help me ?Thanks a lot!
This is my web.xml
<code>
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>
</web-app>
</code>
and this is my applicationContext.xml .
My User.hbm.xml is in the directory of web-inf/classes/com/cpic/xj/user/
<code>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerD ataSource"
destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/dev;SHUTDOWN=true
</value>
</property>
<property name="username" value="root" />
<property name="password" value="nihao123" />
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFac toryBean">
<property name="dataSource" ref="myDataSource" />
<property name="mappingResources">
<list>
<value>com/cpic/xj/user/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.pool_size">0</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>
</beans>
</code>
this is my User.hbm.xml
<code>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.cpic.xj.user" >
<class name="User" table="oc_user">
<id name="id" column="id" type="long">
<generator class="native" />
</id>
<property name="userId" column="userid" type="string" unique="true" />
<property name="passWord" column="pwd" type="string" not-null="true" length="12" />
<property name="userName" column="username" type="string" not-null="true" />
<property name="email" column="email" type="string" />
<property name="address" column="address" type="string" not-null="true" />
<property name="phone" column="phone" type="string" not-null="true" />
<property name="cell" column="cell" type="string" />
<property name="zipcode" column="zipcode" type="string" />
</class>
</hibernate-mapping>
</code>
this is my lib list
http://www.xjcpic.cn/yyyy.jpg