I am currently migrating my application from Java 7 to Java 8 and currently I am running the Spring 3.1.6 jar. Would this be compatible with Java 8 or I need to upgrade the Spring jar ?
I understand that the Spring 4x version has natural support for Java 8, but this is time critical and I am seeking to change as little jars as I can.
Spring Boot 2.7. 5 requires Java 8 and is compatible up to and including Java 19.
Spring 5 supports Java EE 7 and also compatible with Java EE 8. So we can use Servlet 4.0, Bean Validation 2.0, JPA 2.2 in our applications. We can also use their older versions i.e. Servlet 3.1, Bean Validation 1.1, JPA 2.1. Spring 5 applications preferred server versions are Tomcat 8.5+, Jetty 9.4+ and WildFly 10+.
Incompatibilities between Java SE 8 and Java SE 7. Java SE 8 is strongly compatible with previous versions of the Java platform. Almost all existing programs should run on Java SE 8 without modification.
By default, Spring Boot 1.4. 1. RELEASE requires Java 7 and Spring Framework 4.3.
Basically Spring 3.x
versions supports up to Java-7
only. If you want to migrate to Java-8
you should use Spring 4.x
version.
However some spring release notes says that the
Spring Framework 3.2.x
will support deployment onJDK 8
runtimes for applications compiled againstJDK 7
(with -target 1.7) or earlier. Note that it won’t supportJDK 8
’s bytecode format (-target 1.8, as needed for lambdas); please upgrade toSpring Framework 4.0
for that purpose.
Follow this link to the source article.
No it is not compatible. I've run into the same issue and while many will say that Java 8 is completely backwards compatible with older versions of java, this turns out not to be true.
This has a very good explaination of the exact problem I ran into java 7 targeted code with java 8.
https://gist.github.com/AlainODea/1375759b8720a3f9f094
Because the API of ConcurrentHashMap has changed between the 2 java releases, spring breaks on startup and you end up with
SEVERE: Context initialization failed
java.lang.NoSuchMethodError: java.util.concurrent.ConcurrentHashMap.keySet()Ljava/util/concurrent/ConcurrentHashMap$KeySetView;
at org.apache.catalina.core.ApplicationContext.getInitParameterNames(ApplicationContext.java:368)
at org.apache.catalina.core.ApplicationContextFacade.getInitParameterNames(ApplicationContextFacade.java:367)
at org.springframework.web.context.support.WebApplicationContextUtils.registerEnvironmentBeans(WebApplicationContextUtils.java:201)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.postProcessBeanFactory(AbstractRefreshableWebApplicationContext.java:163)
I had no choice to but upgrade to Spring 4.x (not sure if 3.2 or above would have worked as I jumped straight to 4.x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With