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: [email protected] 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: [email protected] 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/
