Adam Bien's Weblog

JavaEE 7 Heals Crippled Jars And java.lang.ClassFormatError

JavaEE 6 APIs in Maven central were only usable for compiling. Any attempt to load the classes from

would result in:

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/LockModeType
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(
        at java.lang.ClassLoader.defineClass(
        at Method)

The official Java EE 7 APIs do not have that problem any more:


If you are starting with JavaEE 7, just use the Essential Java EE 7 POM

When I spotted the "crippled" dependency in JavaEE 6 projects, I always asked "Do you write Unit Tests?". "Yes" answers were not honest. Now Java EE 7 killed my litmus tests :-)

The whole example with workaround was checked into The name of the project is: MavenUnitTestWithCrippledAPI. Just increase the dependency version to 7.0 and the unit tests should pass without any workarounds needed.

See you at Java EE Workshops at MUC Airport!

NEW dates, new workshop: Java EE 7 Workshops: Bootstrap, Effective, Architectures, JavaScript Bootstrap and HTML 5 December, 7th-11th
NEW: Effective Java EE 7 -- Available For Streaming


A book about rethinking Java EE Patterns


Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments