December 21, 2014

Java EE 6 Maven Dependency

The EE 6 classes are available in maven central.

<dependency>
    <groupid>javax</groupid>
    <artifactid>javaee-api</artifactid>
    <version>6.0</version>
    <scope>provided</scope>
</dependency>

But when running unit test against them you receive the below error. Thats because they do not contain implementation classes, only api class.

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/LockModeType
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

So in practice, the dependecy is in real life unusable. Instead you must use api classes from specific vendors like JBoss.

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

No comments: