If an exception is thrown from a static initializer of an entity, then you get a stack trace that looks something like this:
Code:
Exception: java.lang.NoClassDefFoundError: Could not initialize class com.foo.db.Bar$$EnhancerByCGLIB$$484d1c9c
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:616)
net.sf.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:609)
net.sf.cglib.proxy.Enhancer.registerCallbacks(Enhancer.java:578)
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyInstance(CGLIBLazyInitializer.java:110)
...
The problem is that the NoClassDefFoundError exception is not initialzed with the original Exception that was thrown from the static initializer (getCause() returns null). Has anyone found a way to get at the original exception, or in general improve this situation? Thanks!