I'm sure this is the worst of all possible post types (e.g., no behavior rather 
than an error that one can diagnose).  I am trying to write a very simple EJB 
3.0 interceptor that will perform error logging and auditing.  The interceptor 
itself is in a separate class and is referenced via the @Interceptors 
annotation in a SLSB.  When viewing my logs, I never see any of the error 
messages output.

Or there might be a simple explanation, "We have not yet implemented 
interceptors in JBoss-4.0.04-GA".  :^)

My thanks in advance for any assistance anyone can render.  

- Saish



--- ERRORINTERCEPTOR.JAVA ---

public final class ErrorInterceptor extends Object {

        @AroundInvoke
        public final Object isDatabaseAlive(final InvocationContext ctx)
                throws Exception {
                
                // NEITHER OF THESE EVER SHOW UP IN LOGS
                System.err.println("DEBUG >>> GOTCHA!!!");
                LOG.error("ErrorInterceptor executing method " + 
                        ctx.getMethod().toGenericString());
                try {
                        return ctx.proceed();
                }
                catch (Throwable cause) {
                        ErrorHandler.getInstance().process(cause);
                        if (cause instanceof RuntimeException) {
                                throw (RuntimeException) cause;
                        }
                        if (cause instanceof Error) {
                                throw (Error) cause;
                        }
                        if (cause instanceof Exception) {
                                throw (Exception) cause;
                        }
                        throw new UnexpectedError("Unknown exception received", 
cause);
                }
        }
}

--- HEARTBEATIMPL.JAVA ----

@Stateless
@Interceptors   ({xxx.xxx.xxx.core.aspect.aop.ErrorInterceptor.class})
@Local                  ({Heartbeat.class})
@Remote                 ({Heartbeat.class})

@LocalBinding   (jndiBinding="local:xxx/xxx/core/aspect/remote/Heartbeat")
@RemoteBinding  (jndiBinding="remote:xxx/xxx/core/aspect/remote/Heartbeat")

public final class HeartbeatImpl extends Object 
        implements Heartbeat {

        public final boolean isDatabaseAlive() throws Exception {
                
                if (true) {
                        throw new Exception("Foo bar!!!");  // TO TEST ERROR 
HANDLER
                }
                try {
                        if (dataSource == null) {
                                return false;
                        }
                        Connection conn = dataSource.getConnection();
                        if (conn == null) {
                                return false;
                        }
                        conn.close();
                        return true;
                }
                catch (SQLException e) {
                        e.printStackTrace();
                        return false;
                }
                catch (RuntimeException e) {
                        e.printStackTrace();
                        return false;
                }
        }
}

-- STACK TRACE (Note:  error is forced by code above) ---

2006-07-05 15:12:32,392 ERROR 
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/mortrac].[jsp]]
 Servlet.service() for servlet jsp threw exception
java.lang.Exception: Foo bar!!!
        at 
xxx.xxx.xxx.core.aspect.remote.HeartbeatImpl.isDatabaseAlive(HeartbeatImpl.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
        at 
org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
        at 
org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3955649#3955649

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3955649

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to