permaculture playing cards*
The moose likes Struts and the fly likes Problem in Struts Dispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem in Struts Dispatcher" Watch "Problem in Struts Dispatcher" New topic
Author

Problem in Struts Dispatcher

leo jacob
Greenhorn

Joined: May 02, 2011
Posts: 17
Hi,

I am new to struts2. I have configured struts2 in eclipse indigo. Now i am trying to run a simple application. I am getting this error. I have pasted the required jar files in lib directory of web-inf folder(commons-logging-1.0.4, freemarker-2.3.16, ognl-3.0, struts2-core-2.2.1.1 and xwork-core-2.2.1.1). Please let me know where am i missing.

Find the error that i am getting. Thanks in advance.




HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: 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]
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:534)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

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]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
org.apache.jsp.index_jsp._jspx_meth_s_005fform_005f0(index_jsp.java:105)
org.apache.jsp.index_jsp._jspService(index_jsp.java:75)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


note The full stack trace of the root cause is available in the Apache Tomcat/7.0.12 logs.

palanisamy subramani
Greenhorn

Joined: Aug 30, 2010
Posts: 29
Could you please give more information, like struts.xml code etc..
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

and also post your web.xml too.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
leo jacob
Greenhorn

Joined: May 02, 2011
Posts: 17
Thanks Mohan and Subramani for the reply. The problem got resolved. It was an issue with web.xml.
Ganiyu Shefiu
Greenhorn

Joined: Dec 17, 2005
Posts: 9
hi Arjun,

i have been battling with same error for days. could you please show me how you resolved it . your web.xml

Thanks for your anticipated response.

Gani
leo jacob
Greenhorn

Joined: May 02, 2011
Posts: 17
Hi Gani,

Check whether your application is able to read web.xml. Make sure your web.xml is in Web-Inf folder. If both the things are ok then paste the error and web.xml with your issue.
Ganiyu Shefiu
Greenhorn

Joined: Dec 17, 2005
Posts: 9
hi Arjun,
thank you for your reply to my post.

Yes my application is able to read web.xml which i placed in web-inf folder.

i am using struts 2.2.3 and glassfish 3.1 is my application server.

below are copies of my files.

thanks and i realy look forward to your reply

Gani
================================================================================
struts.xml

<!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.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/">
<action name="login" class="com.fastech.LoginAction">
<result name="success">Welcome.jsp</result>
<result name="error">Login.jsp</result>
</action>

</package>
</struts>

=======================================================================

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">


<display-name>StrutsHelloWorld</display-name>

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>com.fastech</param-value>
</init-param>

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


<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
</web-app>
===========================================================================

Login.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login</title>
</head>
<body>
<h2>Struts 2 - Login Application</h2>
<s:actionerror />
<s:form action="login.action" method="post">
<s:textfield name="username" key="label.username" size="20" />
<s:password name="password" key="label.password" size="20" />
<s:submit method="execute" key="label.login" align="center" />
</s:form>
</body>

</html>

========================================================================

Welcome.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>
</head>
<body>
<h2>Howdy, <s:property value="username" />...!</h2>
</body>
</html>
===============================================================

LoginAction.java

package com.fastech;

public class LoginAction {
private String username;
private String password;

public String execute() {

if (this.username.equals("admin") && this.password.equals("admin123")) {

return "success";

} else {

return "error";

}

}

public String getUsername() {

return username;

}

public void setUsername(String username) {

this.username = username;

}

public String getPassword() {

return password;

}

public void setPassword(String password) {

this.password = password;

}



}


=================================================================================

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: 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]
root cause

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]
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1 logs.


--------------------------------------------------------------------------------

GlassFish Server Open Source Edition 3.1
Pranav Nakate
Greenhorn

Joined: Aug 29, 2011
Posts: 9
Hi Everyone,

i am facing the same issue,i downloaded struts 2.2.3 , glassfish 3.1 with latest JDK n Eclipse Indigo...

when i am running a sample exception i am getting the following error == HTTP Status 500 - org.apache.jasper.JasperException: The Struts dispatcher...

Below is my web.xml followed by struts.xml .. any help would be gr888...
--------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<display-name>Struts2Validations</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>pkg1.actions</param-value>
</init-param>
</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>

------------------------------------------------

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

<action name="addClient" class="pkg1.action.AddClientAction">
<result name="success">client.jsp</result>
<result name="input">addclient.jsp</result>
</action>

<action name="addEmployee" class="pkg1.action.AddEmployeeAction">
<result name="success">employee.jsp</result>
<result name="input">addemployee.jsp</result>
</action>

<action name="changePassword" class="pkg1.action.ChangePasswordAction" >
<result name="input">changepassword.jsp</result>
<result>changepassword-success.jsp</result>
</action>

<action name="login" class="pkg1.action.LoginAction">
<result name="input">login.jsp</result>
<result name="error">login.jsp</result>
<result name="success">login-success.jsp</result>
</action>

<action name="addUser" class="pkg1.action.AddUserAction">
<result name="input">register.jsp</result>
<result name="error">register.jsp</result>
<result name="success">register-success.jsp</result>
</action>

</package>
</struts>

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in Struts Dispatcher