Search code examples
javamaventomcat8java-11tomee-7

Fail to deploy bare bone webapp to tomee 7.1.0 running openjdk 11


I am planning to migrate a webapp from java 8/tomee 7.0.4 to java 11/tomee 7.1.0, but still unsuccessful. So I write a barebone webapp with only one facelet page and one managed bean. This works on java 10/tomee 7.1.0 but not java 11. The errors are:

java.lang.IllegalStateException: Cannot get Unsafe.defineClass
....
java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String, [B, int, int, java.lang.ClassLoader, java.security.ProtectionDomain)

After some Googling, from http://tomee-openejb.979440.n4.nabble.com/Some-jars-in-TomEE-8-SNAPSHOT-are-not-Java-11-compatible-td4685162.html it seems that the problem originates from jaxb-impl. So I tried adding to pom.xml according to https://winterbe.com/posts/2018/08/29/migrate-maven-projects-to-java-11-jigsaw/ which failed. I restored pom.xml and modified according to Java 11 package javax.xml.bind does not exist which also failed.

This is for tomee server which is less popular. But tomee 7.1.0 is based on tomcat 8.5 which should be much more popular. I think the problem will still be the same.

Advice is appreciated and I think many people should have the same problem.


Solution

  • Try upgrading your tomcat/tomee to the latest version, or downgrading your Java version as incompatible versions tend to fire these NoSuchMethod/NoSuchFile exceptions.

    Could be that one technology is reliant on a certain other technology, and is aware of a certain API version, but you are trying to use a higher API version, which could be entirely different.

    Another possibility is that tomee is not yet ready to work with java 11 at all (but this seems rather unlikely).