I know that many subject speak about classpath loader and transitive dependancy but i m little confused.
I m working on a legacy application that use spring 2.0.5 and spring-ws and all work fine from the beginning of the project to now.
And recently we are faced to a runtime problem with a an exception like methodnotfoundexception.
In fact we see that spring-ws depend on spring-2.5. So maven transitive dependancy add spring 2.5 in my webinf/lib directory near spring 2.0.5
But i dont understand why all working fine during many years and now why weblogic decide to load spring2.5 before spring2.0.5 and cause this error?
We have correct the problem and now i m looking for same jar with different version and do build failure when i have a conflit to avoid dependancy problem in the future.
But i just want to understand why weblogic decide to load one or another jar ? Because if its alphabetical order, same jar will be loaded all the time, but in my exemple the order change...
So i don t understand clearly whats happened.
Thanks by advance;)
While it is documented that WEB-INF/classes is loaded before WEB-INF/lib, the documentation is not clear in cases like yours - where there are sibling copies of Spring in the WEB-INF/lib.
In Tomcat it is alphabetical, but looks like Websphere, Jboss and Weblogic are random. See https://stackoverflow.com/a/5817890/327426
From some threads on the Oracle forums, the recommendation is to run the Classloader Analysis Tool available at http://docs.oracle.com/cd/E23943_01/web.1111/e13706/classloading.htm#BABHJGJJ for your app and see the results. This tool will identify classloading conflicts.
See similar issue at https://community.oracle.com/thread/2387921?tstart=0
This post from 2009 http://www.coderanch.com/t/472496/BEA-Weblogic/Loading-order-jar-WEB-INF on Weblogic v9.2 states "Checking the logs I see the .jars in WEB-INF/lib are being loaded in reverse alphabetical order". This may or may not be true for your version
Another option is to use Maven to bypass the transitive import being packaged in the WAR
Related
I am working on a legacy project that runs on JBoss 7.1.1 and I am using the geotools library (14.5 version).
When the the project is deployed I get a lot of warnings like this
WARN [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015893: Encountered invalid class name 'org.geotools.referencing.operation.transform.WarpTransform2D$Provider' for service type 'org.geotools.referencing.operation.MathTransformProvider'
and when I am trying to execute code related to geotools I get back
Problem asking Directory of spatial files (shapefiles) if it can process request:java.lang.NoSuchMethodError: org.geotools.data.DataUtilities.canProcess(Ljava/util/Map;[Lorg/geotools/data/DataAccessFactory$Param;)Z: java.lang.NoSuchMethodError: org.geotools.data.DataUtilities.canProcess(Ljava/util/Map;[Lorg/geotools/data/DataAccessFactory$Param;)Z
I suspect that is a problem with some library dependency but I do not know how to proceed to fix it.
The project uses ant as a build tool. It builds an EAR package that when expanded contains a lib folder with all the relevant libraries, including the ones reported as problematic above. I see nothing worth mentioning in the included MANIFEST.MF of the EAR, JAR, and WAR subpackages.
Any ideas how I can debug and solve this problem?
Thanks!
This could be a number of things (and with out seeing the project dependencies it's hard to be sure which).
You may be missing a referencing jar - see the FAQ for more details
You may have failed to handle the META-INF/services files correctly when adding jars to your WAR file and JAR files - see this FAQ for details of this.
You might need so additional files to make JBOSS work see this page to see how GeoServer (which is built using GeoTools) does it.
And, you may want to consider upgrading to a currently supported version like 23.x or 24.x.
We are running our Java EE applications in WAS 8.5 and Gradle 5.* to build them.
In the past we packaged our .war application in an .ear archive, which we then deployed on our server. We had to separate our libraries from our applications and include them as shared libraries, because in our experience it made deploying much slower and in some cases used up all system memory, crashing the server.
After some experimentation, we realized that we don't need to extract the dependencies into shared libraries, because we can include them in the lib folder of our .ear archive.
Currently, we get this done by defining the dependencies of our .war application as compileOnly and redefining them as earlib in the root project (which generates the .ear archive). I'm looking for a way to automate this procedure.
The script I used looks something like this:
project.configurations.named('deploy').getAllDependencies().withType(ProjectDependency.class).forEach({dependency ->
project.configurations.named('earlib').getAllDependencies()
.addAll(dependency.dependentProject.configurations.named('earlib').getAllDependencies())
})
// This loosely resembles the actual code I used. The thought process is right, it just might have a couple syntax errors.
// Obviously, I defined an `earlib` configuration in the subproject
I tried running this code in the configuration phase, as well as in the doFirst{} section of the ear task. They all had different problems.
The former didn't work, because it seems like in the configuration phase when this code ran, the dependencies weren't configured yet.
The latter didn't work, because I can't just add dependencies during runtime (thinking back, it sounds ridiculous that I even tried it).
My question is: Can I find a phase in the build lifecycle, where I can find and modify the dependencies? Is there another workaround to solve my problem?
The technical answer to your questions is that you can use either:
A configuration.incoming.beforeResolve hook to do it last minute, only when the configuration really needs to be resolved.
Use an afterEvaluate block, assuming all the other dependencies are not defined in an afterEvaluate themselves.
However, the right solution would be to leverage the dependency management engine of Gradle and effectively declare that your root project, the one building the EAR, has dependencies on the specific configurations of the subprojects.
Not knowing your full setup and details, I believe the above would still be the more correct solution, though you may have to filter the subproject artifacts from the resulting graph.
Ideas on how this works in recent Gradle version: https://docs.gradle.org/6.2/userguide/cross_project_publications.html Most of the things explained there should work with the latest 5.x versions.
I have several huge legacy applications that I am now working on. After months of testing, we finally reached deployment only to have a "failed to load webapplicationcontext" which foiled the whole endeavor. That specific failure was due to a name space conflict between two transitive dependencies. i.e., both jars had a class to load as: org.something.somethingelse.ClassName.
There are ~100 jars pulled in via maven for this single project. Several explicit, most transitive. Ideally, I would like to know every single jar I'm putting on my classpath. Practically, though, I don't have enough experience or time to look through every one of them for potential issues.
Is there a tool, technique, or eclipse/intelliJ feature that I can use to scan a set of jars for similar namespaces?
You can try with enforcer plugin. In a maven project, it's very usefull when you need to detect different jar depenndencies of same artifact with different version.
You can read this post too.
So there were a couple of different solutions here. I ended up using jhades (http://jhades.github.io/) to identify conflicts within the war, and then tattletale (a utility provided by JBOSS support) to identify conflicts between the war and the container.
I added 'exclude *' tags to all the explicit dependencies to prevent any transitive dependencies from loading. I added explicit dependencies for anything that still wasn't present. After ensuring that all compiled dependencies played nicely, I set any libraries identified by tattletale to provided and added the necessary module to standalone.xml. These things like hibernate, apache libs, servlet APIs etc.
The other thing I discovered which made this so difficult to identify in the first place is that JBOSS's classloader indexes libraries according to how the hosting file system orders them. On Windows, which is where we do 90% of our development, they are always loaded alphabetically. On linux, where we do our production deployments, the order is pseudo random. Our production servers are built from the same images, so a RHEL 3.4 server will load in the same order as another 3.4, but a 3.5 will load entirely differently. Thus, we did not see a failure until the stars aligned and we deployed to a 3.6 server. In production.
Hope this helps someone.
I came to a grinding halt in trying to debug a problem I am having with Spring 3.1 ( I put a bounty on it FWIW ). So, I would like to take the spring-security and spring-ldap source code, put my own log4j statments in, compile it and run my webapp in Tomcat 6.
What is the most sensible way to do this?
Include my "customized" libraries in the WEB-INF/lib of my Maven based project or do I put the altered libs in the tomcat\lib dir?
Can I do this using only Maven? I recently learned Maven to fix a proble and I would like to catch my breath before learning gradle if I can.
I don't want to do this for all of Spring and all of Spring-Security.
How would I set it up in maven/my pom.xml?
I realize the new tools make all of this easier than it probably feels to me, but compiling libraries from source has been a terror most of my life so I would like some tips and instructions to make it as easy/fast as possible.
Thanks
You can do this using only maven:
Either: Use the same POM as the spring people do. That way the new jar that falls out of your code will overwrite the one delivered by spring.
Or: Use the same POM, but increase the Version Number (to the next SNAPSHOT ) and change the dependency in your pom to that version. (EDIT: read Roy-Truelove 's comment below, its very correct indeed.)
I would recommend the latter variant.
I have a bit of an issue with Spring 3 and it involves its dependencies or better said "their lack of...".
When you download Spring 2.5.x for example you get a spring-framework-2.5.6-with-dependencies.zip file containing the Spring distribution as well as its dependencies.
For Spring 3 there isn't one. You only get the distro while dependencies are managed in Maven repository and retrieved with Ivy. That was the decision springsource fellows took. Which brings me to my problem.
At work Maven repository has "forbidden access" written all over it and we don't use Ivy. We use Maven but with a local enterprise repository and nothing beyond that is allowed (security concerns yada yada which ultimately makes sense but makes my job as a developer harder). To put something in the local repository means approvals, deployments of resources, configurations, acces rights, time, money etc.
It is OK with a few JARS here and there but I imagine Spring dependencies mean more than a few JARs. So that will be approved and installed over o long period of time. Meanwhile we can't develop in Spring 3 (while everything is set up in the local repository) so we need the dependencies.
I found this page here:
http://static.springsource.org/downloads/nightly/snapshot-download.php?project=SPR
which contains some dependencies but i need it for release 3.0.5 not for nightly builds.
In short, I need a spring-framework-3.0.5-RELEASE-with-dependencies.zip file. Ho do I get one?
P.S. I must mention that I can't just download something home and bring everything on a stick which is the first suggestion that pops in mind. Other rules apply for this :D, so I need an official release to download.
Steps:
Go to http://s3.amazonaws.com/dist.springframework.org/release/SPR/spring-framework-3.0.5.RELEASE.zip
When you hit the URL, your download for jar files starts automatically
After unzipping, there is a folder called dist which contains the following jar files for spring 3.0.5
org.springframework.aop-3.0.5.RELEASE.jar
org.springframework.asm-3.0.5.RELEASE.jar
org.springframework.aspects-3.0.5.RELEASE.jar
org.springframework.beans-3.0.5.RELEASE.jar
org.springframework.context.support-3.0.5.RELEASE.jar
org.springframework.context-3.0.5.RELEASE.jar
org.springframework.core-3.0.5.RELEASE.jar
org.springframework.expression-3.0.5.RELEASE.jar
org.springframework.instrument.tomcat-3.0.5.RELEASE.jar
org.springframework.instrument-3.0.5.RELEASE.jar
org.springframework.jdbc-3.0.5.RELEASE.jar
org.springframework.jms-3.0.5.RELEASE.jar
org.springframework.orm-3.0.5.RELEASE.jar
org.springframework.oxm-3.0.5.RELEASE.jar
org.springframework.test-3.0.5.RELEASE.jar
org.springframework.transaction-3.0.5.RELEASE.jar
org.springframework.web.portlet-3.0.5.RELEASE.jar
org.springframework.web.servlet-3.0.5.RELEASE.jar
org.springframework.web.struts-3.0.5.RELEASE.jar
org.springframework.web-3.0.5.RELEASE.jar
NOTE : You can download any release of spring framwork just by modifying the release version to 3.0.1 or 3.2.5(any other versions according to your need)in the above mentioned URL
One of the main reasons that there isn't a big “Spring 3 with everything” build is that you probably don't need it. (It's absolutely huge!) Instead, you're supposed to identify the parts that you actually need and only include them. The problem is that this makes it hard for you.
Alas, the best way I see long-term for you is to get Spring 3 and its dependencies into your institutional Maven repository (switching to Ivy wouldn't really help; the institutional problem is not with Maven but with depending on unvetted external libraries). Yes, it's awkward but that's what you've got to work with. Sneaking things in the back-door won't help! Perhaps it would be reasonable to inquire whether there is a relatively rapid method to get things approved where previous versions have been found acceptable (which might be “yes, subject to there being no license surprises”)?
You'll probably need to use Maven (or Ivy, but I don't know it) to get the full list of dependencies first, so that you can describe exactly what changes are actually involved, and be aware that some of the dependencies might already be approved.
(I just wish I had a better idea for how to deal with your process, but working against both its spirit and letter is a way to get a corporate bureaucrat very upset. Life's not worth such things.)
I've shared the very origin file from Spring official site:
http://kuai.xunlei.com/d/QBEMGYUXOOKN
http://s3.amazonaws.com/dist.springframework.org/release/SPR/spring-framework-3.0.5.RELEASE-dependencies.zip
Create a project at home, add what you need in spring 3 to that, open the project with eclipse+m2eclipse and view the dependency hierarchy. That will then tell you what you need as dependencies on spring.
Chances are a lot of the dependencies are the same as they were in spring 2.5 as a lot of the spring 3 stuff didn't change.
You can ask your maven at home to download all the dependencies... and you'll have your own version of spring+dependencies