aspose file tools*
The moose likes Struts and the fly likes internal error: (No action instance for path /lookup could be created) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "internal error: (No action instance for path /lookup could be created)" Watch "internal error: (No action instance for path /lookup could be created)" New topic
Author

internal error: (No action instance for path /lookup could be created)

Suvendu Pothal
Greenhorn

Joined: Aug 17, 2011
Posts: 4
hey friends i haave a problem in my application
type Status report

message No action instance for path /lookup could be created

description The server encountered an internal error (No action instance for path /lookup could be created) that prevented it from fulfilling this request.

my xml file is
<struts-config>
<form-beans>
<form-bean name="lookupform" type="org.apache.struts.action.DynaActionForm">
<form-property name="dno" type="java.lang.Integer" initial="10"/>
</form-bean>
</form-beans>
<action-mappings>
<action path="/lookup" type="org.apache.struts.action.LookupDispatchAction" parameter="s" name="lookupform" scope="request">
<forward name="success" path="/display.jsp"/>
</action>
</action-mappings>
<message-resources parameter="Nit"/>
</struts-config>

please please give me solution
Rajagopal Mani
Ranch Hand

Joined: Mar 24, 2011
Posts: 84

Welcome to JavaRanch.

Do create action class which needs to extended org.apache.struts.actions.LookupDispatchAction and map this action class path in configuartion file.
Suvendu Pothal
Greenhorn

Joined: Aug 17, 2011
Posts: 4
Rajagopal Mani wrote:Welcome to JavaRanch.

Do create action class which needs to extended org.apache.struts.actions.LookupDispatchAction and map this action class path in configuartion file.


display.jsp
***********
<%@ page import="java.util.*"%>
<%@ page import="com.nit.struts.EmpDetails"%>
<%
ArrayList al=(ArrayList)request.getAttribute("result");
Iterator i=al.iterator();
while(i.hasNext())
{
EmpDetails ed=(EmpDetails)i.next();
out.println("<h2>"+ed.getName()+"\t"+ed.getSal()+"\t"+ed.getDesig+"</h2>");
}
%>
***************
lookup.jsp
**********
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<center>
<html:form action="/quote">
<bean:message key="my.dno"/>:<html:text property="dno"/>

<input type=submit name="s" value="<bean:message key='Asc'/>"/>
<input type=submit name="s" value="<bean:message key='Desc'/>"/>
</html:form>
</center>
*************
struts-config.xml
**************
<struts-config>
<form-beans>
<form-bean name="lookupform" type="org.apache.struts.action.DynaActionForm">
<form-property name="dno" type="java.lang.Integer" initial="10"/>
</form-bean>
</form-beans>
<action-mappings>
<action path="/quote" type="org.apache.struts.actions.LookupDispatchAction" parameter="s" name="lookupform" scope="request">
<forward name="success" path="/display.jsp"/>
</action>
</action-mappings>
<message-resources parameter="Nit"/>
</struts-config>
*************
web.xml
***********
<web-app>

<servlet>
<servlet-name>as</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup/>
</servlet>

<servlet-mapping>
<servlet-name>as</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>lookup.jsp</welcome-file>
</welcome-file-list>

</web-app>
*************
SQLConstants.java
*************
//helper class
package com.nit.struts;
public class SQLConstants
{
public static final String ASC_QUERY="select ename,esal,edesig,eno from lookupemp where dno=? order by ename";
public static final String DESC_QUERY="select ename,esal,edesig,eno from lookupemp where dno=? order by ename desc";
}
**************
EmpDetails.java
******************
//helper class
package com.nit.struts;
public class EmpDetails
{
//prepare set & get methods
public void setNo(int no)
{this.no=no;}
public int getNo()
{return no;}
public void setName(String name)
{this.name=name;}
public String getName()
{return name;}
public void setSal(double sal)
{this.sal=sal;}
public double getSal()
{return sal;}
public void setDesig(String desig)
{this.desig=desig;}
public String getDesig()
{return desig;}
private int no;
private double sal;
private String desig,name;
}
*******************
LookupDispatchAction.java
************************

//actionapp
package com.nit.struts;
import java.util.*;
import java.sql.*;
import org.apache.struts.action.*;
import org.apache.struts.actions.*;
import javax.servlet.http.*;
public class MyLookupDispatchAction extends LookupDispatchAction
{
public ActionForward ascendingEmps(ActionMapping am,ActionForm af,HttpServletRequest req,HttpServletResponse res)
{
ArrayList al=new ArrayList();
DynaActionForm daf=(DynaActionForm)af;
Connection con=null;
try{
con=getCon();
PreparedStatement ps=con.prepareStatement(SQLConstants.ASC_QUERY);
ps.setInt(1,((Integer)daf.get("dno")).intValue());
ResultSet rs=ps.executeQuery();
while(rs.next())
{
EmpDetails ed=new EmpDetails();
ed.setNo(rs.getInt("eno"));
ed.setName(rs.getString("ename"));
ed.setSal(rs.getDouble("esal"));
ed.setDesig(rs.getString("edesig"));
al.add(ed);
}//while
}//try
catch(Exception e){}
finally{
try{
con.close();
}
catch(Exception e){}
}//finally
req.setAttribute("result",al);
return am.findForward("success");
}//ascendingEmps
public ActionForward descendingEmps(ActionMapping am,ActionForm af,HttpServletRequest req,HttpServletResponse res)
{
ArrayList al=new ArrayList();
DynaActionForm daf=(DynaActionForm)af;
Connection con=null;
try{
con=getCon();
PreparedStatement ps=con.prepareStatement(SQLConstants.DESC_QUERY);
ps.setInt(1,((Integer)daf.get("dno")).intValue());
ResultSet rs=ps.executeQuery();
while(rs.next())
{
EmpDetails ed=new EmpDetails();
ed.setNo(rs.getInt("eno"));
ed.setName(rs.getString("ename"));
ed.setSal(rs.getDouble("esal"));
ed.setDesig(rs.getString("edesig"));
al.add(ed);
}//while
}//try
catch(Exception e){}
finally{
try{
con.close();
}
catch(Exception e){}
}//finally
req.setAttribute("result",al);
return am.findForward("success");
}//descendingEmps
public Connection getCon()throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDriver");
return DriverManager.getConnection("jdbcracle:thin:@localhost:1521:XE","system","lily");
}//getCon
public Map getKeyMethodMap()
{
Map m=new HashMap();
m.put("ASC","ascendingEmps");
m.put("DESC","descendingEmps");
return m;
}//getKeyMethodMap
}//MyLookupDispatchAction
**************************
Nit_en_us.properties
****************
my.dno=Dept No.
Asc=Ascending
Desc=Descending
****************
Nit_it.properties
**************
my.dno=Dept No.(it)
Asc=Ascending(it)
Desc=Descending(it)
**************
please find out the error
Orton K Randy
Ranch Hand

Joined: Aug 12, 2011
Posts: 41

Take your time roaming around the forum, reading through threads and posts. Unless you code your stuff, no one would be able to understand what you've posted. It's more than just a good practice.

On topic, what Rajagopal said should solve your problem.

Your action mapping in struts-config.xml right now looks like:


It should rather look like:



Coderanch, best ever forum on the net. Hands down.
Suvendu Pothal
Greenhorn

Joined: Aug 17, 2011
Posts: 4
Orton K Randy wrote:Take your time roaming around the forum, reading through threads and posts. Unless you code your stuff, no one would be able to understand what you've posted. It's more than just a good practice.

On topic, what Rajagopal said should solve your problem.

Your action mapping in struts-config.xml right now looks like:


It should rather look like:





sorry sir still error

javax.servlet.ServletException: Action[/lookup] missing resource in key method map
org.apache.struts.actions.LookupDispatchAction.getLookupMapName(LookupDispatchAction.java:230)
org.apache.struts.actions.LookupDispatchAction.getMethodName(LookupDispatchAction.java:271)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:173)
org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:150)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

i am not getting missing resource in key method map
Orton K Randy
Ranch Hand

Joined: Aug 12, 2011
Posts: 41

The getKeyMethodMap() function should return a map with entries for 'Asc' and 'Desc' and NOT 'ASC', 'DESC". Because that's how you named the buttons in JSP using bean:message, remember? See my inline comments in the below code. I'd suggest learning how LookupDispatchAction works with the help of a working example before you try out your own stuff.

Suvendu Pothal
Greenhorn

Joined: Aug 17, 2011
Posts: 4
Orton K Randy wrote:The getKeyMethodMap() function should return a map with entries for 'Asc' and 'Desc' and NOT 'ASC', 'DESC". Because that's how you named the buttons in JSP using bean:message, remember? See my inline comments in the below code. I'd suggest learning how LookupDispatchAction works with the help of a working example before you try out your own stuff.




thank you.
thanks a lot i have got my result.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: internal error: (No action instance for path /lookup could be created)