user5005768Himadree
user5005768Himadree

Reputation: 1439

How to resolve HTTP Status 404 - No result defined for action org.name.action.TutorialAction and result?

I was writing an struts 2 project in eclipse.After starting the project on tomcat server, whenever i insert this url : http://localhost:8080/Struts2Starter/getTutorial.action on web browser then the browser dispalys this error: HTTP Status 404 - No result defined for action org.name.action.TutorialAction and result

am i missing any other important jer files? or Do i need to add convention-plugin-2.3.x.jar ? or Do i need to add annotation ?

These are the the jer files i added in WEB-INF/lib :

commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-lang-2.4.jar
commons-logging-1.1.3.jar
commons-logging-api-1.1.jar
freemarker-2.3.22.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-core-2.3.24.jar
xwork-core-2.3.24.jar 

this is struts.xml code below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">        
 <struts>
 <package name="default" extends="struts-default">       
    <action name="getTutorial" class="org.name.action.TutorialAction">
        <result name="success">/success.jsp</result>
        <result name="failure">/error.jsp</result>
    </action>
</package>
 </struts> 

this is TutorialAction class code below:

package org.name.action;
import com.opensymphony.xwork2.ActionSupport;

public class TutorialAction  extends ActionSupport{

    public String execute(){
        System.out.println("Hello From execute() method.");
        return "success";
    }
}

this is web.xml code below:

<?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" 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>Struts2Starter</display-name>
  <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>


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


</web-app>

under this folder given image ,i added my jsp pages: enter image description here

Updates: during cleaning the project this error was occurred :

Errors running builder 'Integrated External Tool Builder' on project 'Struts2Starter'. Variable references non-existent resource : ${workspace_loc:/Java8} Variable references non-existent resource : ${workspace_loc:/Java8}

is this the main reason or other things needed.how to solve this. please let me know for further information.

Upvotes: 0

Views: 1965

Answers (2)

compt
compt

Reputation: 80

There is another file "commons-lang3xxx.jar", add this file and run it again.

Upvotes: 1

James Jithin
James Jithin

Reputation: 10555

This looks like the value returned from execute() method resolves to an empty String. Check if you have local/class/instance variable with name SUCCESS which has value of empty String.

If there is a result name being returned and if the result is not found, Struts gives error with result name. For e.g., the result success is being removed and it gives error HTTP Status 404 - No result defined for action org.name.action.TutorialAction and result success

Following screen is being generated by returning an empty String.

enter image description here

Upvotes: 1

Related Questions