我测试过,原因是在applicationContext.xml加了hibernate映射类配置的时候出错。去掉配置就好了。
但是映射文件是用myeclipse自动生成的。spring配置文件:<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@192.168.0.80:1521:testdb">
</property>
<property name="username" value="test"></property>
<property name="password" value="test"></property>
<!-- 最大活动连接数 -->
<property name="maxActive" value="100"></property>
<!-- 最大可空闲连接数 -->
<property name="maxIdle" value="30"></property>
<!-- 最大可等待连接数 -->
<property name="maxWait" value="500"></property>
<!-- 默认的提交方式(如果不需要事务可以设置成true,在实际应用中一般设置为false,默认为false) -->
<property name="defaultAutoCommit" value="true"></property>
</bean>
<!-- JNDI
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/mysql</value>
</property>
</bean>
-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/topinfo/sg/hibernate/JbpmTaskinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmSwimlane.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmBytearray.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmIdMembership.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmComment.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmDelegation.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmNode.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmEvent.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmAction.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmLog.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmProcessdefinition.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmExceptionhandler.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmVariableaccess.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmIdGroup.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmPooledactor.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmModuleinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTask.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmRuntimeaction.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmModuledefinition.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmSwimlaneinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTokenvariablemap.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmIdUser.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmVariableinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTaskcontroller.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTransition.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmToken.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTaskactorpool.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmProcessinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmJob.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmByteblock.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmDecisionconditions.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmIdPermissions.hbm.xml</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
</beans>web.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
<!-- web日志配置 BEGIN -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<!-- web日志配置 END -->
<!-- spring配置 BEGIN -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- spring配置 END -->
<!-- struts2配置 BEGIN -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,../struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- struts2配置 END --> <!-- 字符过滤 BEGIN -->
<filter>
<filter-name>Spring character encoding filter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Spring character encoding filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 字符过滤 END -->
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>pollAndCometEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
错误信息:
[main]20100826;11:27:38,927;ERROR;web.context.ContextLoader;Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at
后面错误,因为字数太多显示不了,我就不写了
但是映射文件是用myeclipse自动生成的。spring配置文件:<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@192.168.0.80:1521:testdb">
</property>
<property name="username" value="test"></property>
<property name="password" value="test"></property>
<!-- 最大活动连接数 -->
<property name="maxActive" value="100"></property>
<!-- 最大可空闲连接数 -->
<property name="maxIdle" value="30"></property>
<!-- 最大可等待连接数 -->
<property name="maxWait" value="500"></property>
<!-- 默认的提交方式(如果不需要事务可以设置成true,在实际应用中一般设置为false,默认为false) -->
<property name="defaultAutoCommit" value="true"></property>
</bean>
<!-- JNDI
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/mysql</value>
</property>
</bean>
-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/topinfo/sg/hibernate/JbpmTaskinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmSwimlane.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmBytearray.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmIdMembership.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmComment.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmDelegation.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmNode.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmEvent.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmAction.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmLog.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmProcessdefinition.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmExceptionhandler.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmVariableaccess.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmIdGroup.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmPooledactor.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmModuleinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTask.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmRuntimeaction.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmModuledefinition.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmSwimlaneinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTokenvariablemap.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmIdUser.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmVariableinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTaskcontroller.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTransition.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmToken.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmTaskactorpool.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmProcessinstance.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmJob.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmByteblock.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmDecisionconditions.hbm.xml</value>
<value>com/topinfo/sg/hibernate/JbpmIdPermissions.hbm.xml</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
</beans>web.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
<!-- web日志配置 BEGIN -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<!-- web日志配置 END -->
<!-- spring配置 BEGIN -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- spring配置 END -->
<!-- struts2配置 BEGIN -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,../struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- struts2配置 END --> <!-- 字符过滤 BEGIN -->
<filter>
<filter-name>Spring character encoding filter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Spring character encoding filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 字符过滤 END -->
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>pollAndCometEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
错误信息:
[main]20100826;11:27:38,927;ERROR;web.context.ContextLoader;Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at
后面错误,因为字数太多显示不了,我就不写了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货