Struts 2.3.15.2 org.apache.struts2.tiles.StrutsTilesListener的异常

时间:2013-10-16 18:39:07

标签: struts2 struts2-tiles-plugin

我从Struts 2.0.8 升级到 2.3.15.2

启动apache tomcat服务器时出现以下错误。

异常将上下文初始化事件发送到类org.apache.struts2.tiles.StrutsTilesListener的侦听器实例

**INFO: Starting Servlet Engine: Apache Tomcat/6.0.33
Oct 16, 2013 1:03:07 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class 
org.apache.struts2.tiles.StrutsTilesListener
java.lang.NullPointerException
at org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058)
at org.apache.commons.digester.Digester.parse(Digester.java:1887)
at     org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(DigesterDefinitionsReader.java:267)**


我在WEB-INF / lib文件夹中使用以下jar文件

commons-beanutils-1.8.0.jar
commons-codec-1.6.jar
commons-collections-3.1.jar
commons-dbcp.jar
commons-digester-2.0.jar
commons-fileupload-1.3.jar
commons-io-2.0.1.jar
commons-lang-2.4.jar
commons-logging-1.1.3.jar
commons-pool-1.6.jar
crimson.jar
displaytag-1.1.jar
displaytag-export-poi-1.1.jar
fluent-hc-4.2.3.jar
freemarker-2.3.19.jar
httpclient-4.2.3.jar
httpclient-cache-4.2.3.jar
httpcore-4.2.2.jar
httpmime-4.2.3.jar
itext-2.0.4.jar
javax.mail_1.4.0.v201005080615.jar
jstl.jar
log4j-12.jar
mail.jar
ognl-3.0.6.jar
ojdbc6.jar
poi-3.0.1-FINAL-20070705.jar
standard.jar
struts2-core-2.3.15.2.jar
struts2-tiles3-plugin-2.3.15.2.jar
struts2-tiles-plugin-2.3.15.2.jar
struts-core-1.3.10.jar
tiles-api-2.0.6.jar
tiles-core-2.0.6.jar
tiles-jsp-2.0.6.jar
xwork-core-2.3.15.2.jar


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

<display-name>My Web Application</display-name>

<filter>
    <filter-name>struts-cleanup</filter-name>
    <filter-class>
        org.apache.struts2.dispatcher.ActionContextCleanUp
    </filter-class>
</filter>

<filter-mapping>
    <filter-name>struts-cleanup</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

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

<filter>
    <filter-name>ResponseOverrideFilter</filter-name>
    <filter-class>
        org.displaytag.filter.ResponseOverrideFilter
    </filter-class>
</filter>

<filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>

<listener>
    <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>

<listener>
    <listener-class>com.comp.ccra.listener.CCRAContextListener</listener-class>
</listener>

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>


struts.xml中     

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package name="ccra" extends="struts-default" >
    <interceptors>
        <interceptor name="login" class="com.comp.ccra.action.interceptor.LoginInterceptor"/>
        <interceptor-stack name="defaultLoginStack">
            <interceptor-ref name="login"></interceptor-ref>
            <interceptor-ref name="defaultStack"></interceptor-ref>
        </interceptor-stack>
    </interceptors> 
    <!-- Make the defaultLoginStack the default one used
     for all actions unless otherwise configured. -->
    <default-interceptor-ref name="defaultLoginStack" />
    <global-results>
        <result name="exception">/WEB-INF/jsp/exception.jsp</result>
    </global-results>       
    <global-exception-mappings>
        <exception-mapping exception="org.apache.tomcat.dbcp.dbcp.SQLNestedException" result="exception"/>
        <exception-mapping exception="javax.servlet.ServletException" result="exception"/>
        <exception-mapping exception="java.sql.SQLException" result="exception"/>
        <exception-mapping exception="java.lang.Exception" result="exception"/>
    </global-exception-mappings>
 </package>
<include file="struts-filedownload.xml" />
<include file="struts-fileupload.xml" />
<include file="struts-common.xml" />
<include file="struts-report.xml" />
<include file="struts-admin.xml" />
</struts>


TILES.xml     

<!DOCTYPE tiles-definitions PUBLIC
   "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
   "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<!-- Definitions for Tiles documentation   -->

<tiles-definitions>

<!-- =======================================================  -->
<!-- Master definition                      -->
<!-- =======================================================  -->

<definition name="basicLayout" template="/WEB-INF/tiles/layout/basicLayout.jsp">
<put-attribute name="title"  value="Call Center Connection (C3)"/>
<put-attribute name="header" type="template" value="/WEB-INF/tiles/layout/header.jsp"/>
<put-attribute name="navigation" type="template" value="/WEB-INF/tiles/layout/navigation.jsp"/>
<put-attribute name="body" type="template" value="/WEB-INF/tiles/layout/empty.jsp"/>
<put-attribute name="info" type="template" value="/WEB-INF/tiles/layout/info.jsp"/>
<put-attribute name="footer" type="template" value="/WEB-INF/tiles/layout/footer.jsp"/>
</definition>

<definition name="homePage" extends="basicLayout" >
</definition>

</tiles-definitions>



如果我在这里做错了,请建议。任何帮助是极大的赞赏。

1 个答案:

答案 0 :(得分:2)

您不能混用两个不同的Tiles版本,使用struts2-tiles3-plugin-2.3.15.2.jarstruts2-tiles-plugin-2.3.15.2.jar

并根据Tiles版本遵循文档:

http://struts.apache.org/release/2.3.x/docs/tiles-plugin.html   http://struts.apache.org/release/2.3.x/docs/tiles-3-plugin.html