Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dispatch[/ActionName ] to method method1 returned an exception

 
Rajeev Ja
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
whenever i am creating new instance of form it is required because form contains a constructor while it is using getters and setters of another dto.then form is coming as null.
our formbean is like
public class Person extends ActionForm
{
private PatientDetail patientDetail;
}
public class PatientDetail extends ActionForm
{
private String patientId;
}
How to acess patientId in JSTL
requestParameter.patientDetail.patientId
Please reply.

Thanks and Regards
Rajeev
 
Chris Boldon
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using JSTL you do not use ActionForms. You add your object to the request as an Attribute.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not quite sure what you are asking. I would think that your form would have to have a parameter-less constructor (or no constructors with parameters specified). Otherwise I do not think that Struts would be able to instantiate your form. Also, I am not sure you really want both Person and PatientDetail to extend ActionForm. It might be better design to have PersonForm class which contained a Person (or a PatientDetail).

- Brent
 
Chris Boldon
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Map your form to a bean, then set the bean as an attribute.
[ October 19, 2007: Message edited by: Chris Boldon ]
 
Rajeev Ja
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies
but i have made all the changes but it is throwing null pointer exception
get me some code of that kind
 
Chris Boldon
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which variable is coming up as null? Post your code.
 
Myyron Murray Latorilla
Ranch Hand
Posts: 65
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, im also receiving this message in glassfish whenever I create a JSONObject object.

Sample log:
Dispatch[/role] to method 'getUsers' returned an exception
java.lang.reflect.InvocationTargetException

Sample code:
public ActionForward getUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.setContentType("text/html;charset=utf-8");

JSONObject json = new JSONObject(); //HERE IS WHERE THE EXCEPTION IS OCCURRING
json.put("userName", "Juan dela Cruz");
json.put("userID", "12345");
json.put("role", "System Administrator");
json.put("active", "true");
response.getWriter().write((new StringBuilder("[")).append(json.toString()).append("]").toString());

return null;
}

Any idea why this exception is occurring?..Thanks in advance
 
Chris Boldon
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
myyron latorilla wrote:Hi, im also receiving this message in glassfish whenever I create a JSONObject object.

Sample log:
Dispatch[/role] to method 'getUsers' returned an exception
java.lang.reflect.InvocationTargetException

Sample code:
public ActionForward getUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.setContentType("text/html;charset=utf-8");

JSONObject json = new JSONObject(); //HERE IS WHERE THE EXCEPTION IS OCCURRING
json.put("userName", "Juan dela Cruz");
json.put("userID", "12345");
json.put("role", "System Administrator");
json.put("active", "true");
response.getWriter().write((new StringBuilder("[")).append(json.toString()).append("]").toString());

return null;
}

Any idea why this exception is occurring?..Thanks in advance


Can you debug the call? It's really hard to tell what's going on with a basic Exception and no stack track. Where exactly is the exception being thrown, and what is the complete stack trace when the exception is thrown?
 
Myyron Murray Latorilla
Ranch Hand
Posts: 65
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind Chris, I've already found the problem. It's my fault that I rushed to use the JSON library without reading its documentation first. Found from log that there were missing classes and needs the following jars inorder for it to work.

- commons-lang-2.4.jar
- commons-collections-3.2.1.jar
- ezmorph-1.0.jar

Anyway, thanks for your time man.

Before I forgot, heres the trace of the exception.
[#|2009-12-10T20:22:53.221+0800|SEVERE|sun-appserver2.1|org.apache.struts.actions.DispatchAction|_ThreadID=23;_ThreadName=httpSSLWorkerThread-8108-2;_RequestID=1bc6ac94-7be0-41b3-af14-621827cc9dc9;|Dispatch[/role] to method 'getUsers' returned an exception
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.java:688)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at com.onsemi.rdc.mes.webclmc.action.Role.getUsers(Role.java:27)
... 39 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
at com.sun.enterprise.loader.EJBClassLoader.findClassData(EJBClassLoader.java:738)
at com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.java:628)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 46 more
|#]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic