users@glassfish.java.net

problem catching the exception in the bean interceptor

From: <glassfish_at_javadesktop.org>
Date: Thu, 10 Sep 2009 19:33:27 PDT

I am facing this problem hope to find some solution. Here is the scenario,

I have an ejb interceptor which basically looks like this

EJBInterceptor
{

@AroundInvoke
        public Object handleExceptions(InvocationContext context) throws Exception
        {
                Exception exception = null;
                Object result = null;
                
                try
                {
                        result = context.proceed();
                }
                catch (Exception e)
                {
                        exception = e;
                }
                finally
                {
                         // some custom functions to do logging....
                }
}

I have two types of entities A and B. B has reference to A through JPA annotation and also in the database. There is no cascade delete option defined in the database on B though. The relation is a Uni-directional from B -> A in JPA.

 Now i call a stateless sesson bean to delete entity A. The problem is i am getting database exceptions in the server log saying that B refers A. However, i am unable to catch in the interceptor. Any thoughts?? I can do work around by deleting B but i still want to know the reason why the interceptor could not catch the exception...

thanks in advance,
[Message sent by forum member 'eligetiv' (eligati_999_at_yahoo.com)]

http://forums.java.net/jive/thread.jspa?messageID=363676