I have a project that utilizes the following architecture:
MIDDLEWARE
APPLICATION
CUSTOMIZED APPLICATION
The build environment utilizes what is known as a maven-overlay.
The Application contains references to the Middleware dependencies, so those get installed into my maven repo when I build the Application.
Next, when I build my Customized Application, I reference the Application as a dependency - my customizations get overlayed on top of the Application classes.
The final product that is created is war file that I deploy on a Tomcat webserver after building my Customized Application.
The overall project is getting pretty old - the Middleware was developed back in the 2011/2012 so it's using outdated versions of ... well everything!
The Middleware and Application use an old version of Spring (3.1.0) and were originally developed using JDK 6. Several years back I moved to JDK 7. However, recently I tried building and deploying my customized application using JDK11 - but ran into all kinds of issues, so I throttled back to JDK8; but, even with JDK8 there is an issue. Specifically it has to do with Lamba expressions and some other nuances that my current version of Spring (3.1.0) doesn't know how to handle. That being said - the solution is to update the version of Spring that the Middleware is using so that the overall project can utilize JDK8 (for TLS1.2, beefer security, etc.)
Question: How do I update a dependency in my Middleware?
I've looked at the Middleware source code (so I do have access to the source code if necessary) and I see this dependency in the main POM of the project:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
Again - I need to update this version to 4.0.0.M1 to solve my problem, but I'm not sure how to do that given the build environment that I described above, where the APPLICATION pulls in that Middleware dependency (which in turn is the one that pulls in that old spring version).
Thanks.
So, long story short on this one is that in order to affect the dependency that is being managed by the middleware - I needed to upgrade the middleware to the appropriate version that would solve my JDK problem but at the same time jive with my application's architecture (e.g. I couldn't just automatically take the latest middleware version as much as I would have liked, so I took the highest version possible and solved both problems after A LOT of work.
Ended up going with JDK8 + a version of the middleware that used Spring version 3.2.3. This Spring version allows to target JDK 1.7 byte code but build using 1.8 JDK.
Related
The scenario. I write LibraryA which needs to use a newer version of a library (Caffeine in this case, and specifically v2.6.2). I will build and upload this artifact to our build artifactory
LibraryA is intended to be used by other teams (unknown to me) in an older Spring Boot 1.5 environment . The issue is that Spring Boot internally uses an older version of Caffeine 2.3.5 (although to me , it could use a newer one).
What I see is at runtime, the older version dominates the newer version resulting in class not found exceptions in my lib
Is there a way, I can force my library to always use the newer desired Caffeine version . This would be easy to do if I had control over the code using my library but I'd like to accomplish this within the scope of my library. I tried all the dependency resolution strategies in the gradle documentaion but they are always overridden by the invoking (spring-boot) application
You should use package relocating from gradle shadow plugin.
In your case you just add following to your build:
shadowJar {
relocate 'com.github.benmanes.caffeine', 'shadow.caffeine'
}
I have a RESTful web service application in java deployed on google app-engine which uses jersey 1.18.6.
I want to use postmark java client to send transactional emails from it.
When I integrated it, i was seeing the following exception:
javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family
From what I could find, I think this error was because of there were two different (and probably incompatible) version of jersey being used ,1.18.6 for jersey-server, jersey-guice and jersey-bundle and 2.25.1 for jersey-client (by postmark).
Then I tried to make the jersey version 1.18,6 throughout, so in the my main project pom, while including the dependency for postmark, I excluded the jersey-client (by added exclusions header) and separately added jersey-client dependency in my main project .
But then I got the following error:
java.lang.NoClassDefFoundError: javax/ws/rs/core/MultivaluedHashMap
This is I think the class MultivaluedHashMap is present only in jax-rs 2.x versions (which is compatible with jersey 2.x versions)
So my questions are:
Is there a version of postmark java client library which uses jersey 1.x instead of jersey 2.x?
If no then what options do I have other than migrating my main project from jersey 1.x to jersey 2.x. I don't want to do that since we will have to migrate not just the jersey dependencies but I think some other things like guice, shiro etc. which would be time consuming. Also it doesn't really seem optimal to modify multiple existing dependencies just to include one additional module.
There isn't. The very first commit of the project's pom.xml already used Jersey 2.25.1
as Mureinik mentioned above, when we worked on the library, our plan at Postmark was to use newer library versions, since they are better options in long run.
On our Github page Rupert made good suggestions, from which I find separate ClassLoader a good choice. I will play a bit with the library code in next couple of days on compatibility, however we are always in favour of using newer libraries for our codebase.
please check out my latest comment on Github issues page for possible solution for using older Jersey version https://github.com/wildbit/postmark-java/issues/11
It should be pretty easy to port the library to Jersey 1.x by porting only the HttpClient class on your side.
I searched spring on maven, and I find it at this page :http://mvnrepository.com/artifact/org.springframework/spring. The problem is I want to download 4.0 version but there is no 4.0 version in the chart.
Newer version of Spring can be found under group id org.springframework - Spring 4+
There is no reason to include all features of Spring Framework in one .jar. Spring is huge and you will probably won't use every feature of Spring. Including everything will cause unnecessary overhead. Pick what components you need add them to pom.xml and Maven will download them. If you found out later you need additional dependency just add it on the fly...
As an alternative you can use Spring Boot which will generate project for you with default set up. You can generate such a project using Spring Initializr Spring Boot Initializr. At the bottom click Switch to the full version. Pick what you need and hit generate project.
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.
I'm trying to deploy an existing app to tc-server. I have been using this app on tomcat for a couple of years and the production version already runs on tc-server. I have installed the version of tc-server that comes with spring insight. Everything goes well until I deploy a war file that has a dependency on spring integration. I'm getting a no class def found error and it is complaining about a class called
org/springframework/integration/transformer/AbstractMessageProcessingTransformer
I opened up the spring integration jar that is bundled with my war in the WEB-INF lib and did not see that class.
I poked around in the tomcat instance that I created with the bat files in tc-server and see a later version of spring-integration i.e.
.\insight\collection-plugins\insight-plugin-spring-integration-1.9.2.SR1.jar
Since my war is now getting a class not found exception (whereas it deploys fine on my normal tomcat 6.29 ) I'm assuming that this other version of spring-integration is being seen by my app somehow. My app is configured to use spring-integration-1.0.4.
Does anyone know how to get around this problem?
1.0.4 is an extremely old version (3+ years old) the current release is 2.2.4. That class was introduced in 2.0.0.
So you probably have a classpath issue - insight needs a more recent version of Spring Integration on the classpath.
The insight plugin version (1.9.2.x) is not related to the Spring Integration version (but it needs a much more recent version than 1.0.4).