Struts2 tiles org.apache.struts2.tiles.StrutsTilesListener NullPointerException错误

时间:2013-10-10 06:31:19

标签: java jsp tomcat struts2 tiles

我正在尝试使用Tiles和Tomcat服务器运行我的Struts2项目,但我无法让它工作。

我已经查看了两者的文档,我认为我做得对。这是我的文件:  的web.xml

<display-name>Struts2_Application</display-name>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<context-param>
<param-name>tilesDefinitions</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>

<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<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>
   <package name="default" extends="struts-default">
      <result-types>
         <result-type name="tiles" 
         class="org.apache.struts2.views.tiles.TilesResult" />
      </result-types>


      <action name="*Menu" method="{1}" 
         class="com.greensun.struts2.tiles.action.MenuAction">
         <result name="tiger" type="tiles">tiger</result>
         <result name="lion" type="tiles">lion</result>
      </action>

   </package>
</struts>

MenuAction.java

public class MenuAction extends ActionSupport {

/**
 * 
 */
/*private static final long serialVersionUID = 1L;
@Override
public String execute() throws Exception {
    // TODO Auto-generated method stub
    return "tiger";
}*/

public String tiger() { return "tiger"; }
public String lion() { return "lion"; }
  }

当我尝试运行该项目时,我收到此错误:

  

org.apache.catalina.core.StandardContext listenerStart Critical:Class   org.apache.struts2.tiles.StrutsTilesListener发送上下文的异常   初始化事件到侦听器实例   java.lang.NullPointerException at   org.apache.tiles.context.ChainedTilesContextFactory.createApplicationContext(ChainedTilesContextFactory.java:107)   在   org.apache.struts2.tiles.StrutsTilesContainerFactory $ StrutsTilesContextFactory.createApplicationContext(StrutsTilesContainerFactory.java:98)   在   org.apache.struts2.tiles.StrutsTilesContainerFactory.initializeContainer(StrutsTilesContainerFactory.java:68)   在   org.apache.tiles.factory.TilesContainerFactory.createTilesContainer(TilesContainerFactory.java:199)   在   org.apache.tiles.factory.TilesContainerFactory.createContainer(TilesContainerFactory.java:164)   在   org.apache.tiles.listener.TilesListener.createContainer(TilesListener.java:91)   在   org.apache.struts2.tiles.StrutsTilesListener.createContainer(StrutsTilesListener.java:66)   在   org.apache.tiles.listener.TilesListener.contextInitialized(TilesListener.java:58)   在   org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)   在   org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)   在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)   在   org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)   在   org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)   在   org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)   在   org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)   在   org.apache.catalina.startup.HostConfig $ DeployDescriptor.run(HostConfig.java:1635)   at java.util.concurrent.Executors $ RunnableAdapter.call(Unknown Source)   在java.util.concurrent.FutureTask.run(未知来源)at   java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)at   java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源)at   java.lang.Thread.run(未知来源)

     

我确定我做的事情非常愚蠢,但我自己也看不到。   任何人吗?

0 个答案:

没有答案