java.lang.ClassFormatError : Absent Code attribute in method that is not native or abstract in class file …


A very strange and rare problem, happened in JPA or Hibernate development.

Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is 
        not native or abstract in class file javax/persistence/GenerationType
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(Unknown Source)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at Source)
	at Source)
	at$000(Unknown Source)
	at$ Source)
	at Method)
	at Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknow


This is always caused by the javaee.jar which is located at Many developers like to grab the javaee.jar with the following Maven coordinate :

    <!-- Javaee API -->

But, the javaee.jar from is not contains any method bodies, but the APIs name only. Which is not suitable to use for running or deploying along with your application.

The good practice is always get the original full version of javaee.jar file from the Just download and install the J2EE SDK, and the javaee.jar can be found in the “\J2EE_SDK_FOLDER\lib” folder. Include it into your local Maven repository or poject classpath will get rid of the above error message.


Tags :

About the Author

Founder of and, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.


  • Pingback: electrician bucuresti pret()

  • Pingback: locuri de munca electrician bucuresti()

  • Pingback: house blue()

  • Pingback: zak?ad szklarski piotrków trybunalski()

  • Pingback: paypal loans()

  • Pingback: plumber miami()

  • Pingback: illinois plumbing code book()

  • Pingback: locksmith jobs pa()

  • Pingback: electrician 77084()

  • Pingback: alkaline water brands()

  • Pingback: Google()

  • Pingback: water ionizer plans()

  • Pingback: water ionizers()

  • Pingback: laan penge billigt()

  • Pingback: parking()

  • Pingback: 3gp mobile porn()

  • Pingback: car parking()

  • Pingback: DIRECTV vs Dish()

  • Pingback: here()

  • Pingback: This mega-bitch had()

  • Pingback: watch free movies online()

  • Pingback: watch movies online free()

  • Pingback: Blue Coaster33()

  • Swarndeep Singh

    Getting exception while creating client. jersey-core-1.13.jar and jersey-client-1.13.jar are included as Maven dependency.

    Client c = Client.create ();


    Exception in thread “main” java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/ws/rs/core/MediaType
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(

    Please help!

  • Usman

    java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/FacesServlet
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at Source)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(
    at org.apache.catalina.loader.WebappClassLoader.findClass(
    at org.apache.catalina.loader.WebappClassLoader.loadClass(
    at org.apache.catalina.loader.WebappClassLoader.loadClass(
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(
    at org.apache.catalina.startup.ContextConfig.start(
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
    at org.apache.catalina.core.StandardContext.start(
    at org.apache.catalina.core.ContainerBase.addChildInternal(
    at org.apache.catalina.core.ContainerBase.addChild(
    at org.apache.catalina.core.StandardHost.addChild(
    at org.apache.catalina.startup.HostConfig.deployDirectory(
    at org.apache.catalina.startup.HostConfig.deployDirectories(
    at org.apache.catalina.startup.HostConfig.deployApps(
    at org.apache.catalina.startup.HostConfig.start(
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
    at org.apache.catalina.core.ContainerBase.start(
    at org.apache.catalina.core.StandardHost.start(
    at org.apache.catalina.core.ContainerBase.start(
    at org.apache.catalina.core.StandardEngine.start(
    at org.apache.catalina.core.StandardService.start(
    at org.apache.catalina.core.StandardServer.start(
    at org.apache.catalina.startup.Catalina.start(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(
    at org.apache.catalina.startup.Bootstrap.main(

    I am having this issue i am not using maven… please help me hwo to fix this problem

  • peterborough hair dresser

    I was curious if you ever considered changing the page layout of your site?
    Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people
    could connect with it better. Youve got an awful lot of
    text for only having one or two pictures. Maybe you could
    space it out better?

  • Jesper Tejlgaard


    Anamika Mishra’s approach solves problems with applications installed on a Java EE server, but it does not solve the problem for tests executed during the Maven lifecycle, because dependencies in scope provided are available at the test runtime.

    For those experiencing this problem during tests there is another solution:

    I favour this over having the full javaee.jar as part of my final application archive (war/ear)

  • paul brickell

    Seriously? That really makes unit testing my ‘POJOs’ really hard.

  • Radu

    I have got the folow error:

    Exception in thread “main” java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/ejb/EJBException

    I’ve added the following in the pom.xml file and its work. I hope to be helpful.



  • ClintJCL

    I’d like to know how to see if my JAR is an API only. It has .class files but is there a way to really tell? Do you have the filesize for the 2 different versions?

  • http://non omile

    please i need help in developing standalone application using EJB.
    first i thank all who have been contributing in java.i am new to EJB.
    my problem is :i tried to build remote application using Ejb ,
    1. i build entity bean from datebase
    2. i tried to build session bean from entity class for remote AP.
    then error=”EJB Remote Interface depends on JPA AEntity classes. JPA Entities are inaccessible if they are located in mode.” i used netbean 7.2.1.

    as i was making a research over a week ,i stormble over this solution
    1 .that i should build class library
    2. create entity bean in the class library
    3.add the class library to the already created ejeModule
    4.create persistence Unit
    5.create session bean for entity class in ejbModule .
    Great i used that to create my Remote application .

    BUT:when i tried to build my ejeModule i keep on seen this malignant error

    =”An annotation processor threw an uncaught exception.
    Consult the following stack trace for details.
    java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/PersistenceException
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(
    at Method)
    at java.lang.ClassLoader.loadClass(
    at org.eclipse.persistence.internal.helper.Helper.getField(
    at org.eclipse.persistence.internal.descriptors.InstanceVariableAttributeAccessor.initializeAttributes(
    at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(

    C:\Users\Administrator\Documents\NetBeansProjects\serva\nbproject\build-impl.xml:849: The following error occurred while executing this line:
    C:\Users\Administrator\Documents\NetBeansProjects\serva\nbproject\build-impl.xml:258: Compile failed; see the compiler error output for details.

    please i need help.i have spend over a week and some days trying to get rid of this ,please my Java gurus give me a step by step solution in this ,i am new to EJE .

  • meursaul

    My name is Meursaul, first excuse me for my English because it is not good.
    Thank you mkyong and thank you all man who contribute to this tutoriel, it is helpfull.
    I try to execute the example where you used spring+hibernate+struts and maven and i have this error:
    [ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:run (default-cli) on project aaaa: Execution default-cli of goal org.codehaus.mojo:tomcat-maven-plugin:1.1:run failed: An API incompatibility was encountered while executing org.codehaus.mojo:tomcat-maven-plugin:1.1:run: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/http/HttpServlet
    [ERROR] —————————————————–
    [ERROR] realm = plugin>org.codehaus.mojo:tomcat-maven-plugin:1.1
    [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
    [ERROR] urls[0] = file:/C:/Users/boussad/.m2/repository/org/codehaus/mojo/tomcat-maven-plugin/1.1/tomcat-maven-plugin-1.1.jar
    [ERROR] urls[1] = file:/C:/Users/boussad/.m2/repository/org/apache/maven/maven-archiver/2.2/maven-archiver-2.2.jar
    [ERROR] urls[2] = file:/C:/Users/boussad/.m2/repository/org/codehaus/plexus/plexus-archiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.jar
    [ERROR] urls[3] = file:/C:/Users/boussad/.m2/repository/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar
    [ERROR] urls[4] = file:/C:/Users/boussad/.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3.jar
    [ERROR] urls[5] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/catalina/6.0.29/catalina-6.0.29.jar
    [ERROR] urls[6] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/juli/6.0.29/juli-6.0.29.jar
    [ERROR] urls[7] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/annotations-api/6.0.29/annotations-api-6.0.29.jar
    [ERROR] urls[8] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/catalina-ha/6.0.29/catalina-ha-6.0.29.jar
    [ERROR] urls[9] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/tribes/6.0.29/tribes-6.0.29.jar
    [ERROR] urls[10] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/el-api/6.0.29/el-api-6.0.29.jar
    [ERROR] urls[11] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/jasper/6.0.29/jasper-6.0.29.jar
    [ERROR] urls[12] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/jasper-el/6.0.29/jasper-el-6.0.29.jar
    [ERROR] urls[13] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/jasper-jdt/6.0.29/jasper-jdt-6.0.29.jar
    [ERROR] urls[14] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/jsp-api/6.0.29/jsp-api-6.0.29.jar
    [ERROR] urls[15] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/servlet-api/6.0.29/servlet-api-6.0.29.jar
    [ERROR] urls[16] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/coyote/6.0.29/coyote-6.0.29.jar
    [ERROR] urls[17] = file:/C:/Users/boussad/.m2/repository/org/apache/tomcat/dbcp/6.0.29/dbcp-6.0.29.jar
    [ERROR] Number of foreign imports: 1
    [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
    [ERROR] —————————————————–
    [ERROR] -> [Help 1]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1]

    Is there someone who can help me ? Thank you :)

  • anamika mishra

    Thanks mkyong that surely explains the issue in details. Another way of solving this could be using the maven scope as provided i.e.


    . This ensures that the api only jar is used only for compilation and not at run time. Place the implementation jar in the server lib.

  • Pingback: java.lang.ClassFormatError: Absent Code attribute in method …()

  • naveed khan

    Sorry but i dont know how to add above dependencies in project..

  • Jacek

    Your directions are very helpfull.
    Many thanks for that.
    ps. make big mess whit his libraires – they are in NetBeans IDE.

  • Pingback: Hibernate Tutorials()