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/release</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
Related
Consider I have a maven plugin project and I want to publish it to Github's public maven repository called "Github Packages". I've done everything by instruction and for normal projects everything works fine out of the box. But for maven plugin projects with packaging=maven-plugin the instruction doesn't work.
In build log I see something like this:
[WARNING] Could not transfer metadata repo-name/maven-metadata.xml
from/to github (https://maven.pkg.github.com/user-name/repo-name):
Failed to transfer file:
https://maven.pkg.github.com/user-name/repo-name/group-id/maven-metadata.xml.
Return code is: 422 , ReasonPhrase:Unprocessable Entity.
It seems the maven deploy plugin needs maven-metadata.xml in the group-id's root, but can't find it and no one puts it there. How to solve this problem?
I use Apache Maven 3.3.9, and use the command:
mvn clean deploy
--Addition: example of pom file I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub my_repo Apache Maven Packages</name>
<url>https://maven.pkg.github.com/my_nick/my_repo</url>
</repository>
</repositories>
<version>1.0.0</version>
<groupId>x</groupId>
<artifactId>some-plugin</artifactId>
<packaging>maven-plugin</packaging>
<dependencies>
<dependency>
<groupId>x</groupId>
<artifactId>my-dependency</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.15.12</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
</plugin>
</plugins>
</build>
</project>
Unfortunately I haven't found the right answer to my question, it seems that for now it's impossible to add Maven plugins to Github Packages.
However I found a workaround which uses S3 as a repository backend, so you don't need heavyweight solutions like Nexus or JFrog. You can read this and this on how to do it.
I had the same problem 422 from server: Unprocessable Entity when publishing Maven artifacts from GitHub Actions to GitHub Packages. The reason was that the corresponding tag for the uploaded artifact didn't exist yet.
The error message may be better in this case.
If you have already uploaded the artifact to the GitHub Packages then it means you have configured everything right.
I suppose the real reason for the 422 error is that you are trying to upload the same artifact with the same version that already was uploaded. And if it is not a SNAPSHOT version then the repository should deny replacing it so it behaves correctly.
I got the same error when trying to redeploy the already deployed package:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project MavenPluginForGithub:
Failed to deploy artifacts: Could not transfer artifact ru.dmochalov:SampleMavenPluginForGithub:jar:1.0.3 from/to github (https://maven.pkg.github.com/dmochalov/hello-world):
Failed to transfer file: https://maven.pkg.github.com/dmochalov/hello-world/ru/dmochalov/SampleMavenPluginForGithub/1.0.3/SampleMavenPluginForGithub-1.0.3.jar.
Return code is: 422, ReasonPhrase: Unprocessable Entity. -> [Help 1]
How to fix?
Is suppose you have two options:
Increment the version <version>1.0.0</version> of the plugin from 1.0.0 to 1.0.1. Consider using 1.0.1-SNAPSHOT versions if the plugin is unstable and under development. GitHub allows redeploying artifacts with SNAPSHOT versions. So you could always redeploy it when developing.
Delete the package from the repo. You can do it only for packages in a private repository.
422 error vs 401 error
I suppose that there is not accepted specification or standardization for error codes and different repositories behave differently. For example, the Maven Central repository replies with 401 error when attempting to replace the already deployed version.
Why GitHub decided to use 422 is a mystery. There is an answer in the community forum but without proper explanation.
Here's the official github link for how to do exactly that. However, since this doesn't seem to be of much help, here's a link to a gradle forum question that should help you with this. Best of luck!
I am trying add this dependency in my pom.xml, but maven is not able to resolve the dependency for the same.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.4.RELEASE</version>
</dependency>
I was working on my other computer some weeks ago. I switched my laptop, and trying to setup this project, but it's not working anymore.
Error:
Missing artifact org.springframework:spring-test:jar:4.3.4.RELEASE
I see this this is available in the maven central.
http://search.maven.org/#artifactdetails%7Corg.springframework%7Cspring-test%7C4.3.4.RELEASE%7Cjar
Does anybody have any idea why is it happening?
Thank you #Reek for the comment.
I added spring repository url in my pom.xml and it started working.
<repository>
<id>repository.spring.release</id>
<name>Spring GA Repository</name>
<url>http://repo.spring.io/release</url>
</repository>
You do not need to add spring specific repository to use those artifacts.
Maven works as follows:
Firstly Maven tries to find artifact in the local repository.
Otherwise Maven tries to download artifacts from http://repo1.maven.org/maven2/ by default.
If you wanna build your project on another computer for the first time than there is no local repository at the moment. There are two possible reasons for Error on the second stage:
Maven central repository is unavailable from another computer: check this URL.
Mirror of Maven central is misconfigured in settings.xml like this:
<mirrors>
<mirror>
<id>central-proxy</id>
<name>Proxy of Maven Central</name>
<url>http://some/invalid/url/here</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
Detailed logs are required.
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.
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 ?
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>