4 Replies Latest reply on Feb 13, 2009 1:08 PM by bonerandi

    hanling exception ignored

    bonerandi

      Hi
      I would like to test the management of Hibernate errors in my application.

      I encoded an aspect :

      public class SQLDeadlockExceptionInjector
      {
       /**
       *
       * @param invocation
       * @return
       * @throws Throwable
       */
       public Object throwDeadlock(Invocation invocation) throws Throwable
       {
       throw new HibernateException("",new SQLException("Oracle Deadlock", "12345", 23000));
       }
      }


      My jboss-app.xml

      <aop>
      
       <aspect class=" SQLDeadlockExceptionInjector" scope="PER_INSTANCE"/>
       <bind pointcut="call(* $instanceof{net.sf.hibernate.Session}->saveOrUpdate(..) throws net.sf.hibernate.HibernateException)">
       <advice name="throwJDBCException" aspect=" SQLDeadlockExceptionInjector"/>
       </bind>
      
      
      </aop>



      This aspect handling exception in application but it was nener catch by the handler

      try{
      
       session.saveOrUpdate(Object)
      
      } catch (HibernateException ex) {
      
      .........
      particular treatment
      .........
      
      }


      why error is never handling by the catch ?

      how to test the correct treatment of error with aop ?

      thanks a lot







        • 1. Re: hanling exception ignored
          flavia.rainone

          Hi,

          There is a space before the name of the aspect. This space could be messing with your JBoss AOP... try removing it.

          Plus, remember that you must specify the complete names of everything in the XML. So, is your SQLDeadlockExceptionInjector aspect in the default package? If not, you must specify the name of the package it is in.

          Let me know if this fix your problem.

          • 2. Re: hanling exception ignored
            bonerandi

            Hi,
            The space before the name of the aspect is just a copy paste error.
            The exception is correctly throw by the aspect but is never handle by the catch.

            I would to test the correct treatment of error in my catch.

            Thanks

            • 3. Re: hanling exception ignored
              kabirkhan

              Which version of AS are you on? What you suggest is not be possible on AS 4.x since hibernate3.jar is in the lib/ folder, so the classes are loaded before server/xxx/deploy/jboss-aop.deployer is deployed.

              Unfortunately, even if you use compile-time weaving, you will still have problems since hibernate3.jar is deployed in a classloader that is the parent of loader containing the aop stuff. So basically on AS 4 you can only really aspectize the classes deployed as part of a deployment in the serve/xxx/deploy folder. I am not sure if anything else would work in AS 5 as it stands, but it could probably be made to work there.

              • 4. Re: hanling exception ignored
                bonerandi

                Hi,

                My version of Jboss AS is 4.0.4.
                My version of Jboss - aop is 1.5.6.
                Hibernate 2.8 is in /lib folder of server.

                The HibernateException is correctly throw by the aspect but the catch is not efficient.