external maven repo and jenkins - java

I have an external jar(meaning not available in a public repo), that i want o include in my build.
I used the instructions found on this site:
http://charlie.cu.cc/2012/06/how-add-external-libraries-maven/
and it works, when I do mvn install in my PC.
But when I am building the maven project using Jenkins, i get the following error:
Executing Maven: -B -f D:\Program Files (x86)\Jenkins\workspace\rmy
job\pom.xml install [INFO] Scanning for projects... [INFO]
[INFO]
[INFO] Building xxxxxx 0.0.1-SNAPSHOT [INFO]
[WARNING] The POM for sqljdbc:sqljdbc_4.0:jar:v4 is missing, no
dependency information available
[INFO]
[INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total
time: 1.705s [INFO] Finished at: Tue Feb 11 10:29:23 EET
2014
[INFO] Final Memory: 13M/307M
[ERROR] Failed to execute goal on project xxxxxx: Could not resolve
dependencies for project com.xx:xxxxxxx:jar:0.0.1-SNAPSHOT: Failure to
find sqljdbc:sqljdbc_4.0:jar:v4 in
http://repository.codehaus.org/org/codehaus was cached in the local
repository, resolution will not be reattempted until the update
interval of codehaus has elapsed or updates are forced -> [Help 1]
The pom that i am using has these entries for repositories:
<repositories>
<repository>
<id>codehaus</id>
<url>http://repository.codehaus.org/org/codehaus</url>
</repository>
<!-- In Project repository -->
<repository>
<id>in-project</id>
<name>In Project Repo</name>
<url>file://${project.basedir}/libs</url>
</repository>
Any ideas why this is happening?

After some tries, i did the following workaround in pom.xml
<repository>
<id>in-project</id>
<name>In Project Repo</name>
<url>file://${project.basedir}/libs</url>
</repository>
and
<dependency>
<groupId>sqljdbc</groupId>
<artifactId>sqljdbc_4.0</artifactId>
<version>v4</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/sqljdbc/sqljdbc_4.0/v4/sqljdbc_4.0-v4.jar</systemPath>
</dependency>
This means that the system path is needed as a whole and not just
<url>file://${project.basedir}/lib</url>
as it was mentioned above.
By this "workaround" I got it to work both locally and remotely (Jenkins-Git)

Actually that might be hppen that it can't get the jar from lib.
tyr it with other way.
right click project
select property
java build path
select Lib
add external jar and put set path of your jar files
finish
clean and build your project.
OR
<repositories>
<repository>
<id>local123</id>
<name>localRepo</name>
<url>file://${project.basedir}/lib</url>
</repository>
</repositories>
try putting this code in pom.xml file.
hope your problem can be resolve using this.

As a general rule I always strongly recommend to
use a Maven Repository Manager such as Nexus
only manage repositories in the Maven Repository Manager, not in the POMs
use the Maven Repository Manager to host third-party libraries not available from any other repository
configure your settings file
This is a key to get stable and reproducible builds - even when one of the repositories is temporarily unavailable.

Related

Could not resolve dependencies: org.springframework.transaction

I am not super confident in my understanding of Maven so bear with me:
My POM:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.transaction</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
Build:
[WARNING] The POM for org.springframework:org.springframework.transaction:jar:3.2.4.RELEASE is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.427 s
[INFO] Finished at: 2016-12-02T15:22:42-08:00
[INFO] Final Memory: 7M/77M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project PROJECT: Could not resolve dependencies for project PROJECT:jar:1.0: Failure to find org.springframework:org.springframework.transaction:jar:3.2.4.RELEASE in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of maven2 has elapsed or updates are forced -> [Help 1]
Looking in http://repo1.maven.org/maven2 this makes sense. org.springframework.transaction is indeed not present in the repository. So I went to this page and noticed that it says the artifact lives in the following repository:
https://artifacts.alfresco.com/nexus/content/repositories/public/
This time, looking through the repository I did find org.springframework.transaction at the directory matching the groupId and artifactId specified in my POM.
https://artifacts.alfresco.com/nexus/content/repositories/public/org/springframework/org.springframework.transaction/
However there is clearly no 3.2.4.RELEASE here. My co-worker's are able to build the project (though it has been some time since they checked it out fresh) and they remember running into a similar issue. I am a little confused as to why this feels like a repository issue though when we are all running the same POM.
As an aside, there are multiple other org.springframework dependencies that are resolving appropriately and I can see them in my ~/.m2, just not this one.
The org.springframework.transaction has the spring-tx artifact id.
I use this snippet in my pom and works seamlessly:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.2.4.RElEASE</version>
</dependency>
Ended up being an issue to having spring-context dependency in my pom. Apparently that does stuff for you? Getting rid of both spring-tx and org.springframework.transaction actually allowed them to be downloaded and accessed properly.
As #Vadim just answered, you just need to add your custom repo to your pom.
<repositories>
<repository>
<id>alfresco</id>
<name>your custom repo</name>
<url>http://repository.springsource.com/maven/bundles/releas‌​e</url>
</repository>
</repositories>
And then you can get your dependency by using:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.transaction</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
You can view the repository contents by using this link https://artifacts.alfresco.com/nexus/#nexus-search;quick~transaction
Also be carefull not to run maven with -o flag( or in offline mode ) for the first time in order to let maven to download the dependency.
Your .m2 does not have it and Maven tries to get it from defined repositories. You do not have them or you do not have a connection from Maven. (it is more likely from what error says as I remember). are you behind the proxy?
You need to define additional repositories. either in ~/.m2/settings.xml or inside POM on project level.
Something like that:
<repositories>
<repository>
<id>fuse-public-repository</id>
<name>FuseSource Community Release Repository</name>
<url>https://repo.fusesource.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repositories>
in settings.xml usually in one of the active profile element.
In POM just inside project.
PS. be sure you have connection to the repository URL. If you are behind proxy you need to define it as well in settings.xml

Maven Plugin issue for Wsgen tag

After tried several thing as posted by me on :
Unable to do wsdl generation by maven plugin
I find the below issue after trying with several versions of mojo jaxws plugin which is already discussed in a site:
Get "java.lang.NoClassDefFoundError" though the class is in the classpath
So as per the suggestion I tried to add the tools jar in the plugin section just above org.codehaus.mojo.
I think this what it is suggested and one of the guy find the solution.
<plugin>
<dependencies>
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7</version>
<scope>system</scope>
<systemPath>${JAVA_HOME}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>${jaxws-maven-plugin.version}</version>
</plugin>
But trying that ended up having the below issue: Please provide any suggestion , if I am going wrong anywhere.
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) jdk.tools:jdk.tools:jar:1.7
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dversion=1.7 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dversion=1.7 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.codehaus.mojo:jaxws-maven-plugin:maven-plugin:1.9
2) jdk.tools:jdk.tools:jar:1.7
----------
1 required artifact is missing.
for artifact:
org.codehaus.mojo:jaxws-maven-plugin:maven-plugin:1.9
from the specified remote repositories:
releases (https://dsnexus.us.hibm.hex:8081/nexus/content/repositories/releases),
dsnexus-snapshots (https://dsnexus.us.hibm.hex:8081/nexus/content/repositories/snapshots),
R2 (http://dsnexus.us.hibm.hex:8081/nexus/content/groups/public),
snapshots (https://dsnexus.us.hibm.hex:8081/nexus/content/repositories/snapshots),
jboss (http://repository.jboss.org/nexus/content/groups/public-jboss),
dsnexus (https://dsnexus.us.hibm.hex:8081/nexus/content/groups/prd)
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Missing:

Installing Mahout with Maven on OS X Eclipse

I am trying to play with Mahout.
Following very simple instructions on the apache website. I'm getting weird dependency errors.
I've created a new project with Maven. I've added this to the pom.xml as suggested:
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-mrlegacy</artifactId>
<version>0.9</version>
</dependency>
now running 'mvn clean install -U' gives me:
Downloading: https://repo.maven.apache.org/maven2/org/apache/mahout/mahout-mrlegacy/0.9/mahout-mrlegacy-0.9.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.689 s
[INFO] Finished at: 2015-03-21T10:54:37+00:00
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project my-app: Could not resolve dependencies for project com.mycompany.app:my-app:jar:1.0-SNAPSHOT: Could not find artifact org.apache.mahout:mahout-mrlegacy:jar:0.9 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
Java is too hard! Seriously, I'm a Ruby guy. Now I also tried 'artifactID' as just 'mahout' as I can see that in some of these alleged maven repositories, but same error.
What am I doing wrong???
The documentation of Apache Mahout appears to have a version mix-up. mahout-mrlegacy does not exist in version 0.9, but it will exist in version 0.10.0. For version 0.9, the dependency is actually mahout-core.
Therefore, you should use
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-core</artifactId>
<version>0.9</version>
</dependency>
When 0.10.0 will be released, you will need to use
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-mrlegacy</artifactId>
<version>0.10.0</version>
</dependency>
Add below dependency to your pom.xml
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-mrlegacy</artifactId>
<version>0.9.0.2.2.0.0-2041</version>
</dependency>
And below repositories
<repositories>
<repository>
<id>pentaho-releases</id>
<url>http://repository.pentaho.org/artifactory/repo/</url>
</repository>
</repositories>
For more details:
https://mvnrepository.com/artifact/org.apache.mahout/mahout-mrlegacy/0.9.0.2.2.0.0-2041

Maven 2.2.1 repository order seems arbitrary

My build is breaking on a fresh machine because one of the repositories is returning a 301 page for both the pom and jar instead of the expected 404. The dependency is asm:asm:1.3. It is in Central, but Maven doesn't seem to be looking there.
Here's a sample of the build log:
Downloading: http://download.java.net/maven/2/asm/asm/3.1/asm-3.1.pom
[INFO] Unable to find resource 'asm:asm:pom:3.1' in repository java.net2 (http://download.java.net/maven/2)
Downloading: http://repository.primefaces.org/asm/asm/3.1/asm-3.1.pom
[INFO] Unable to find resource 'asm:asm:pom:3.1' in repository prime-repo (http://repository.primefaces.org)
Downloading: https://repository.jboss.org/nexus/content/groups/public-jboss//asm/asm/3.1/asm-3.1.pom
[INFO] Unable to find resource 'asm:asm:pom:3.1' in repository jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public-jboss/)
Downloading: http://maven.thebuzzmedia.com/asm/asm/3.1/asm-3.1.pom
[INFO] Unable to find resource 'asm:asm:pom:3.1' in repository The Buzz Media Maven Repository (http://maven.thebuzzmedia.com)
Downloading: http://maven.glassfish.org/content/groups/glassfish/asm/asm/3.1/asm-3.1.pom
185b downloaded (asm-3.1.pom)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '6c9fd3d150b8a5f0ca676f49b8ed603793cabebb'; remote = '<html>
<head><title>301' - RETRYING
Downloading: http://maven.glassfish.org/content/groups/glassfish/asm/asm/3.1/asm-3.1.pom
185b downloaded (asm-3.1.pom)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '6c9fd3d150b8a5f0ca676f49b8ed603793cabebb'; remote = '<html>
<head><title>301' - IGNORING
[WARNING] POM for 'asm:asm:pom:3.1:compile' is invalid.
Here's the repositories section in my pom.xml:
<repositories>
<repository>
<id>central</id>
<name>Central Maven Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
</repository>
<repository>
<id>java.net2</id>
<name>Repository hosting the jee6 artifacts</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
<repository>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<id>jboss-public-repository-group</id>
<layout>default</layout>
<name>JBoss Public Maven Repository Group</name>
</repository>
<repository>
<id>The Buzz Media Maven Repository</id>
<url>http://maven.thebuzzmedia.com</url>
</repository>
</repositories>
I don't have a settings.xml file.
From what I can tell, the dependency on jersey-server-1.3 is breaking the build. Its pom.xml specifies the now non-existant repository at http://maven.glassfish.org/content/groups/glassfish. But all the other repositories I have specified are being checked in the order I have specified. That is, everything except central. How can I make Maven check the central repository first? Or at least make it check Central before using repositories specified in dependencies' poms?
The first recommendation i can make is to read the sonatype article about repositories in your pom. Furthermore the http code 301 means in move permanently. This means your URL you are using for one of your repositories seemed to be out of date or should be different.
The defined glassfish repository seemed to wrong, cause it should be an https connection.
Furthmore i can recommend to use a repository manager.
One questions comes to my mind: Why are you defining Maven Central in your repositories list, cause it's already defined in Maven itself...BTW: Repository definition should be put into the settings.xml instead of the pom.xml apart from using a repository manager.
To define the order of the repository access it is done in reverse order based on their definition in the settings.xml. To get better control over this is to use a repository manager.
One important question: Why don't you use Maven 3.0.X instead of Maven 2.2.1 ?

Build issue Spring 3 -hibernate 3 Project

I have a simple spring3,hibernate 3 project.When am trying to build the project using Maven i got the following errors.
Downloading: http://repo1.maven.org/maven2/org/hibernate/hibernate-entitymanager/3.3.2.ga/hibernate-entitymanager-3.3.2.ga.jar
[INFO] Unable to find resource 'org.hibernate:hibernate-entitymanager:jar:3.3.2.ga' in repository central (http://repo1.maven.org/maven2)
[INFO] Failed to resolve artifact.
Missing:
1) org.hibernate:hibernate-entitymanager:jar:3.3.2.ga
Anybody know what is the issue, i put anything wrong in my POM.xml.
If i downloaded the jar file, how i added to Maven through my eclipse
Help is highly appreciated,
VKS
You could use http://mvnrepository.com to search for hibernate-entitymanager. Your version looks like this: Do note the upper case in GA ...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.3.2.GA</version>
</dependency>
For hibernate we use following repository:
https://repository.jboss.org/nexus/content/repositories/releases/
Try adding this to your pom:
<repository>
<id>jboss.org</id>
<name>JBoss Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
</repository>

Categories

Resources