struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prasenjit Bhadra <prbha...@gmail.com>
Subject Problem with Struts2 JSON RPC using simple HTTP Post
Date Fri, 04 Dec 2009 00:10:52 GMT
I have developed a native client interface which calls struts2 JSON RPC
using post method. I have set content type, content length as suggested in
the spec. The request body looks like as follows : {"method":
"uploadTxpAssignment","id": "txpUploadRequest",
"params":{"addressByDestAddrId":{"addrLine1":"test home","addrLine2":"7th
ave","addressId":2,"aptRoomNo":5,"city":"queens","phone":"435-577-4567","state":"NY","zipCode":10183},"atDestTime":null,"callRcvdTime":"2009-11-26T08:01:00","comments":"comments1","dateCreated":"2009-11-26T00:00:00","dateModified":null,"user":{"dateCreated":null,"dateModified":null,"dob":"1956-09-18T00:00:00","firstName":"passfname","gender":"Male","lastName":"patient1lname","mi":null,"ssn":null,"userId":10000}}}
The struts.xml configurations are : <action name="UploadAction"
class="com.actions.upload.UploadAction" method="smd"> <interceptor-ref
name="json"> <param name="enableSMD">true</param> <param
name="ignoreSMDMethodInterfaces">false</param> </interceptor-ref> <result
type="json"> <param name="enableSMD">true</param> <param
name="ignoreInterfaces">false</param> <param
name="contentType">text/plain</param> <param name="bufferSize">1024</param>
<param name="allowCaching">false</param> <param
name="contentCharSet">UTF-8</param> </result> </action> The simple action
code body : public class UploadCallreportAction { private
TransportAssignmentVO transport; /** * @return the transport */ public
TransportAssignmentVO getTransport() { return transport; } /** * @param
transport the transport to set */ public void
setTransport(TransportAssignmentVO transport) { this.transport = transport;
} public String smd() { return Action.SUCCESS; } @SMDMethod public void
uploadTxpAssignment(TransportAssignmentVO txpVO) { setTransport(txpVO);
System.out.println("The Tansport assignment is for Run #:"+
transport.getRunNumber()); } } When I run the client the call reaches the
server and returns me an exception : :35,013 ERROR [RPCError]
java.util.HashMap cannot be cast to java.util.List
java.lang.ClassCastException: java.util.HashMap cannot be cast to
java.util.List at
org.apache.struts2.json.JSONInterceptor.invoke(JSONInterceptor.java:204) at
org.apache.struts2.json.JSONInterceptor.intercept(JSONInterceptor.java:131)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
at
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
I am also using Spring 2.5 and Hibernate JPA in the same app.... Not sure if
there is any conflict.I have followed the simple rules to set up the JSON
RPC.However I am not able to resolve the problem. Please let me know if
anyone has a solution for this.

Jeet

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message