wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts2 - Json issue, InvocationTargetException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 - Json issue, InvocationTargetException" Watch "Struts2 - Json issue, InvocationTargetException" New topic
Author

Struts2 - Json issue, InvocationTargetException

anil kumar mullapudi
Greenhorn

Joined: Oct 25, 2011
Posts: 8
i have a ArrayList "objUsersList" in my Action class. That contains the following data.

objUsersList has setters and getters in my Action class.

[User [Nuser_id=1, strUser_FirstName=anil, strUser_LastName=mullapudi, strUser_Name=anil, strUser_Password=root, strUser_gender=M],
User [Nuser_id=2, strUser_FirstName=Ramesh, strUser_LastName=gubbala, strUser_Name=ramesh, strUser_Password=root, strUser_gender=M],
User [Nuser_id=3, strUser_FirstName=anil, strUser_LastName=vatti, strUser_Name=anilv, strUser_Password=root, strUser_gender=M],
User [Nuser_id=4, strUser_FirstName=ram, strUser_LastName=m, strUser_Name=ram, strUser_Password=root, strUser_gender=M],
User [Nuser_id=5, strUser_FirstName=tarun, strUser_LastName=k, strUser_Name=tarun, strUser_Password=root, strUser_gender=m]]


I am using the following code in my jsp.
java script:
-------------
function viewUsers() {

var url = 'view_users.action';

var myAjax = new Ajax.Request(
url,
{
method: 'post',
onComplete: fetchUsers
});

}

function fetchUsers(originalRequest) {
var result = originalRequest.responseText.evalJSON(); // the execution stops here
alert(result.objUsersList[0]);
}

How to populate my ArrayList in my jsp page. Please help me.



I changed the above code to

function fetchUsers(originalRequest) {
alert(originalRequest.responseText);
}

Then i got the following execption in alert message


<html><head><title>Apache Tomcat/6.0.10 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: com.googlecode.jsonplugin.JSONException: java.lang.reflect.InvocationTargetException
com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:239)
com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161)
com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:127)
com.googlecode.jsonplugin.JSONWriter.write(JSONWriter.java:95)
com.googlecode.jsonplugin.JSONUtil.serialize(JSONUtil.java:98)
com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
com.opensymphony…

Thanks in advance.
Anil (anilmullapudi@gmail.com)
anil kumar mullapudi
Greenhorn

Joined: Oct 25, 2011
Posts: 8
Problem solved when i remove the setters in my Action class which are injected from spring configuration file.
Instead of setter injection i used constructor injection, Now everything works fine, But my action class method executes two times for a single request. I am unable to stop this second time execution.
 
wood burning stoves
 
subject: Struts2 - Json issue, InvocationTargetException
 
Similar Threads
using apache soap webservice in jboss
Problem while Deploy web service
How to Implement POST Method in RESTFul web services using Jersey
Regarding struts with ajax
Struts2 - Json problem