java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation
Asked Answered
C

2

2

Using maven to add activemq, there is a problem about conflicting jar when I unit-test in IDE, the exception message is:

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation

i have excluded the validation from javaee, as following:

   <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
        <exclusions>
            <exclusion>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-jms_1.1_spec</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

and dependency for activemq is

  <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-all</artifactId>
        <version>${activemq_version}</version>

        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
            </exclusion>

            <exclusion>
                <groupId>org.fusesource.fuse-extra</groupId>
                <artifactId>fusemq-leveldb</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

this is an annoying problem.

anyone would like to give some point? Help much appreciated!

Compulsory answered 12/9, 2012 at 8:39 Comment(0)
T
2

The dependency javax::javaee-api contains stripped classes which contain no method implementations as described here. You can use the API JAR provided by JBoss instead:

<dependency>
    <groupId>org.jboss.spec</groupId>
    <artifactId>jboss-javaee-6.0</artifactId>
    <version>1.0.0.Final</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>
Tamanaha answered 14/2, 2013 at 19:55 Comment(0)
C
1

I know it is very old question but I have had this issue recently and I've found an easy solution that may work for someone in the future.

Due to the validator-api cannot be removed from javaee-api (it is not imported as a dependency) The trick is to use javaee-api version 8.0 (it also contains validation-api inside but the factory works) and you can avoid adding validation-api, would be something like:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>8.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.el</artifactId>
    <version>3.0.0</version>
</dependency>

That's it.

Constellation answered 20/1, 2022 at 10:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.