0

I am trying to deploy a Hibernate test project on an Application Server (tried Glassfish 5.0.1 & Tomcat 9.0.64) but I get the following error:

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsupportedClassVersionError: jakarta/ws/rs/core/FeatureContext has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (unable to load class [jakarta.ws.rs.core.FeatureContext])

I have to mention that I created this project using IntelliJ IDEA, because yesterday I was working on another project, which I created using the command described in Jersey Documentation,

mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false -DgroupId=com.example -DartifactId=simple-service-webapp -Dpackage=com.example -DarchetypeVersion=2.36

and it worked on both servers. My JRE and JDK are on same version (Java 8) and I would like to avoid changing it.

enter image description here

I had the same problem yesterday, when I tried to create a Project using IntelliJ IDEA. Any IDEA what could have caused this?

  • The fact is that: `jakarta/ws/rs/core/FeatureContext` is being compiled with a newer version of Java (JDK11) which means if you like to use that dependency you have to use JDK 11 ...otherwise you have to check for older versions of the dependency and use that.. – khmarbaise Jul 22 '22 at 14:36
  • I did not import this dependency by myself. Can I somehow override it? – Fotis Kolytoumpas Jul 22 '22 at 14:38
  • That you check from where it is coming...it is a transitived dependency..you can check that via IntelliJ (there is plugin which shows the tree) or you can check via `mvn dependendy:tree` on command line and find out where the dependency is coming from... – khmarbaise Jul 22 '22 at 14:45

1 Answers1

0

The problem was that one of the dependencies' version was not compatible with my JRE version.

I specified the version attribute for jersey-container-servlet-core in pom.xml file to be 2.36 which is compatible with JRE 1.8, and then built the project again.

<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet-core</artifactId>
    <version>2.36</version>
</dependency>

So if you get this error, you probably have to check your dependencies compatibility with your current JRE version.

  • No, that does not mean it is compiled with your local JDK. A JAR file that's included as a dependency is not (re)compiled. That you don't get the error anymore just means that nothing in your code is actually loading / using the classes in that JAR file. – Jesper Jul 22 '22 at 15:37
  • This was the case before doing the procedure above. I never used this package in my code... It's a package I get every time I create a Java EE project using IntelliJ IDEA. I have spent so many hours looking for solutions on the internet, but I still can't understand what is going on... – Fotis Kolytoumpas Jul 22 '22 at 15:43