我使用的是struts 2.2.1和tiles 2.2.2。我做每一個步驟描述here,但我不能讓瓷磚工作...我得到,同時部署了以下錯誤我的戰爭GlassFish的3.1:Tiles與Struts2搭配使用的問題
[#|2011-10-04T08:43:28.117+0200|SEVERE|glassfish3.1|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=74;_ThreadName=AutoDeployer;|Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: org.apache.struts2.tiles.StrutsTilesListener
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:130)
在我的WEB-INF/lib中我有commons- collections-3.1.jar,commons-fileupload-1.2.1.jar,struts2-core-2.2.1.jar,tiles-api-2.2.2.jar,tiles-core-2.2.2.jar,tiles-jsp- 2.2.2.jar和xwork-core-2.2.1.jar。
這是我的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>
<constant name="struts.devMode" value="true" />
<package name="basicstruts2" extends="struts-default">
<interceptors>
<interceptor-stack name="appDefault">
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">ERROR</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="appDefault" />
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<global-results>
<result name="exception">/jsp/exceptions/exception.jsp</result>
<result name="webServiceException">/jsp/exceptions/webserviceexception.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="exception" />
<exception-mapping exception="java.io.IOException" result="exception" />
<exception-mapping exception="exceptions.WebServiceExceptionForStruts"
result="webServiceException" />
</global-exception-mappings>
<action name="tilesTest" class="test.action.TilesTest">
<result name="success" type="tiles">/welcome.tiles</result>
</action>
<action name="index">
<result>/jsp/index.jsp</result>
</action>
</package>
</struts>
插入代碼到我的struts.xml後,我在日食出現此錯誤:
這是我的網頁。 xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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>Consumer</display-name>
<welcome-file-list>
<welcome-file>/jsp/index.jsp</welcome-file>
</welcome-file-list>
<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>
<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>
</web-app>
非常感謝!
我已經添加了Struts2的瓷磚,插件-2.2.1.jar和糾正在struts.xml中的順序。 IDE錯誤消失了,但ClassDefNotFound仍然存在(現在在另一個點):[#| 2011-10-04T23:39:35.690 + 0200 | SEVERE | glassfish3.1 | org.apache.catalina.core.ContainerBase | _ThreadID = 17; _ThreadName = AutoDeployer; | ContainerBase.addChild:start: org.apache.catalina.LifecycleException:java.lang.IllegalArgumentException:java.lang.NoClassDefFoundError:org/apache/tiles/web/startup/TilesListener \t在org.apache.catalina.core.StandardContext.start(StandardContext.java:5271) – strauberry
我的第一個假設是要實際檢查[tiles tiles插件使用的tiles版本](http://mvnrepository.com/artifact/ org.apache.struts/Struts2的瓷磚,插件/ 2.2.1)。這會讓我相信你是混合和匹配不兼容的版本。 –
好的一個:-)依賴關係是「邪惡的一部分」。但是有很多依賴......我會看看maven ^^非常感謝您的幫助! – strauberry