部署时无法找到Struts调度程序

时间:2014-07-29 11:51:18

标签: java spring jsp struts2 weblogic

当我尝试在WL Server 9.2上运行我的Spring + Struts 2项目时(我必须使用此版本,所以请不要让我使用较新版本的WL服务器),我有这个错误。

浏览器中的URL地址为:

http://localhost:7003/SpringStrust2/

完整的堆栈跟踪:

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)

这是我的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>

我非常确定将文件放在正确的文件夹中,包括lib文件夹中的jar库......

以下是我使用的罐子列表:

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

2 个答案:

答案 0 :(得分:0)

你正在点击User.jsp文件(带有S2标签)而没有像错误那样运行一个动作。

你可以:

  • 从欢迎文件重定向到Struts操作(一种常见的技术,而且很简单)
  • 配置容器以允许操作为欢迎文件
  • 从欢迎文件中删除S2标记

答案 1 :(得分:0)

我遇到了同样的问题。我的Struts 2应用程序在localhost上运行,就像黄油刀一样,但是在VPS上运行失败了。最后解决方案是项目中的Web-Inf文件夹与Tomcat的web-inf文件夹冲突。

将您的project / web-inf / web.xml内容移动到 usr / local / easy / share / easy-tomcat7 / conf(适用于Cent OS)

并将您的jar从youtproject / web-inf / lib移至 usr / local / easy / share / easy-tomcat7 / lib(适用于Cent OS)

对于其他操作系统,请在相应的路径上执行相同的操作..

希望这会有所帮助..