Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i run jersey 2.26 with JDK 1.7?

I'm using JDK1.7 for my application.

I upgrade jersey 2.26 and now I am getting the error :

严重: Servlet [Jersey Web Application] in web application [/spcsis-1.0] threw load() exception
java.lang.UnsupportedClassVersionError: org/glassfish/jersey/servlet/ServletContainer : Unsupported major.minor version 52.0 (unable to load class org.glassfish.jersey.servlet.ServletContainer)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3129)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1341)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1827)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1701)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1146)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1085)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5318)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5610)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

I've change the jdk to 1.8 and then it works, but i have to use jdk1.7 for my project .

somebody can help me to do it?

like image 243
pangguoming Avatar asked Jul 20 '17 09:07

pangguoming


3 Answers

From Jersey 2.26, all modules support only Java SE 8

See jersey dependencies:

Until version 2.6, Jersey was compiled with Java SE 6. This has changed in Jersey 2.7.

Up to version 2.25.x almost all Jersey components are compiled with Java SE 7 target. It means, that you will need at least Java SE 7 to be able to compile and run your application that is using latest Jersey. Only core-common and core-client modules are still compiled with Java class version runnable with Java SE 6.

Since Jersey 2.26, all modules are build using Java SE 8 and there is no support for running it on older Java SE distributions.

like image 127
user7294900 Avatar answered Oct 10 '22 03:10

user7294900


You have to use Jersey up to the 2.13, this is the last version which has been compiled by the JDK 1.7 (please look at the MANIFEST inside the JAR).

like image 1
Antonio Petricca Avatar answered Oct 10 '22 04:10

Antonio Petricca


Your only option would be to rebuild jersey using Java 7.

like image 2
leftbit Avatar answered Oct 10 '22 02:10

leftbit