I think, therefore I blog

java.lang.ClassFormatError Exception With EclipseLink Static Weaving [SOLVED]

By , 19 March 2012

java.lang.ClassFormatError Exception With EclipseLink Static Weaving [SOLVED]
java.lang.ClassFormatError Exception With EclipseLink Static Weaving [SOLVED]

Here's an interesting exception that slapped me when I tried out using the EclipseLink static weaver on against a fresh Maven pom.xml for Java EE Web projects. The same exception occurs with the OpenJPA enhancer.

Executing tasks
     [java] Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/ValidationMode
     [java] 	at java.lang.ClassLoader.defineClass1(Native Method)
     [java] 	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
     [java] 	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
     [java] 	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
     [java] 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
     [java] 	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
     [java] 	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
     [java] 	at java.security.AccessController.doPrivileged(Native Method)
     [java] 	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     [java] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     [java] 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     [java] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
     [java] 	at org.apache.openjpa.persistence.PersistenceProductDerivation.configureBeanValidation(PersistenceProductDerivation.java:241)
     [java] 	at org.apache.openjpa.persistence.PersistenceProductDerivation.beforeConfigurationLoad(PersistenceProductDerivation.java:214)

It turns out this obscure error is because the default Java EE jars do not contain any actual code. To fix it, change your Java EE dependencies from

    <!-- Java EE libraries -->


    <!-- default Jave EE jars don't include code necessary fo
         bytecode enhancement so we use these instead -->

You will also need to add the JBoss repository to your pom.xml if you aren't already using it:

      <name>JBoss repository</name>
java.lang.ClassFormatError Exception With EclipseLink Static Weaving [SOLVED]

About Roger Keays

java.lang.ClassFormatError Exception With EclipseLink Static Weaving [SOLVED]

Roger Keays is an artist, an engineer, and a student of life. Since he left Australia in 2009, he has been living as a digital nomad in over 40 different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, and finding good food. Click here to subscribe to his weekly blog, or stalk him on Facebook and Twitter.

Leave a Comment

Please visit https://RogerKeays.com/java-lang-classformaterror-exception-with-eclipselink-static-weaving-solved to add your comments.

Comment posted by: , 3 years ago

Not sure, but check what version of the Java EE jars you are compiling against. Maybe the ones in your build don't include code either.

Comment posted by: Usman, 3 years ago

I am having this java.lang.ClassFormatError Absent Code attribute can you help me to resolve this issue ..... i am not using maven.

Comment posted by: ivan, 3 years ago

 thanks man,
this has been of great help!

Comment posted by: skylie, 3 years ago

 good job! this was helpfull for me, thanks! :)

Join Over 1000 Subscribers

I write every Sunday about travel, psychology, and technology. Thousands of people just like you have already subscribed—and for good reason. It'll change your life. And it's free :)

Read a Good Book

“A spellbinding true story of love, passion and adventure. One can’t help but be swept away by 100% Love Guaranteed.” —Dr Tammie Matson, author of Elephant Dance.

Chat For A While

Your Vote Matters

Which animal will take over when humans go extinct?