Spring 3.2.x with Java 8 - java

We are currently using spring 3.2.9. We are thinking of upgrading that to a newer version. When I checked the documentation it says that
Along with 4.0 M1, we’ve released Spring Framework 3.2.3, containing
fixes for recently reported issues but also coming with OpenJDK 8 runtime
support. Spring Framework 3.2.x will support deployment on JDK 8 runtimes
for applications compiled against JDK 7 (with -target 1.7) or earlier.
Does that imply that I can't compile on Java 8?
Should I use spring version 4.0.x if I wanna compile with Java 8?

There is a best effort support of JDK8 in the 3.2.x line, as of 3.2.9+.
See SPR-11656 for initial support in 3.2.9 and SPR-11979 for bytecode support improvements in 3.2.10. Please note the support limitations explained in the comments.
For comprehensive support of JDK8, please upgrade to Spring 4.x - there's a dedicated wiki page explaining the upgrade path, and the Spring team made great efforts to make that upgrade experience really easy.

As per my observations, you can actually use spring 3 with code compiled in Java 8, as long as you do not use new java8 syntax in there (like lambdas) in the paths scanned.
So, you can use new APIs (streams ...), but not new syntax (lambdas...).
When I tried, I ended up with startup errors like org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class

Versions of the Spring Framework that are older than 4.0M1 do not work with classes that are compiled for Java 8.
Spring tries to Proxy these classes by reading class files, which won't work if they're "too new". If your #Service classes are compiled with Java 8 as the target, Spring will fail to load the classes on startup.
This means that you will have to upgrade to Spring 4.x.x, if you want to target Java 8 (and use lambdas, default implementations and so on).
I encountered this problem myself a few months ago with a project that uses Spring 3.x.x.

Related

Spring 5.1.5.RELEASE what should i think to chose a JVM version

I am having an application running on JAVA - AIX platform, I am trying to move my spring application to Spring version 5.1.5.RELEASE.
I cannot upgrade my JVM which is currently in version 'J9VM - R28_20170209_0201_B336038'
The application does run in the above JVM version, but I am not sure if I have to upgrade to the latest JVM too to benefit on the latest Spring version!?
Is there any documentation on the JVM to chose for a spring version?
PS: My application does not work on any higher JVM version, which I have to sort out first.
See JDK Version Range on the Spring Framework Versions page, which currently says:
Spring Framework 5.1.x: JDK 8-12
Spring Framework 5.0.x: JDK 8-10
Spring Framework 4.3.x: JDK 6-8
We fully test and support Spring on Long-Term Support (LTS) releases of the JDK, i.e. currently JDK 8 and 11 (both with a lifetime until 2023). Additionally, there is support for intermediate releases such as JDK 9/10 or the upcoming JDK 12 on a best-effort basis, meaning that we accept bug reports and will try to address them as far as technically possible but won't provide any service level guarantees.
Please upgrade to Spring Framework 5.1 (and the corresponding Spring Boot 2.1) for JDK 11 support, as the common Long-Term Support migration path from JDK 8. No earlier Spring versions are officially supported on JDK 11, in particular not with JDK 11 bytecode level. Note that third-party components might not fully support JDK 11 yet, so you are likely to be limited in your full-stack options.

Spring 3.2.x, Hibernate 3.x and Java 11. Fully incompatible?

We have a huge project with a lot of obsolete code and dependencies including spring-core, hibernate, spring-security and a lot more.
Having in mind that we have to migrate this project on JDK 11.
Our first attempt was just to build project with JDK 11. In some cases it worked, but when integration tests were to run, spring(ASM) confused with bytecode. Having read answers on this topic i saw that starting from spring 5 Java 11 is supported. So updating to newest frameworks would be great decision but.. A huge amount of work needs to be done, so much that we cannot even estimate it. My answer is: Have anyone tried running spring 3 on new java versions (8 works fine) or is there an opportunity to do that. Maybe some kind of dependency replacement - to use newer ASM etc or to fork spring and make some changes there? What do you think?

Do I need Spring 5 for Java 9?

Spring 5 is promoted as "with support for JDK 9", meanwhile the documentation for Spring 4.3.13 states that it supports Java 8 (as well as 6 and 7).
Does this mean that I need to upgrade to Spring 5 before I can
run my application in JRE 9?
compile my application using JDK 9?
Spring
On the official Spring blog, they announced that Spring 4.2 would support Java 7 and 8 (it didn't change in 4.3), and they also said that Spring 5 would support Java 9.
It is implied that Spring 4 won't support Java 9.
But it depends of what you're doing: on this blog, the writer is testing Java9 on Spring 4 and he said:
However, before we begin, a quick disclaimer: I will be demonstrating migrating Spring 4.x/Spring Boot 1.x applications to Java 9. As far as I have heard, there will be little to no formal support for either in Java 9. So far, I haven’t run into many issues once I have gotten the applications running, however, as these are primarily proofs of concept, they have not been thoroughly vetted.
Because "doesn't support" only means you're not sure of the comportment, If you're using anything that changed in Java9, you should consider migrating (unless you can test it first).
Spring Boot
Spring boot 1.x does not support Java9. If you want to use it, you have to migrate to Spring Boot 2.x.
Actual
For all that sake, if you are planning to compile your code built with Spring 4.x with Java9 it should just work fine based on the backword compatbility of Java9 which has though been in question for certain implementations and the precise answer there would be dependent on your usage of spring as and when you move ahead and try out things.
Theories
The 5.0.0-RC1 release of Spring framework was announced with the support for Java 8+. The announcement included the theme declared for Java9 pertaining development as well:-
Ready for JDK 9: fully aligned with JDK 9 at runtime, on the classpath
as well as the module path (on the latter: as filename-based
“automatic modules” for the time being).
This candidate is currently available since November 1, 2017 which can be used from
repositories {
maven { url 'http://repo.spring.io/libs-milestone' }
}
compile "org.springframework.integration:spring-integration-core:5.0.0.RC1"
The certain good news to look for on that note would be :
We expect GA in a couple weeks - just in time for Spring Boot 2.0 GA!
Pertaining to Spring Boot with Java 9, the requirements are clear such that 2.x vs 1.x are categorized separately :
Spring Boot 2 is the first version to support Java 9 (Java 8 is also
supported). If you are using 1.5 and wish to use Java 9 you should
upgrade to 2.0 as we have no plans to support Java 9 on Spring Boot
1.5.x.
To keep an eye on the updates over the same, you can follow the Java 9 theme tracker as well as the 2.0 in Progress.
So the ideal world would be, migrating to making use of Spring 5.x/Spring Boot 2.x and Java 9 to get support over the latest features and any incompatibilities found further.

JBoss 5 Backward compatibility with Java 6

I just need clarifications related to JBoss Application Server. I've developed a project which is compiled in Java 6. And it is deployed in Jboss 5 version. Till now I didn't find any problem with the application. But I want to know will there be any possibility that Jboss will have any backward compatibility problem. Or does Jboss needed upgradation with respect to Java version. Any suggestion would be appreciable.
Thanks,
Marshal.
Even if JBoss 5 is compiled with Java 5 there shouldn't be compatibility problems at a language level.
As for the libraries there might be a problem but those that JBoss requires should have been taken care of. This leaves you with core libraries that JBoss might have replaced in its class loader hiearchy and thus might have an older version. In that case you could put those libraries into your application and effectively override the JBoss versions on a per-application basis. We did that with some XML libs (IIRC JAXB was one of them).
As an alternative - as suggested by #Geziefer - use a JBoss 5 version specifically compiled for Java 6.

How to use java 6 features in a java 5 environment

I am facing an strange issue. I developed java web app in java 6 and when I hosted it on server, its shows error since its java 5 server. I have used annotations, hibernate, rest API in my code and now I want to transform my code with java 5 environment.
is it possible to do so? if yes HOW? Or is there any other workaround for this problem? Please let me know.
#all: This is the error i am getting:
I am not sure what your build process is but you need to compile your code for a specific target like java 1.5.
If you are using javac from the command line look at the -target switch
If you are using ant then look at the target property.
You will run into problems if you are using java 1.6 specific libraries. You will know this when you try and run your code/webapp.
I hope this helps.
You'll have to look at the individual errors and figure out what is missing.
The JPA annotations were already part of Java EE 5, so if "hibernate" is causing problems, it either means you are not in fact running on Java EE 5, or you're using hibernate-specific annotations. The REST annotations were indeed added in Java EE 6, but can be used in a Java EE 5 environment relatively easily by adding a JAR with the API as well as the implementation (e.g. Apache Jersey) to the app's class path.
BTW, there's some confusion here concerning Java SE vs. Java EE. You're clearly talking about Java EE features, but there is a big difference between Java SE (which most people think about when you just say "Java") and Java EE.
From your post, it seems you're using Java EE 6 features in a Java EE 5 environment. If your app. server doesn't support such features at its core level, such as sing Servlet 3.0 features in a Servlet 2.5 environment, then you're out of luck.
However, when using features that are libraries, like Hibernate, you can get away using it in a Java EE 5 environment.
Java 6 as a language remains the same as Java 5, however, libraries have changed. Likewise, using JRE classes and methods that are in 6, won't work in 5.
Update: from your screenshot, I see that you're using Java 6 compiled classes on an older version of Tomcat. Compile them for Java 5.
You are trying to run classes compiled against Java 6 on Java 5 (Tomcat 5.x uses Java 5).
You can upgrade to Java 6.
You can compile the classes to be Java 5 compatible by using "-target" argument to javac but this option is not going to help as the problem is occuring with the servlet api. JEE6 requires Java 6.

Categories

Resources