Any issues migrating from JDK6 to JDK7 with Spring & Tomcat? - spring

I'd like to take advantage of some JDK7 features. What issues might I run into given that I use Apache Tomcat 7.0.x (latest) and Spring 3.1 (latest)?

There were a few compilation gotchas where JDK 6 could infer the generic type properly where JDK 7 could not. This was apparently a bug in JDK 6 as referenced here.
If you are using container-specific resources (e.g., data sources, etc.) be sure to verify these are still operating properly (though this will be immediately obvious on Spring startup if any of these are wired in).
If you are using Spring Security, and you upgrade, you do not need to make any changes per se to get get things running. However, you should take advantage of their less verbose configuration options (especially for REST URL's) that are available in Spring Security 3.1.
Other than that, our upgrade was seamless.

With the last Ubuntu update (11.10) I switched to JDK 7 (OpenJDK 1.7.0_147). I'm using Spring 3.0, Tomcat 6, and JRE 6 on the server (we have both VM and "physical" server installations). The code, compiled with JDK 7 runs on this configuration without any problems. I'm sure, switching to Spring 3.1 won't cause any changes. Not so sure about Tomcat 7, but hopefully this information will be useful to you.

You might run into a problem if you're using Java 7 features in a JSP. Tomcat by default user Java 1.6 for JSP compilation. See http://tomcat.apache.org/tomcat-7.0-doc/jasper-howto.html#Production%20Configuration
To solve the problem you'll want to override the compilerSourceVM and compilerSourceVM init parameters in your application's web.xml file. More on that here: https://stackoverflow.com/a/20194823/1029261

Related

Deprecated java.security.egd=file:/dev/./urandom for Spring Boot applications?

I used to configure -Djava.security.egd=file:/dev/./urandom in my Dockerfile for Spring Boot applications.
In https://spring.io/guides/gs/spring-boot-docker/ a comment was added that this is not required any more for newer versions:
To reduce Tomcat startup time we added a system property pointing to "/dev/urandom" as a source of entropy. This is not necessary with more recent versions of Spring Boot, if you use the "standard" version of Tomcat (or any other web server).
I am looking for any references for this change in Tomcat or Spring Boot repos, and which Spring Boot versions are affected.
This problem should have been resolved by the JDK Enhancement Proposal : JEP 123, Configurable Secure Random-Number Generation.
According to the JDK 8 Security Enhancements official Oracle document, the /dev/./urandom workaround is no more necessary from JDK 8.
SHA1PRNG and NativePRNG were fixed to properly respect the SecureRandom seed source properties in the java.security file. (The obscure workaround using file:///dev/urandom and file:/dev/./urandom is no longer required.)

Upgrading to Spring 4

I have a spring 3 app deployed in openshift jboss eap6, and I want to upgrade to ver 4. I also want to upgrade to Java8. Has anyone here been successful in doing so? What are the things that must be considered? How can I make the transition easier? I'm so afraid of Jar hell.
Upgrading von Spring 3.0 to 4.0 could need some changes (depending on what you have done and used). I recommend to do it in small steps, so you can check that everything still works more often, so: uprade to 3.1 first, then 3.2, and then 4.0. After that upgrade to Java 8.
The Spring Reference contain some hints in the what is new section and this Wiki: Migrating from earlier versions of the Spring Framework
Attention: if you upgrade Spring Security too, then I strongly recommend to read its upgrade hints in its Migration documentation!
Solution to your Question
Don't worry Spring 4 is 100% compatible with Java 8
For Jars you need to use the Bill of Materials of Spring 4 Jars which can be obtained in this Link. Use only these jars which will take care of your dependencies issues.
Typically replace all these JAR files in your WEB Applications and try to build and deploy your application. You got your JAR upgrade if it runs without any issues. Most probably 100% it will run without any issues.
Then Depending your scenarios you can apply your spring-framework components.

Spring 3.1.x and java 7u80

When compiled with java 7u79, spring 3.1 app is all good. When compiled on java 7u80, we're encountering some injection issues.
Searching a solution i found that Spring 3 is not compatible with java8, as explained here (due to asm).
We can see here that javac modifications were backported to java 7u80 and java 7u85.
So, am I rigth to think that it's same compatibility problem than for java 8, and that spring 3 app will not work if compiled on java7u80 ?
Sharing my experience - yes, some spring versions have problems with java 8. For example in my project we've had to change spring from 3.2.4 to 3.2.9 to use java 8. I won't put here any particular example because I don't have one but I would advice you to give spring 3.2.9 a chance. We're using it successfully with Java 8.

How do i migrate application from Tomcat 6.0.35 to JBoss AS 7.1.1

Is there any tool or set of guidelines to migrate application using Spring, from Tomcat 6.0.35 to JBoss AS 7.1.1 ? Or is it better to just host app in JBoss and work backwards to fix issues one by one as suggested by some?
There is a migration center, but it says Tomcat is coming soon.
The biggest issues you would likely face are dependencies that you've included in your application that JBoss AS or WildFly already include. This is a little old, but might be helpful too.
Other than that it's tough to say what would need to be changed without knowing your environment and current configuration. The main idea behind Java EE is ideally it should work on any application server. That said, Spring isn't a Java EE standard and Tomcat is just a servlet container :) Not that there is anything wrong with either.

Is it possible to run Mule 2.2.1 on spring 3?

We have an application that is currently running spring 2.5.6 and mule 2.2.1. We have decided to go ahead and upgrade the app to use spring 3.2 we also upgraded spring security to 3.1. I understand that Mule 2.2.1 uses spring 2.5.6 for configuration and so forth. We were to re-factor our code and build the entire project. However after deploying the application and starting the server, my server started in about 6 seconds instead of the normal 30 seconds and then I noticed that none of my services were not loaded. Unfortunately after days of investigating I cannot find where everything fails, as there are no errors in any of the logs including spring and mule logs. My question is it possible to get these to play together or should I just forget about getting this to work.
I read this post http://lifeinide.blogspot.com/2012/07/spring-3-and-mule-2-initialized-by.html and followed these instruction and still was not able to get it work. Mule says it started up just fine without any errors but I can hit any of my services. Any help? Thanks
Thanks #genjosanzo for the pointer. It helped met dig into this issue better and eventually make it work.
#mtanzania,
We had a similar need like yours - need to make Mule 2.2.1 work with Spring 3.2.x releases. Upgrade to Mule 3 involved rewrite of Mule extensions such as exception handling strategies, a RabbitMQ Mule transport etc. Upgrade to Mule 3 was therefore ruled out.
In order to make this work, you need to rewrite/update 3 java files from your module:
groupId:org.mule.modules
artifactId:mule-module-spring-config
version:2.2.1
with implementations from :
groupId:org.mule.modules
artifactId:mule-module-spring-config
version:3.4.0
To be more specific, you need these classes to be updated/upgraded: MuleBeanDefinitionDocumentReader.java, MuleApplicationContext.java and SpringXmlConfigurationBuilder.java
With these updated versions, you can continue to create the MuleContext like:
SpringXmlConfigurationBuilder springConfigBuilder = new SpringXmlConfigurationBuilder(muleConfigPaths);
MuleContext context = new DefaultMuleContextFactory().createMuleContext(springConfigBuilder)
The modified implementations are here : Mule in Trooper and sample class that uses this is here : Trooper Mule container
Mule uses some internal spring API to parse the mule configuration and creates the correspondent beans.
For this reason the upgrade might work with spring 3.0.x but I'm pretty sure that something got broken with spring 3.1.x (i.e. this code has been introduced to maintain backward compatibility).
How about upgrading mule as well? Most of the 2.2.x syntax is still supported and many new feature has been introduced in newer mule versions.
FWIW, the above answer from #regunathb is right on. Patching in those three classes works. However, it is important to note that the 3.4 version of those classes from mule-module-spring-config will not work as-is. You must get the modified versions of the classes that #regunathb posted on GitHub, otherwise you'll end up with various incompatibilities between 3.4 and 2.2.1.

Resources