简体   繁体   中英

The Struts dispatcher cannot be found while deploy

When I try to run my Spring + Struts 2 project on WL Server 9.2 (I have to user this version, so please don't ask me to user the newer version of WL Server), I had this error.

The URL address in the browser is :

http://localhost:7003/SpringStrust2/

Full stacktrace:

The Struts dispatcher cannot be found.  This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
at org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
at jsp_servlet.__user._jsp__tag0(__user.java:115)
at jsp_servlet.__user._jspService(User.jsp:12)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3269)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2019)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1925)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1394)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)

Here is my web.xml:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<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>User.jsp</welcome-file>
</welcome-file-list>

struts.xml:

<struts>
<constant name="struts.enble.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="myapp" />

<package name="default" extends="struts-default">
    <action name="user" class="user">
        <result name="success">/success.jsp</result>
        <result name="input">/User.jsp</result>
    </action>
</package>
</struts>

user.jsp:

<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Spring + Struts2</title>
</head>

<body>
    <s:form action="user" method="addUser">
        <s:textfield name="username" key="user.name" />
        <s:submit key="submit" />
    </s:form>
</body>
</html>

I'm very sure about putting files in correct folders, including jar libraries in lib folder...

Here is the list of jars I'm using:

antlr-runtime-3.0.jar 
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-lang3-3.1.jar
commons-logging-1.1.jar
freemarker-2.3.13.jar 
junit-3.8.1.jar 
ornl-2.6.11.jar 
org.springframework.asm-3.9.9.M3.jar
org.springframework.beans-3.0.0.M3.jar
org.springframework.context-3.0.0.M3.jar
org.springframework.core-3.0.0.M3.jar
org.springframework.web-3.0.0.M3.jar
org.springframework.web.servlet-3.0.0.M3.jar
struts2-convention-plugin-2.1.6.jar 
struts2-core-2.1.6.jar
struts2-spring-plugin-2.1.6.jar
xwork-2.1.2.jar

You're hitting the User.jsp file (with its S2 tags) without running through an action like the error says.

You can either:

  • Redirect to a Struts action from the welcome file (a common technique, and trivial)
  • configure the container to allow actions as welcome files
  • Remove the S2 tags from the welcome file

I had the same problem. My Struts 2 application was running on localhost like knife on butter but on VPS it failed. Finally the solution is that Web-Inf folder in project conflicts with web-inf folder of Tomcat.

So move your project/web-inf/web.xml contents to usr/local/easy/share/easy-tomcat7/conf (for Cent OS)

and move your jars from youtproject/web-inf/lib to usr/local/easy/share/easy-tomcat7/lib (for Cent OS)

For other OS do the same at respective path..

Hope this will be helpful..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM