Hi,
As I can see from the attached code, MyException still extends from
RemoteException. My suggestion was to make the method look like:
double divide(double n1, double n2) throws MyException, RemoteException;
Where MyException does not extend RemoteException.
Thanks,
Raymond
From: Sun Yang
Sent: Monday, July 21, 2008 5:28 PM
To: user@tuscany.apache.org
Subject: Re: How to return application exception in RMI binding?
Hi,
I still cannot achieve the goal. I attach my modified version of
calculator-rmi-service. Could you help me check it?
Client App: CalculatorClient.java - a pure rmi application which does not
know Tuscany runtime (and outside the Tuscany domain)
Server App: CalculatorServer.java - start a Tuscany domain which binds
CalculatorService to rmi interface.
Wanted Scenario:
1. Client App calls calculator service through rmi
2. client will call divide(3, 0) on the remote object and receive the
service specific MyException class to do further exception processing.
I tried your solution, but the returned exception still wrapped in
java.lang.reflect.InvocationTargetException.
Are you suggesting to make the client join the domain first then call the
service within the domain? (as
https://svn.apache.org/repos/asf/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java)
Best Regards,
Yang Sun
2008/7/21 Raymond Feng <[EMAIL PROTECTED]>:
Hi,
You can just add the RemoteException on the "throws" clause instead of
having the user exception extend the RemoteException.
Thanks,
Raymond
From: Sun Yang
Sent: Monday, July 21, 2008 7:37 AM
To: user@tuscany.apache.org
Subject: Re: How to return application exception in RMI binding?
Hi, Raymond:
Thanks for pointing out my problem. I read the part you specified in JAXWS
specification and understand that RemoteException and RuntimeException are
not suitable for service specific exceptions.
But if I want to provide the following interface with RMI service binding:
public interface OrderManagement {
public void placeProcessOrder(String userID) throws
UserPriviledgeNotEnoughExcepti
on;
}
How can I achieve the goal if I doesn't specify
UserPriviledgeNotEnoughException as a RemoteException? RMI client runtime
will complain a non-remotable exception. Could you give me some indication
or best practices to work around this in Tuscany way?
Best Regards,
Yang Sun
2008/7/19 Raymond Feng <[EMAIL PROTECTED]>:
Hi,
RemoteException and its subclasses are usually used to represent
communication issues and not treated as business exceptions by Tuscany based
on the statement from JAXWS Specification v2.1 section 3.7. SCA spec
requires the remotable interface follows JAXWS mapping rules.
Thanks,
Raymond
From: Sun Yang
Sent: Thursday, July 17, 2008 5:23 PM
To: user@tuscany.apache.org
Subject: Re: How to return application exception in RMI binding?
Hi, Luciano:
My scenario is not the same. I use a pure RMI client (agnostic of Tuscany)
to connect to a service exposed by a RMI binding.
I make some modifications to sample project calculator-rmi-service. So
instead of return Infinity, it should throw a RemoteException when divide by
zero. But at the client side, instead of getting the RemoteException, I got
a InvocationTargetException which wraps the RemoteException.
The client code to connect to sca service is:
public class CalculatorClient {
public static void main(String[] args) throws Exception {
CalculatorService calculatorService =
(CalculatorService)Naming.lookup("//localhost:8099/CalculatorRMIService");
System.out.println("3 / 0=" + calculatorService.divide(3, 0));
}
}
Best Regards,
Yang Sun
2008/7/18 Luciano Resende <[EMAIL PROTECTED]>:
Is your scenario different from the one defined in the RMI Binding
test case where the method would throw the Hello business exception ?
String sayHi(String name, String greeter) throws HelloException;
[1]
https://svn.apache.org/repos/asf/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java
On Thu, Jul 17, 2008 at 7:15 AM, Sun Yang <[EMAIL PROTECTED]> wrote:
Hi,
I want to get an application specific exception (which extends
java.rmi.RemoteException) from calling a rmi binding service. But the
exception always wrappered in a InvocationTargetException.
RMI spec supports remote exception. I am not sure if I missed something in
the composite configuration or Tuscany doesn't support throwing the
RemoteException directly.
In RuntimeWireInvoker.java, I find the following code which relates to the
exception handling.
Object body = resp.getBody();
if (resp.isFault()) {
throw new InvocationTargetException((Throwable)body);
}
I guess the wrapping here is the cause of the exception wrapper.
Best Regards,
Yang Sun
--
Luciano Resende
Apache Tuscany Committer
http://people.apache.org/~lresende
http://lresende.blogspot.com/