4 Replies Latest reply on Apr 27, 2005 2:19 PM by Daniel Santos

    Exception propagation

    Daniel Santos Newbie

      Hello,

      I was wondering if it could be possible / make any sense to propagate the exceptions thrown inside the ServerInvocationHandler implementors invoke method, to the client.
      This would make the client code more clean.

      Regards

        • 1. Re: Exception propagation
          Tom Elrod Master

          I does this currently. Maybe you can clarify your question with an example?

          • 2. Re: Exception propagation
            Daniel Santos Newbie

            On the implementation of a ServerInvocationHandler.invoke method :

            public Object invoke(InvocationRequest request) throws Throwable {

            try {
            myObject.doSomething();
            } catch (Exception e) {
            throw new MyException(e.getMessage());
            }
            }

            On the client:
            ...
            InvokerLocator locator = new InvokerLocator(url);
            Client aClient = new Client(locator);
            aClient.connect();
            ...
            try {
            aClient.invoke("argument to doSomething");
            } catch (MyException e) {
            e.printStackTrace();
            }
            ...

            The exception MyException is thrown on the server and is caught on the client. It is propagated through the network by the remoting framework.

            Hope it carified.

            • 3. Re: Exception propagation
              Tom Elrod Master

              Are you saying that your client does not get the MyException thrown to it when calling the invoke() method? It should. If it does not, then this is a bug and need to enter a jira issue (http://jira.jboss.com).

              There is a test case (org.jboss.remoting.exception.server.ServerExceptionTestCase), that test this explicitly as well.

              • 4. Re: Exception propagation
                Daniel Santos Newbie

                No I am not. I just wrote some code with this framework, and have not yet run it, so I ended up putting the question here before seeing it happen. I hadn't seen any reference to it in the pdf, so I asked first

                Next time I'll try before asking. Sorry.

                Regards