Maven can't find httpcomponents-client in repository - maven

I am trying to add the Apache httpcomponents-client library to my Maven project. I have added a dependency to pom.xml (as found on http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcomponents-client/4.1.1), but when building my Eclipse project Maven is unable to find and download the library.
I have made a test project which does nothing but include this library to ensure that it's not any other settings that cause problems:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.gundelsby.test</groupId>
<artifactId>NeedMyPackage</artifactId>
<version>0.1</version>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcomponents-client</artifactId>
<version>4.1.1</version>
</dependency>
</dependencies>
</project>
Building this project results in the same error.
Other things I have tested:
Tried building with vanilla installs of both Maven 2.2.1 and 3.0.3
Had a friend build the test project on his computer to rule out local problems on my computer
Changed the version from 4.1.1 to 4.1
For what it's worth I had the same problem a few days ago with org.easytesting.fest-swing, see pom dependency entry below:
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-swing</artifactId>
<version>1.2.1</version>
</dependency>

You don't want httpcomponents-client as a dependency. That's just the parent pom for the client-related modules. I suspect you actually want <artifactId>httpclient</artifactId>.

Here a simple solution...
Its great for me...
You can downloar jar file from internet and add manually to project from netbeans or another IDE.
Here an example for you:
enter image description here
Search the downloaded jar in your computer
enter image description here

Related

How to import all provided Wildfly libraries in my maven project?

Is there a way to translate this human language in an xml codeblock that Maven will happily understand?
Hey Maven, look you are a great dependency management system. I am working on a JavaEE project which is intended to be deployed on Wildfly 10.1.0. Please put all Libraries that are specified in Wildflys parent BOM http://repo1.maven.org/maven2/org/wildfly/wildfly-parent/10.1.0.Final/wildfly-parent-10.1.0.Final.pom on the compiletime classpath and consider them as provided by Wildfly at runtime. And please dont bother me to list every single referenced artifact in the dependencies section of the projects pom file. Thank you Maven, you are so cool.
To clarify:
As far as I understand, importing the bom file in the dependencyManagement section of my pom file will only spare me to specify the Version Number of every single artifact, but I will still have to declare every artifactID and groupID.
This is indeed discussed here How to use BOM file with Maven
But in this answer is also stated:
Then you do not have to specify the version attribute of a dependency.
I would prefer to declare only that I am using wildfly and then be able to use all client libraries without declaring any other dependencies.
But I must admit, I have the feeling to miss something obvious. There should be an easy way to do this.
If you want everything in a another pom to be set as a dependency and as provided you can specify that in your pom. A minimal pom for wildfly 10.1.0.Final that includes everything seems to be as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>wft</groupId>
<artifactId>wft</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>wft</name>
<description>wft</description>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-spec-api</artifactId>
<version>10.1.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
But I would still recommend doing it the way that wildfly does it themselves, which is to put the BOM in the depencency management section and declare artifacts as you need them. Why? I don't know other than it's cleaner to read and maybe easier for maven/java to compile and build.

Intellij - Add project as dependency to another project

I am trying to make my project work on intellij (it works with eclipse). I have a project with this in my pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.fitnetapplication</groupId>
<artifactId>fitnet-common</artifactId>
<version>6.0.2-Final</version>
<packaging>war</packaging>
<name>FitnetCommon</name>
<description>Socle Commun FitnetManager / SyrhaLogic</description>
Now i have another project which needs to be linked to this one, so I had:
com.fitnetapplication
fitnet-common
6.0.2-Final
runtime
war
<dependency>
<groupId>com.fitnetapplication</groupId>
<artifactId>fitnet-common</artifactId>
<version>6.0.2-Final</version>
<type>jar</type>
<scope>provided</scope>
<classifier>classes</classifier>
</dependency>
The problem is that on Intellij, the version is not accepted for some reason, I don't know why, it tells me that the version 6.0.2-Final is not found for the artifact fitnet-common
To confirm - you are actually running mvn clean install (or similar) on the first project before trying to resolve the dependency in the second project?
If you are, it sounds like you're installing the project using one Maven repo location, and then in the other project it is looking in a completely different location. Are your .m2 location settings identical for both projects?
Edit:
Is it because you're specifying the first project as a war packaging, but in the dependency declaration you are looking for a jar? They would essentially be two different artefacts:
.war - com.fitnetapplication:fitnet-common:6.0.2-Final:war
.jar - com.fitnetapplication:fitnet-common:6.0.2-Final:jar
Check in your .m2/com/fitnetapplication/fitnet-common/6.0.2-Final to see what you have there, likely it is just the war file.

Generating the .war file from maven dependency project

Here I have two projects those are project(1) and project(2).
I am going to generate a .war file for the project(1) but it depends on project(2).
I built the project(2) as a .jar file and added it to the project(1)'s build path but while runnig mvn install it results in compilation errors like:
package com.disha.db.dao.orm.gen does not exist` the package is in the project(2).
Can any one please help to me.
You have to delegate dependency management to Maven and that's actually where it comes in hand, otherwise you can move on packaging and resolving inter-projects dependencies by hand and let the Maven alternative be dropped.
You should make sure you have provided the correct Project Object Module description for your projects (pom.xm) along with tha packaging type.
Then since you want the project(2) to be availble for project(1) at compilation time, you have to declare, project(2) as a dependency of project(1).
project(2) pom.xml (I will refer to it as project-2 since 'project(2)' does not match a valid id pattern.):
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>project2.group.id</groupId>
<artifactId>project-2</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</project>
Now the project(1) will refer to the project-2 artifact as a dependency with scope compile:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>project1.group.id</groupId>
<artifactId>project-1</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>project2.group.id</groupId>
<artifactId>project-2</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
Note: Update the group and artifact IDs with ones you are using.

OpenCV-2.4.4 POM entry Tag

I am starting OpenCV in Java and want to get started by creating a maven project.
For that I am using OpenCV-2.4.4 jar.
But was not able to find out the pom entry needed for that jar to be included in the dependency.
Tell me if I am missing something too trivial. Or where to find the POM entry for the same.
All I was able to find was the pom entry for the google version:
<dependency>
<groupId>com.googlecode.javacv</groupId>
<artifactId>javacv</artifactId>
<classifier>linux-x86_64</classifier>
<version>0.3</version>
</dependency>
But I need the pom tag for OpenCV-2.4.4.jar
as far as I can see from the http://code.google.com/p/javacv/#Quick_Start_for_OpenCV_and_FFmpeg you should:
point your pom.xml file to the Maven repository
http://maven2.javacv.googlecode.com/git/, and make sure that the
library files of OpenCV and FFmpeg (*.so, *.dylib, or *.dll) can be
found either in their default installation directories or in the
system library PATH, which under Windows includes the current working
directory.
To add new maven repo, you can follow:
http://www.mkyong.com/maven/how-to-add-remote-repository-in-maven-pom-xml/
afterwards, it seems you can go for the latest version of javacv (present in repo):
<dependency>
<groupId>com.googlecode.javacv</groupId>
<artifactId>javacv</artifactId>
<version>0.5</version>
</dependency>
or maybe, as you specified (with platform specific classifier):
<dependency>
<groupId>com.googlecode.javacv</groupId>
<artifactId>javacv</artifactId>
<classifier>linux-x86_64</classifier>
<version>0.5</version>
</dependency>
UPDATE:
Sorry, I seem to miss the point with my previous answer. If you're trying to go with the OpenCV java bindings rather than JavaCV (http://code.google.com/p/javacv), there seems to be no maven packaging provided yet.
As the official tutorial uses ant only (http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html)
Moreover there is an open bug for what you expect: http://code.opencv.org/issues/3097
So the only option seem to be wait for resolution of the bug and use another way in the meanwhile.
I know OpenCV developers are working to make a public maven repository for Java bindings, but I've made an example that shows how to do it, pretty much like Java OpenGL deals with it.
The full example can be retrieved from:
https://github.com/JavaOpenCVBook/code/tree/master/chapter1/maven-sample
Remember to add the github repository, as pointed by:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<repositories>
<repository>
<id>javaopencvbook</id>
<url>https://raw.github.com/JavaOpenCVBook/code/maven2/</url>
</repository> </repositories>
<modelVersion>4.0.0</modelVersion> … </project>
For now, there are only windows 64 and 32 native jars available, but it should be easy to add your Linux/MacOS version of it.
Best regards,
Daniel

Maven Systempath not working as expected

I have specified following dependencies(For example mentioned one here) in pom.xml which will look for saaj.jar under the specified sytempath and Maven used to pick it from same path and working fine.
<dependency>
<groupId>saaj</groupId>
<artifactId>saaj</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/saaj.jar</systemPath>
</dependency>
Now I have moved to windows 7 and Spring Tool suite 2.7.1 version(Previously Win XP and Spring older vesion). In this new setup am getting below error.
Missing artifact saaj:saaj:jar:1.0:system
Now, It is looking for saaj-1.0.jar instead of saaj.jar and under the folder ${basedir}/src/main/webapp/WEB-INF/lib/saaj/saaj/1.0/ instead of ${basedir}/src/main/webapp/WEB-INF/lib/.
Why is it so? Please provide the solution where my previous setup should work fine.
Avoid systemPath, you must create a local repository like :
this is you pom file :
<repositories>
<repository>
<id>local-repo</id>
<url>file://${basedir}/lib</url>
</repository>
</repositories>
<dependency>
<groupId>tiago.medici</groupId>
<artifactId>eureka</artifactId>
<version>0.0.1</version>
</dependency>
on project you create a lib folder to put your jar and maven pom file generated from
mvn install:install-file -Dfile=c:\tiago.medici-0.0.1.jar -DgroupId=tiago.medici -DartifactId=eureka -Dversion=0.0.1 -Dpackaging=jar
tiago.medici-0.0.1.pom
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>tiago.medici</groupId>
<artifactId>eureka</artifactId>
<version>0.0.1</version>
<description>POM was created from install:install-file</description>
</project>
Don't use system scope. It was meant for system provided libraries. Given the path you gave for it, you are obviously creating a web application.
Use a war project and specify your dependencies with provided scope if they're already available (e.g. because they are provided by your application server) or without a scope specification otherwise. Maven will take care of packaging your project dependency in a correct way, both for Eclipse development and for deployment in your application server.

Resources