maven dependency - which dependency is using unwanted jar? - java

I am working on upgrading a complex maven project, with numerous pom files. The code is built using openjdk and it runs on jboss6.*
On starting up Jboss, I'm getting the following exception:
NoSuchMethodError:
org.apache.http.conn.ssl.SSLConnectionSocketFactory.(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V
Initially, it looked like I was not importing the right maven dependency.
I looked at the pom file for the project where the exception is thrown and I found the following dependency:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
However, when adding the following line
LOGGER.debug(org.apache.http.conn.ssl.SSLConnectionSocketFactory.class.getProtectionDomain().getCodeSource().getLocation().getPath());
I get the following output:
11:54:37,037 DEBUG [packageobsucated.httpclient.HttpClientConfigUtil]
(ServerService Thread Pool --
69) file:/server/modules/system/layers/base/org/apache/httpcomponents/main/httpclient-4.3.6.redhat-1.jar!/
How can I find out which maven dependency is using httpclient-4.3.6.redhat-1.jar?
I have called mvn dependency:tree on the parent pom.xml file but I'm afraid I cannot find anything with that exact description.
Thanks in advance,

I am not jboss expert, but I guess that this dependency is loaded from a module inside jboss, i.e. not from your war.
So I guess you need to look for the order of class loading in your jboss if you want to use a different version of httpclient.

Related

Pom.xml with local jar and concurrent dependency

Here is the situation :
I want to use a locally installed jar in a springboot project. I included the dependency to this artifact in my pom.xml :
<dependency>
<groupId>org.mycie.myjar</groupId>
<artifactId>myjar</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
This jar uses the artifact snakeyaml with version 1.16
But in my main project, Springboot uses snakeyaml version 1.23
The concurrency seems to cause some issues when running the application.
Do you have any idea on the good practices to tackle this issue?
Maven will only let one of the jars into the resulting application. You can find out by calling mvn dependency:list which jar Maven chose.
The resulting problem cannot be really solved by Maven. Instead, you need to figure out which version of snakeyaml works for all scenarios. Since one of the jars belongs to you, it is probably best to just update the dependency of myjar to avoid this problem.

ERROR: Unable to process Jar entry - Selenium/Maven

I am trying to deploy my Maven project on Tomcat within Eclipse, but since I just added a new Selenium dependency I am now getting this error every time I start the server:
SEVERE: Unable to process Jar entry [module-info.class] from Jar [jar:file:/Users/ash/eclipse-workspace/my-project/target/my-project-0.0.1-SNAPSHOT/WEB-INF/lib/selenium-api-3.14.0.jar!/] for annotations
This is the dependency:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.14.0</version>
</dependency>
I have tried following advice given on related questions, as it seems people have had this issue with a variety of different dependencies. The advice included using the latest version of the dependency, or deleting the dependency and jar files from the lib folder, and then re-adding them and rebuilding Maven before I deploy the project, but I had no luck. Has anyone got an idea of how I can fix this? I need to use Selenium to test my web app.
(I'm using the tomcat7-maven-plugin if that makes any difference.)

What is the equivalent of adding a jar to deployment assembly in maven

I am working with a maven project in eclipse which I have been testing using the built-in "run on server" tomcat option. When I try to do this, I get errors stating certain dependencies are unmet from an external jar I reference in the POM. However I have found if I add the jar via the DeploymentAssembly Tab I can run in eclipse without issues:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.company.user.server.UserDetailsAuthoritiesMapper#0'
The issue comes when I try to deploy on an actual tomcat instance. The Maven build runs fine, but when I start the servlet I get the same unmet dependency errors. This to me is indicating that the external jar is not being properly packaged into the war. What is the maven equivalent of adding the package via the DeploymentAssembly tab in eclipse? The entry in the POM.xml:
<dependency>
<groupId>com.company.webapp</groupId>
<artifactId>webapp-user</artifactId>
<version>106</version>
</dependency>
Thanks
You need to locate the maven info for the external jar. If you google the name of the jar and maven you often find a direct link to the block you need. For example if I want version 1.58 of the Bouncy castle jar Google "Maven BouncyCastle" you can find the artifact info. Add that info to your pom.xml as a new dependency in your block.
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.58</version>
</dependency>
After you rebuild, refresh maven in your IDE 1st after doing a clean, this will tell maven to pull down the jar and added it to your build.
You can also go to the repo directly and search:
Maven Repo: https://mvnrepository.com/

Maven dependencies for IBM Websphere packages

I'm trying to convert a "classic" JAVA EE project, using IBM websphere 8.0.0.5, into a maven multi module project and facing issues with the IBM dependecies.
We use IBM classes from the following packages:
com.ibm.websphere.asynchbeans
com.ibm.websphere.scheduler
com.ibm.websphere.ce.cm
com.ibm.ws.asynchbeans
com.ibm.ws.util.ThreadPool
To get my local project to be compiled I downloaded the was.installer-8.0.0.pm from IBM and installed it to my maven using
mvn install -f "was.installer-8.0.0.pom" -D serverInstallationFolder="C:\Program Files (x86)\IBM\WebSphere\AppServer"
This step was successfull according to command line output.
I then added the following dependencies to my project as described from IBM:
In parent:
<dependency>
<groupId>com.ibm.tools.target</groupId>
<artifactId>was</artifactId>
<version>8.0.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
In module:
<dependency>
<groupId>com.ibm.tools.target</groupId>
<artifactId>was</artifactId>
</dependency>
But I still can't compile my project as the IBM packages are not found.
Can anyone help me to find and correct a mistake I made?
Edit
After following BevynQ tip from the comments I copied the "was_public.jar" to "was_public-8.0.0.jar" (described at IBM here) and added it to my repository:
mvn install:install-file -Dfile="C:\Program Files (x86)\IBM\WebSphere\AppServer\dev\was_public-8.0.0.jar" -DpomFile="C:\Program Files (x86)\IBM\WebSphere\AppServer\dev\was_public-8.0.0.pom"
I then changed the dependencies to:
<dependency>
<groupId>com.ibm.websphere.appserver</groupId>
<artifactId>was_public</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.websphere.appserver</groupId>
<artifactId>was</artifactId>
</dependency>
This helped to get the compiling errors for the imports to com.ibm.websphere done.
What I now have still open is the packages com.ibm.ws.* package. Anyone have an idea?
Edit 2
I added the following dependency and then I was rid of the com.ibm.ws.* import errors.
<dependency>
<groupId>com.ibm.websphere.ws</groupId>
<artifactId>com.ibm.ws.runtime</artifactId>
<version>1.0.0</version>
</dependency>
But it still does not compile as now indirectly references can not be found (in my case commonj.work.WorkManager). It seems I need to add further .jars for every single thing. Isn't there an easier way to provide all websphere jars at once as descirbe in the above linked tutorial with the com.ibm.toolsdependency (which do not work)?
In general, com.ibm.websphere are public API for use by applications (this is true of the packages you listed above) which is consistent with these being in was_public.jar
However, com.ibm.ws package is generally product internals. May I ask what interface methods you are using from the com.ibm.ws.asynchbeans package? Maybe there is a public API alternative.
Regarding commonj.work, the only place I can find this in the WebSphere Application Server product image is WAS/plugins/com.ibm.ws.prereq.commonj-twm.jar so it looks like you will need to use that to compile against.
Here's the solution so I solved my dependency problems:
I configured the company repository manager (nexus) as a mirror. In this nexus all ibm packages are present. As you can think that solved the main problem.
I then added the following dependencies according to common maven style:
Dependencies in pom.xml (version numbers extracted to properties):
<dependency>
<groupId>com.ibm.websphere.ws</groupId>
<artifactId>com.ibm.ws.runtime</artifactId>
<version>${ibm.ws.runtime.version}</version>
</dependency>
<dependency>
<groupId>com.ibm.ws.prereq</groupId>
<artifactId>commonj-twm</artifactId>
<version>${ibm.ws.prereq.commonj-twm.version}</version>
</dependency>
Sorry I can't provide a "nice" solution that's useable by all people but the answer from njr and the comment from BevynQ helped at lot to get clearer with the problem and helped to solve the problem in a "more manual" way by copying the needed jars by hand.
I was facing this issue as I tried to build a project using Maven version 3.3.9, running on Java version 1.8.0_101, as depicted in the screenshot:
This is how I resolved it: Step 1. Download the commonj.jar from here.
Step 2. Determine which JDK your Maven is using by typing mvn -version in the command prompt.
Step 3. Go to that directory and place the commonj.jar file there in the jre/lib/ext directory, as shown below. Now your project should build in maven without any issues.

maven dependency for joda-time:joda-time-jsptags:jar:1.0.2

I am trying to install the spring petcare application in my eclipse/tomcat7 installation, and I am getting the following error message when I try Run As..Maven Build in eclipse:
POM for joda-time:joda-time-jsptags:jar:1.0.2 is missing, no dependency information available
Here is a link to the complete stack trace. And here is a link to pom.xml. The entire code for the application can be found at this link. I have not changed anything in the application's code yet because I have not even gotten it to compile.
The jar in question seems to be in my local maven repository, so the problem may be that the app is simply not seeing it.
Can anyone help me get this to compile?
Actually looking at http://search.maven.org and the pom for that artifact is indeed missing! However the pom later version does exist.
Assuming that artifact is backward compatible I think you can fix it simply by upgrading joda-time-jsptags to 1.1.
Find and update following dependency on the pom.xml
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time-jsptags</artifactId>
<version>1.1</version>
<scope>runtime</scope>
</dependency>

Categories

Resources