You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by ZhiYong Mao <zm...@us.ibm.com> on 2008/10/20 08:28:24 UTC
"error parsing result" error in Tuscany JSON-RPC
Hi
I found there would be an error "error parsing result" while call by
JSON-RPC and we could not get the actual error message if the java code
threw a exception, which results from the error message is not valid JSON
string, for example:
{"error":com.ibm.iq.innovation.marketplace.biz.exception.BizException: A
Group named Jacky's team already exists.,"id":2}
So I think it would be better to fix it like this:
=>Line 246 in org.apache.tuscany.sca.binding.jsonrpc.provider.
JSONRPCServiceServlet:
Change the following code: =>
jsonResponse.put("error", e.getCause());
to the code as follows: =>
/**********************************************************
* add json error object into error so that
* the client javascript can parse them correctly.
*/
Throwable t=e.getCause();
JSONObject jsonError = new JSONObject();
jsonError.put("code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
jsonError.put("msg", t.getMessage());
jsonError.put(;"trace", t.getClass().getName()););
jsonResponse.put("error", jsonError);
/************************************************/
Best regards!
Jacky Mao , Software Engineer
IBM GPSG Wuhan Perform Center
Tel : 0086-027-87406266-1212
E-Mail: zmao@us.ibm.com
Re: "error parsing result" error in Tuscany JSON-RPC
Posted by Luciano Resende <lu...@gmail.com>.
This change might have gone only into trunk, and we are talking about
a 1.4 release for sometime next month.
If you need to check the latest source code, it's available at :
https://svn.apache.org/repos/asf/tuscany/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
On Tue, Oct 21, 2008 at 12:49 AM, ZhiYong Mao <zm...@us.ibm.com> wrote:
> Hi Luciano
>
> What we used is Tuscany SCA 1.3.1, but I did not find any code like you
> mentioned in source code 1.3.1 and 1.3.2, here are the source files for the
> 2 versions:
> (See attached file: JSONRPCServiceServlet1.3.2.java)(See attached file:
> JSONRPCServiceServlet1.3.1.java)
> But I saw the following change from the TUSCANY-1961, why?
>
> Best regards!
>
> Jacky Mao , Software Engineer
> IBM GPSG Wuhan Perform Center
> Tel : 0086-027-87406266-1212
> E-Mail: zmao@us.ibm.com
> "Luciano Resende" <lu...@gmail.com>
>
>
> "Luciano Resende" <lu...@gmail.com>
>
> 2008-10-21 12:19
>
> Please respond to
> user@tuscany.apache.org
>
> To
> user@tuscany.apache.org
> cc
>
> Subject
> Re: "error parsing result" error in Tuscany JSON-RPC
> Hey ZhiYong
>
> What release are you using ? This might have already been fixed by
> TUSCANY-1961 by adding the following code
>
> JSONRPCResult errorResult = new
> JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, e.getCause() );
>
> Please let me know if you still see the mentioned behavior with current
> code.
>
> [1] https://issues.apache.org/jira/browse/TUSCANY-1961
>
>
>
> On Sun, Oct 19, 2008 at 11:28 PM, ZhiYong Mao <zm...@us.ibm.com> wrote:
>> Hi
>>
>> I found there would be an error "error parsing result" while call by
>> JSON-RPC and we could not get the actual error message if the java code
>> threw a exception, which results from the error message is not valid JSON
>> string, for example:
>> {"error":com.ibm.iq.innovation.marketplace.biz.exception.BizException: A
>> Group named Jacky's team already exists.,"id":2}
>>
>> So I think it would be better to fix it like this:
>> =>Line 246 in
>> org.apache.tuscany.sca.binding.jsonrpc.provider.JSONRPCServiceServlet:
>> Change the following code: =>
>> jsonResponse.put("error", e.getCause());
>> to the code as follows: =>
>> /**********************************************************
>> * add json error object into error so that
>> * the client javascript can parse them correctly.
>> */
>> Throwable t=e.getCause();
>> JSONObject jsonError = new JSONObject();
>> jsonError.put("code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
>> jsonError.put("msg", t.getMessage());
>> jsonError.put("trace", t.getClass().getName());
>> jsonResponse.put("error", jsonError);
>> /************************************************/
>>
>> Best regards!
>>
>> Jacky Mao , Software Engineer
>> IBM GPSG Wuhan Perform Center
>> Tel : 0086-027-87406266-1212
>> E-Mail: zmao@us.ibm.com
>
>
>
> --
> Luciano Resende
> Apache Tuscany, Apache PhotArk
> http://people.apache.org/~lresende
> http://lresende.blogspot.com/
>
>
--
Luciano Resende
Apache Tuscany, Apache PhotArk
http://people.apache.org/~lresende
http://lresende.blogspot.com/
Re: "error parsing result" error in Tuscany JSON-RPC
Posted by ZhiYong Mao <zm...@us.ibm.com>.
Hi Luciano
What we used is Tuscany SCA 1.3.1, but I did not find any code like you
mentioned in source code 1.3.1 and 1.3.2, here are the source files for the
2 versions:
(See attached file: JSONRPCServiceServlet1.3.2.java)(See attached file:
JSONRPCServiceServlet1.3.1.java)
But I saw the following change from the TUSCANY-1961, why?
Best regards!
Jacky Mao , Software Engineer
IBM GPSG Wuhan Perform Center
Tel : 0086-027-87406266-1212
E-Mail: zmao@us.ibm.com
"Luciano Resende"
<luckbr1975@gmail
.com> To
user@tuscany.apache.org
2008-10-21 12:19 cc
Subject
Please respond to Re: "error parsing result" error in
user@tuscany.apac Tuscany JSON-RPC
he.org
Hey ZhiYong
What release are you using ? This might have already been fixed by
TUSCANY-1961 by adding the following code
JSONRPCResult errorResult = new
JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, e.getCause() );
Please let me know if you still see the mentioned behavior with current
code.
[1] https://issues.apache.org/jira/browse/TUSCANY-1961
On Sun, Oct 19, 2008 at 11:28 PM, ZhiYong Mao <zm...@us.ibm.com> wrote:
> Hi
>
> I found there would be an error "error parsing result" while call by
> JSON-RPC and we could not get the actual error message if the java code
> threw a exception, which results from the error message is not valid JSON
> string, for example:
> {"error":com.ibm.iq.innovation.marketplace.biz.exception.BizException: A
> Group named Jacky's team already exists.,"id":2}
>
> So I think it would be better to fix it like this:
> =>Line 246 in
> org.apache.tuscany.sca.binding.jsonrpc.provider.JSONRPCServiceServlet:
> Change the following code: =>
> jsonResponse.put("error", e.getCause());
> to the code as follows: =>
> /**********************************************************
> * add json error object into error so that
> * the client javascript can parse them correctly.
> */
> Throwable t=e.getCause();
> JSONObject jsonError = new JSONObject();
> jsonError.put("code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
> jsonError.put("msg", t.getMessage());
> jsonError.put("trace", t.getClass().getName());
> jsonResponse.put("error", jsonError);
> /************************************************/
>
> Best regards!
>
> Jacky Mao , Software Engineer
> IBM GPSG Wuhan Perform Center
> Tel : 0086-027-87406266-1212
> E-Mail: zmao@us.ibm.com
--
Luciano Resende
Apache Tuscany, Apache PhotArk
http://people.apache.org/~lresende
http://lresende.blogspot.com/
Re: "error parsing result" error in Tuscany JSON-RPC
Posted by Luciano Resende <lu...@gmail.com>.
Hey ZhiYong
What release are you using ? This might have already been fixed by
TUSCANY-1961 by adding the following code
JSONRPCResult errorResult = new
JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, e.getCause() );
Please let me know if you still see the mentioned behavior with current code.
[1] https://issues.apache.org/jira/browse/TUSCANY-1961
On Sun, Oct 19, 2008 at 11:28 PM, ZhiYong Mao <zm...@us.ibm.com> wrote:
> Hi
>
> I found there would be an error "error parsing result" while call by
> JSON-RPC and we could not get the actual error message if the java code
> threw a exception, which results from the error message is not valid JSON
> string, for example:
> {"error":com.ibm.iq.innovation.marketplace.biz.exception.BizException: A
> Group named Jacky's team already exists.,"id":2}
>
> So I think it would be better to fix it like this:
> =>Line 246 in
> org.apache.tuscany.sca.binding.jsonrpc.provider.JSONRPCServiceServlet:
> Change the following code: =>
> jsonResponse.put("error", e.getCause());
> to the code as follows: =>
> /**********************************************************
> * add json error object into error so that
> * the client javascript can parse them correctly.
> */
> Throwable t=e.getCause();
> JSONObject jsonError = new JSONObject();
> jsonError.put("code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
> jsonError.put("msg", t.getMessage());
> jsonError.put("trace", t.getClass().getName());
> jsonResponse.put("error", jsonError);
> /************************************************/
>
> Best regards!
>
> Jacky Mao , Software Engineer
> IBM GPSG Wuhan Perform Center
> Tel : 0086-027-87406266-1212
> E-Mail: zmao@us.ibm.com
--
Luciano Resende
Apache Tuscany, Apache PhotArk
http://people.apache.org/~lresende
http://lresende.blogspot.com/