"Could not initialize class" error at runtime
Symptoms
Execution of tests or a standalone application terminates with an error message similar to the following:
Could not initialize class com.acme.MyClass$__CLR3_2_02t2thng9gff
or from Maven:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.acme.MyClass$__CLR3_2_02t2thng9gffc
or from JBoss:
org.jboss.arquillian.container.spi.client.container.DeploymentException: Could not deploy to container: ...
Caused by: javax.persistence.PersistenceException: ...
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
Caused by: org.hibernate.InstantiationException: could not instantiate test <some test name>
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.acme.MyEntity$__CLR3_1_12b0b0hlfzxawo
Cause
In 99% of cases this is caused by a fact that clover.jar is missing in runtime. Please keep in mind that it's not enough to have clover.jar during compilation - classes instrumented by Clover needs Clover's core classes from clover.jar during application (or test) execution.
Please have a look at solutions in a related article: NoClassDefFoundError com_atlassian_clover/CoverageRecorder.
References