廿指緊釦 2010-02-24 14:26 采纳率: 0%
浏览 227
已采纳

ssh2整合问题:error getting ActionMapping,恳求各位大大帮忙看看!!

报错如下:

[framework][2010-02-24 14:14:10][org.springframework.orm.hibernate3.support.OpenSessionInViewFilter][ http-8080-1:20235 ]-[ DEBUG ] Using SessionFactory 'sessionFactory' for OpenSessionInViewFilter
[framework][2010-02-24 14:14:10][org.springframework.beans.factory.support.DefaultListableBeanFactory][ http-8080-1:20235 ]-[ DEBUG ] Returning cached instance of singleton bean 'sessionFactory'
[framework][2010-02-24 14:14:10][org.springframework.orm.hibernate3.support.OpenSessionInViewFilter][ http-8080-1:20344 ]-[ DEBUG ] Opening single Hibernate Session in OpenSessionInViewFilter
[framework][2010-02-24 14:14:10][org.springframework.orm.hibernate3.SessionFactoryUtils][ http-8080-1:20344 ]-[ DEBUG ] Opening Hibernate Session
[framework][2010-02-24 14:14:10][org.hibernate.impl.SessionImpl][ http-8080-1:20485 ]-[ DEBUG ] opened session at timestamp: 12669920506
[framework][2010-02-24 14:14:10][org.hibernate.impl.SessionImpl][ http-8080-1:20485 ]-[ DEBUG ] setting flush mode to: NEVER
[framework][2010-02-24 14:14:10][org.springframework.transaction.support.TransactionSynchronizationManager][ http-8080-1:20501 ]-[ DEBUG ] Bound value [org.springframework.orm.hibernate3.SessionHolder@1049cbf] for key [org.hibernate.impl.SessionFactoryImpl@652f4d] to thread [http-8080-1]
[framework][2010-02-24 14:14:10][org.apache.struts2.dispatcher.FilterDispatcher][ http-8080-1:20516 ]-[ ERROR ] error getting ActionMapping
java.lang.NullPointerException
 at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:393)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Thread.java:619)
[framework][2010-02-24 14:14:10][org.springframework.transaction.support.TransactionSynchronizationManager][ http-8080-1:20532 ]-[ DEBUG ] Removed value [org.springframework.orm.hibernate3.SessionHolder@1049cbf] for key [org.hibernate.impl.SessionFactoryImpl@652f4d] from thread [http-8080-1]
[framework][2010-02-24 14:14:10][org.springframework.orm.hibernate3.support.OpenSessionInViewFilter][ http-8080-1:20532 ]-[ DEBUG ] Closing single Hibernate Session in OpenSessionInViewFilter
[framework][2010-02-24 14:14:10][org.springframework.orm.hibernate3.SessionFactoryUtils][ http-8080-1:20532 ]-[ DEBUG ] Closing Hibernate Session
[framework][2010-02-24 14:14:10][org.hibernate.impl.SessionImpl][ http-8080-1:20532 ]-[ DEBUG ] closing session
[framework][2010-02-24 14:14:10][org.hibernate.jdbc.ConnectionManager][ http-8080-1:20532 ]-[ DEBUG ] connection already null in cleanup : no action

 

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">


 <!-- 加载所有Spring配置文件  开始-->
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
   /WEB-INF/config/applicationContext*.xml
  </param-value>
 </context-param>
 <!-- 加载所有Spring配置文件  结束-->
 <!-- 字符编码过滤器  开始
 <filter>
  <filter-name>encodingFilter</filter-name>
  <filter-class>ws.wskai.filter.EncodingFilter</filter-class>
  <init-param>
   <param-name>encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>encodingFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>-->
 <!-- 字符编码过滤器  结束-->
 <!-- 懒加载过滤器 session到页面才能关  开始-->
 <filter>
  <filter-name>lazyLoadingFilter</filter-name>
  <filter-class>
   org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
  </filter-class>
 </filter>
 <filter-mapping>
  <filter-name>lazyLoadingFilter</filter-name>
  <url-pattern>*.action</url-pattern>
 </filter-mapping>
 <!-- 懒加载过滤器 session到页面才能关  结束-->
 <!-- Struts2总控器(过滤器)  开始-->
 <filter>
  <filter-name>struts2</filter-name>
  <filter-class>
   org.apache.struts2.dispatcher.FilterDispatcher
  </filter-class>
  <init-param>
   <param-name>config</param-name>
   <param-value>../config/struts.xml</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
 <!-- Struts2总控器(过滤器)  结束-->
 <!-- Spring的listener来初始化Context  开始-->
 <listener>
  <listener-class>
   org.springframework.web.context.ContextLoaderListener
  </listener-class>
 </listener>
 <!-- Spring的listener来初始化Context 结束 -->

 <!-- Spring 刷新Introspector防止内存泄露 -->
 <listener>
  <listener-class>
   org.springframework.web.util.IntrospectorCleanupListener
  </listener-class>
 </listener>
 <!-- session超时定义,单位为分钟 -->
 <session-config>
  <session-timeout>20</session-timeout>
 </session-config>


 <!-- 默认启动页面  结束-->
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
 <!-- 默认启动页面  结束 -->
</web-app>

struts.xml配置如下:

 

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
 "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
 <!-- 设置常量,表示把struts交给spring管理 -->
 <constant name="struts.objectFactory"
  value="com.opensymphony.xwork2.ObjectFactory" /><!--把value里面的值改为"spring"就出错,郁闷!!-->

 <package name="admin" extends="struts-default"
  namespace="/jsp/admin">
  <action name="list" class="adminBean" method="select">
   <result>/index.jsp</result>
  </action>
  <action name="addAdmin" class="adminBean" method="add">
   <result>list.action</result>
  </action>
  <action name="deleteAdmin" class="adminBean" method="delete">
   <result>list.action</result>
  </action>
  <action name="deleteByIDAdmin" class="adminBean"
   method="deleteByID">
   <result>list.action</result>
  </action>
  <action name="updateAdmin" class="adminBean" method="update">
   <result>list.action</result>
  </action>
  <action name="selectByIDAdmin" class="adminBean"
   method="selectByID">
   <result>list.action</result>
  </action>
 </package>
</struts>

Spring的三个文件配置如下: 

 

applicationContext-actions.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:p="http://www.springframework.org/schema/p"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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">

 <!-- struts的注入,特别注意,加scope="prototype" -->
 <!-- admin -->
 <bean name="adminBean" class="ws.wskai.action.AdminAction"
  scope="prototype">
  <property name="adminService" ref="adminService" />
 </bean>
</beans>


applicationContext-beans.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:p="http://www.springframework.org/schema/p"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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">

<!-- model层注入   开始-->
 <!--adminDAO-->
 <bean id="adminDAO" class="ws.wskai.dao.impl.AdminDAOImpl">
  <property name="sessionFactory" ref="sessionFactory" />
 </bean>
<!-- model层注入   结束-->

<!-- 服务层的注入   开始-->
 <bean id="adminService"
  class="ws.wskai.service.Impl.AdminServiceImpl">
  <property name="adminDAO" ref="adminDAO" /><!-- name为类里面的注入变量名, ref为引用名,引用路径名 -->
 </bean>
<!-- 服务层的注入   结束-->
</beans>

applicationContext-common.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:p="http://www.springframework.org/schema/p"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:jee="http://www.springframework.org/schema/jee"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
   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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

 <bean id="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName"
   value="com.mysql.jdbc.Driver">
  </property>
  <property name="url"
   value="jdbc:mysql://localhost:3306/music">
  </property>
  <property name="username" value="root"></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.MySQLDialect
    </prop>
    <!-- 允许自动提交 -->
    <prop key="hibernate.connection.autocommit">true</prop>
    <!-- 显示sql语句 -->
    <prop key="hibernate.show_sql">true</prop>
    <!-- 根据hbm.xml 自动修改表结构,当表不存在的时候,还会自动创建表-->
    <prop key="hibernate.hbm2ddl.auto">update</prop>
   </props>
  </property>
  <property name="mappingResources">
   <list>
    <value>ws/wskai/beans/Admin.hbm.xml</value>
    <value>ws/wskai/beans/Users.hbm.xml</value>
    <value>ws/wskai/beans/Visits.hbm.xml</value>
   </list>
  </property>
 </bean>

 <!-- 配置事务管理器(声明式的事务)-->
 <bean id="transactionManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref local="sessionFactory" />
  </property>
 </bean>
 <!-- 配置事务特性方法,配置add、delete、update、query开始的方法,事务传播特性为required -->
 <tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
   <tx:method name="add*" propagation="REQUIRED" />
   <tx:method name="delete*" propagation="REQUIRED" />
   <tx:method name="update*" propagation="REQUIRED" />
   <tx:method name="query*" propagation="REQUIRED" />
   <tx:method name="get*" propagation="REQUIRED" />
   <tx:method name="*" read-only="true" />
  </tx:attributes>
 </tx:advice>
 <!--
  配置那个包下的class,方法接受事务管理
  第一个 *  通配 任意返回值类型
  第二个 *  通配 包ws.wskai.service下的任意class
  第三个 *  通配 包ws.wskai.service下的任意class的任意方法
  第四个 .. 通配 方法可以有0个或多个参数  
  综上:包ws.wskai.service下的任意class的具有任意返回值类型、任意数目参数和任意名称的方法 
 -->
 <aop:config>
  <aop:pointcut id="allManagerMethod"
   expression="execution(* ws.wskai.service.*.*(..))" />
  <aop:advisor advice-ref="txAdvice"
   pointcut-ref="allManagerMethod" />
 </aop:config>
</beans>

  • 写回答

2条回答 默认 最新

  • BearMayCry 2010-02-24 18:09
    关注

    问题可能是出在你的Struts 2没有放入Spring的插件包引起的,在整合的时候会使用到一个整合包[b]struts2-spring-plugin-2.0.11.jar[/b]
    下面是我在SSH整合的时候用到的包列表,你可以做下比较

    antlr-2.7.6.jar
    commons-collections-3.1.jar
    commons-dbcp.jar
    commons-logging-1.0.4.jar
    commons-pool.jar
    dom4j-1.6.1.jar
    freemarker-2.3.8.jar
    hibernate3.jar
    javassist-3.4.GA.jar
    jta-1.1.jar
    log4j.jar
    mysql-connector-java-5.1.5-bin.jar
    ognl-2.6.11.jar
    slf4j-api-1.4.2.jar
    slf4j-log4j12.jar
    spring.jar
    struts2-core-2.0.11.jar
    struts2-spring-plugin-2.0.11.jar
    xwork-2.0.4.jar
    asm-attrs.jar
    asm.jar
    cglib-2.1.3.jar
    ehcache-1.1.jar
    jaas.jar
    jaxen-1.1-beta-7.jar
    jdbc2_0-stdext.jar
    jta.jar
    xerces-2.6.2.jar
    xml-apis.jar

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。