I looked into why a bean generated exception is not being reported completely and the
issue is that EJBExceptions with causedByException values should be unwrapped by
the container. Here is an example trace of a bad bean that generates an uncaught
ClassCastException:

[ejb.ProjectDirectory] java.lang.ClassCastException: 
com.dscape.projects.documents.ftp.FtpFileContents
[ejb.ProjectDirectory]  at 
com.dscape.projects.documents.ejb.ProjectDirectoryBean.lookup(ProjectDirectoryBean.java:255)
[ejb.ProjectDirectory]  at java.lang.reflect.Method.invoke(Native Method)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:722)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:247)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:204)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:343)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:144)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:323)
[ejb.ProjectDirectory]  at 
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:163)
[ejb.ProjectDirectory]  at java.lang.reflect.Method.invoke(Native Method)
[ejb.ProjectDirectory]  at 
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
[ejb.ProjectDirectory]  at sun.rmi.transport.Transport$1.run(Transport.java:142)
[ejb.ProjectDirectory]  at java.security.AccessController.doPrivileged(Native Method)
[ejb.ProjectDirectory]  at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
[ejb.ProjectDirectory]  at 
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
[ejb.ProjectDirectory]  at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:643)
[ejb.ProjectDirectory]  at java.lang.Thread.run(Thread.java:484)

Now, 
EntityContainer$ContainerInterceptor.invoke, wraps the RuntimeException in 
EJBException(re)

and
TxInterceptorCMT.runWithTransactions, wraps EJBException in ServerException(ejb(re))

so LogIntercepter.invoke does not see the EJBException that it looks for to log a bean 
error.

Because of this the error is not logged on the server side and because EJBException 
does
not print out its detail msg in printStackTrace(), the real exception type does not 
show up on
the client side. It would also be nice if the complete stack trace was generated as a 
String
on the server side and sent to the client side as the exception msg so that the client 
could
easily obtain it.

There is a whole lot of exception cactching/wrapping/rethrowing going on in the 
container layers
so I'm not sure if there is one point at which the behavior could be introduced. I 
tried making
a change to the org.jboss.ejb.plugins.LogInterceptor.invoke and this did allow me to 
get
the full stack trace back to the client, but its now too verbose because the 
ServerException I
added to LogInterceptor.invoke was wrapped in another ServerException msg and so the 
full
stack trace is printed twice.

Any thoughts on cleaning up the exception reporting?




--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to