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://people.apache.org/%7Elresende>
> http://lresende.blogspot.com/
>

Reply via email to