Search code examples
javamavenapache-tomee

is there a tomee-maven-plugin version that support Java 14?


I am using tomee-maven-plugin version 8.0.5 (The latest found on mvn repository) to generate an executable Jar of my JSF Project,

</plugin>
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId> </artifactId>
<version>8.0.5</version>
 <executions>
   <execution>
     <id>executable-jar</id>
      <goals>
           <goal>exec</goal>
      </goals>
      <phase>package</phase>
    </execution>
  </executions>
</plugin>

The package command works fine and I got the War and Jar but when I launch the Server

java -jar MyJar.jar 

I am using Java 14 The deploiement on Tomee is working fine in Eclipse , The app loading causes this error :

        Caused by: org.apache.openejb.OpenEJBException: Unable to create annotation scanner for web module MonProjet-0.0.1-SNAPSHOT: Unable to read class definition for gestion.controller.GuestServiceControler
            at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:886)
            at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java:233)
            at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:2361)
            ... 44 more
    Caused by: java.lang.RuntimeException: Unable to read class definition for gestion.controller.GuestServiceControler
            at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1180)
            at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:153)
            at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java:166)
            at org.apache.openejb.config.FinderFactory$OpenEJBAnnotationFinder.<init>(FinderFactory.java:546)
            at org.apache.openejb.config.FinderFactory.newFinder(FinderFactory.java:267)
            at org.apache.openejb.config.FinderFactory.create(FinderFactory.java:80)
            at org.apache.openejb.config.FinderFactory.createFinder(FinderFactory.java:69)
            at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoader.java:878)
            ... 46 more
    Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 58
            at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:195)
            at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:176)
            at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:162)
            at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:283)
            at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1176

I did my researchs about this and the problem is in the "org.apache.xbean.asm7" dependency, I was trying to override this dependency by forcing the plugin to use "org.apache.xbean.asm8" but it didn't work and there is no other versions of Maven plugin to use Does anyone have more information about this ? Thank you


Solution

  • Older TomEE <= 8.0.6 are still using a shaded version of asm7, which has only limited support for newer Java versions (max. JDK 13). This also affects several transiend dependencies of Tomee such as OWB, CXF, etc.

    Actually, were was some work related to JDK 16 as well as some open pull requests pending in order to support JDK16 with the next TomEE release:

    From my experience, TomEE 8.0.6 runs fine with JDK11. So for now, you should go with JDK11 and wait until the next TomEE release with the related changes is out.

    Update (15.04.2021)

    I am currently running a TomEE 8.0.7-SNAPSHOT (Plume) with JDK-16 (it also works with the Maven Plugin).

    For now, the following adjustments are necessary:

    1. You need to remove OpenJPA 3.1.2 and its transient asm8 dependeny in <libs> via <lib>remove:openjpa</lib> and <lib>remove:xbean-asm8-shaded</lib> and re-add the latest 3.1.3-SNAPSHOT via <lib>org.apache.openjpa:openjpa:3.1.3-SNAPSHOT</lib>

    2. For now, it requires to specify <args>--illegal-access=permit</args> in the plugin configuration to allow some reflection and other stuff. Java 16 switched the default.

    Update (10.10.2022)

    TomEE 8.0.9 supports JDK17 out of the box.