summaryrefslogtreecommitdiffstats
path: root/branches
diff options
context:
space:
mode:
Diffstat (limited to 'branches')
-rw-r--r--branches/sca-java-1.x/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java b/branches/sca-java-1.x/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
index 85bae9085d..f260fe4a38 100644
--- a/branches/sca-java-1.x/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
+++ b/branches/sca-java-1.x/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
import java.util.List;
import javax.servlet.ServletConfig;
@@ -252,9 +251,8 @@ public class JSONRPCServiceServlet extends JSONRPCServlet {
//result = wire.invoke(jsonOperation, args);
Message responseMessage = wire.getInvocationChain(jsonOperation).getHeadInvoker().invoke(requestMessage);
- if (responseMessage.isFault()) {
- throw new RuntimeException((Throwable)responseMessage.getBody());
- } else {
+ if (!responseMessage.isFault()) {
+ //successful execution of the invocation
try {
result = responseMessage.getBody();
JSONObject jsonResponse = new JSONObject();
@@ -265,14 +263,15 @@ public class JSONRPCServiceServlet extends JSONRPCServlet {
} catch (Exception e) {
throw new ServiceRuntimeException("Unable to create JSON response", e);
}
+ } else {
+ //exception thrown while executing the invocation
+ Throwable exception = (Throwable)responseMessage.getBody();
+ JSONRPCResult errorResult = new JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, exception );
+ return errorResult.toString().getBytes("UTF-8");
}
-
-
- }/* catch (InvocationTargetException e) {
- JSONRPCResult errorResult = new JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, e.getCause() );
- return errorResult.toString().getBytes("UTF-8");
- }*/ catch(RuntimeException e) {
- JSONRPCResult errorResult = new JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, e.getCause());
+ } catch(RuntimeException e) {
+ //some other exception
+ JSONRPCResult errorResult = new JSONRPCResult(JSONRPCResult.CODE_REMOTE_EXCEPTION, id, e);
return errorResult.toString().getBytes("UTF-8");
}
}