Announcement Announcement Module
Collapse
No announcement yet.
ClassFormatError: Absent Code attribute... ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ClassFormatError: Absent Code attribute... ?

    I'm getting the following error in output from tests:
    rg.springframework.beans.factory.support.DefaultLi stableBeanFactory ERROR Destroy method on bean with name 'vendorKeyFilter' threw an exception
    java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/TransactionRequiredException
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java :620)
    ....

    for almost every bean I create. In this case, the VendorKeyFilter contains an autowired KeyRepository, defined in the context file like this:
    <bean id="keyDao" class="com.lexi.db.KeyRepository">
    <property name="dataSource" ref="writeDataSource" />
    </bean>


    Any ideas?

  • #2
    You probably just have the Java EE 5 jar in your classpath, but that's unfortunatly not enough, because this jar lacks some method bodies. So you need an actual implementation, e.g. include the Glassfish JPA implementation in the classpath and it should work. If you use maven, the following snippet may help:

    Code:
            <dependency>
                <groupId>net.java.dev.glassfish</groupId>
                <artifactId>glassfish-persistence-api</artifactId>
                <version>b32g</version>
            </dependency>
            <dependency>
                <groupId>javaee</groupId>
                <artifactId>javaee-api</artifactId>
                <version>5</version>
                <scope>provided</scope>
            </dependency>
    Beware to keep the above order so that the Glassfish jar comes first in the classpath. Otherwise it will not work either.

    Comment


    • #3
      my wordaround for this issue in NetBeans

      Comment out this one
      <!-- <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-web-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
      </dependency>-->

      Replace with the following dependencie:

      <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
      <scope>provided</scope>
      </dependency>
      <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
      <scope>provided</scope>
      </dependency>

      (if you are working with other app servers other than GlassFish,
      you might also need this one)
      <dependency>
      <groupId>javax.persistence</groupId>
      <artifactId>persistence-api</artifactId>
      <version>1.0</version>
      </dependency>

      Comment


      • #4
        pzgyuanf, thank you! You save my day!

        Comment

        Working...
        X