This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes struts 2 error ---- Could not find action or result Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 error ---- Could not find action or result" Watch "struts 2 error ---- Could not find action or result" New topic
Author

struts 2 error ---- Could not find action or result

kalaiselvi Bhalerao
Greenhorn

Joined: Aug 19, 2011
Posts: 9
Hi everybody

I am getting the error message as below


SEVERE: Could not find action or result
There is no Action mapped for action name display. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:497)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)



I am using Eclipse ID to create a simple Struts 2 application

struts.xml

<!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="display" class="example1.action.DisplayName">

<result name="success">/example1/success.jsp</result>
<result name="input">/example1/UserInput.jsp</result>
</action>
</package>
</struts>

Action class

package example1.action;

import com.opensymphony.xwork2.ActionSupport;

public class DisplayName extends ActionSupport {
private String message;

private String userName;

public DisplayName() {
System.out.println("DisplayName constructor");
}

public String execute() {
setMessage("Hello " + getUserName());
return SUCCESS;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

}


Input page

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<html>
<head>
<title>User Input</title>
<s:head />
</head>
<body>
User Input Form
<s:form action="display" >
<s:textfield name="userName" label="User Name" />
<s:submit />
</s:form>

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_2_5.xsd" id="WebApp_ID" version="2.5">

<display-name>StrutsExample1</display-name>

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
</body>
</html>


pl help me to resolve the error.
I assume there is a silly mistake, but i am not able to trace the error.
i guess the tomcat is not able to read struts.xml
debraj mallick
Ranch Hand

Joined: Mar 08, 2011
Posts: 188

hi there,

i think you are missing "namespace"

in struts.xml
kalaiselvi Bhalerao
Greenhorn

Joined: Aug 19, 2011
Posts: 9
i did try adding namespace to struts.xml that also gave the same error.
 
Consider Paul's rocket mass heater.
 
subject: struts 2 error ---- Could not find action or result
 
Similar Threads
unknown error while running Struts2 application
The requested resource () is not available.
Is my application running or is it just stuck??
Struts 2 problem-actions cant find the result. WARNING: Could not find action or result
problem in Struts2 while running an application