There seems to be some major difference between these two styles of EJBException creation. I ran into this working on a CMP example I intend to use for the whole CMP+JPA->JPA merging logic. The real error is that I forgot to implement "setEntityContext" which is an easy mistake to make as the CMP2 bean class is abstract and compiles just fine without it. I got the first stack trace below, which is useless, and decided on a whim to tweak EjbHomeProxyHandler line 213 to the second style shown below. I was and am shocked at the difference in the stack trace.

[Style 1]   throw new EJBException(re.getMessage(), (Exception) detail);
Yields:
java.lang.ClassCastException: java.lang.AbstractMethodError
at org .apache .openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java: 213) at org .apache .openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java: 274)
        at org.superbiz.cmp2.$Proxy26.create(Unknown Source)
        at org.superbiz.cmp2.MoviesTest.test(MoviesTest.java:51)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 39) at sun .reflect .DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 25) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)


[Style 2]   throw new EJBException(re.getMessage()).initCause(detail);
Yields:

javax.ejb.EJBException: The bean encountered a non-application exception.; nested exception is: java.lang.AbstractMethodError: openejb.org.superbiz.cmp2.MovieBean.setEntityContext(Ljavax/ejb/ EntityContext;)V at org .apache .openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java: 213) at org .apache .openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java: 274)
        at org.superbiz.cmp2.$Proxy26.create(Unknown Source)
        at org.superbiz.cmp2.MoviesTest.test(MoviesTest.java:51)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 39) at sun .reflect .DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 25) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32) Caused by: java.lang.AbstractMethodError: openejb.org.superbiz.cmp2.MovieBean.setEntityContext(Ljavax/ejb/ EntityContext;)V at org .apache .openejb.core.cmp.CmpContainer.setEntityContext(CmpContainer.java:318) at org .apache .openejb.core.cmp.CmpContainer.createEJBObject(CmpContainer.java:592) at org.apache.openejb.core.cmp.CmpContainer.invoke(CmpContainer.java: 250) at org .apache .openejb.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java: 267) at org .apache .openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java: 158)
        ... 21 more


Able to verify the stack trace behavior is this way in both intellij and maven. Obviously the stack trace for style #1 completely obfuscates the problem which is itself a big problem.

Anyone have any idea, what causes this difference?

Needless to say, I'll shortly be switching all our code over....

-David

Reply via email to