Results 1 to 4 of 4

Thread: ClassFormatError: Absent Code attribute... ?

Hybrid View

  1. #1

    Default 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. #2
    Join Date
    Sep 2008
    Posts
    1

    Default

    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.

  3. #3
    Join Date
    Oct 2008
    Posts
    6

    Default 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>

  4. #4
    Join Date
    Jan 2013
    Posts
    1

    Default

    pzgyuanf, thank you! You save my day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •