Announcement Announcement Module
Collapse
No announcement yet.
Spring Proxy error handling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Proxy error handling

    I'm using spring 1.1.2 and am concerned with the behavior of proxying classes.

    I am proxying a class with the intent of adding some aop methods later.

    The behavior I was seeing was a java.lang.reflect.InvocationTargetException
    exception being displayed as a webservice fault.

    I initially thought it was something incorrect in my axis config files, but after several hours of trying to track it down, I finally figured out the problem.

    Torque is being used on the backend for persistence. Torque expects to be initialized before being used. So when I called Torque.getConnection() in my code, it threw a TorqueException.

    I had stubbed out a ServletContextListener but forgotten to fill it in.

    Here is where I have a problem. When the Torque exception was thrown my try/catch block was totally ignored. Infact, once the Torque.getConnection() threw the TorqueException, the proxy layer took over control of the app and did not let my try/catch block throw an exception which was specified by the methods signature and should have been handled properly by the proxy, thus propagating the proper message to the webservice client.

    By using an unproxied class, the class behaved as it should have.

    Is this a know issue? If my try/catch block had been executed as it should have, the proper message would have been propagated to the client and fixed in 1 minute rather than several hours. Rather spring proxy saw an exception which did not match the method signature and threw the InvocationTargetException.

  • #2
    Can you post your configuration and the class code? I have created a simple test case in the CglibAopProxyTests class to test that catch and finally blocks are invoked in proxies and that passes okay. You can get this test class from the Spring CVS.

    Perhaps this is something to do with Torque or another component in your system.

    Comment


    • #3
      I beleieve I solved the problem after looking through the Torque source

      the getConnection() method throws a NullPointerException which is unchecked. I believe the NPE and using a proxy would produce the exhibited behavior, however I was unable to reproduce the error in a test case.

      I don't have time to mess with it right now as a deadline is looming.

      Thanks for the help. I'll post any thing else I find when I get a chance to examine it more.

      Doug

      Comment

      Working...
      X