Results 1 to 4 of 4

Thread: Exception handling through remote services.

  1. #1

    Default Exception handling through remote services.

    Hi folks,

    I didn't see where this had been discussed before, so please forgive me if this is a duplicate.

    I would like to be able to elegantly handle exceptions across the HttpInvoker remoting interface. After an exhaustive search, I decided to wrap the exceptions that occur on the server side up in a serializable object and make this wrapper object the universal return value for all of my service methods. On the client side, I've created proxies that unwrap the object and either re-throw the appropriate exception or return the value that would have normally been expected. The problem is that this just feels very clunky and it's not very elegant for creating lots of services.

    Has anyone else found a good way to handle this problem?

    Thanks,
    Dave

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    What exactly is the problem? Why do you need to wrap the exceptions?

    I decided to wrap the exceptions that occur on the server side up in a serializable object and make this wrapper object the universal return value for all of my service methods
    Spring does this for you automatically. Have a look at RemoteInvocationResult and RemoteInvocationBasedExporter#invokeAndCreateResul t()

    Ollie

  3. #3

    Default

    Thanks for the heads-up. This is the first time that I've seen any evidence that Spring will pass the server-thrown exception through to the client in some fashion. None of the books I have and none of the examples that I've seen appear to take advantage of this.

    It appears from looking at the RemoteInvocationBasedExporter.invokeAndCreateResul t() method that it might throw an InvocationTargetException in my case where my application may throw some unhandled exception during the service execution. I just need to make sure that the information in that exception is something useful to the client.

    Thanks again,
    Dave

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    Thanks for the heads-up.
    No worries. It's always a good idea to try something out rather than just assuming that it doesn't work especially with Spring where there's lots of functionality not all of which is documented.

    It appears from looking at the RemoteInvocationBasedExporter.invokeAndCreateResul t() method that it might throw an InvocationTargetException in my case where my application may throw some unhandled exception during the service execution.
    No. It will throw the same exception that was throw on the server.

    Ollie

Similar Threads

  1. Replies: 2
    Last Post: Nov 7th, 2005, 06:41 AM
  2. Replies: 1
    Last Post: Oct 4th, 2005, 06:11 PM
  3. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  4. Replies: 0
    Last Post: Jul 11th, 2005, 05:49 PM
  5. Replies: 3
    Last Post: Nov 8th, 2004, 07:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •