I added below dependency in pom.xml file:
<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>4.0.4</version>
</dependency>
I have alot of maven dependencies but when I add the one above I get:
Failed to read artifact descriptor for org.tuckey:urlrewritefilter:jar:4.0.4: Could not transfer artifact org.tuckey:urlrewritefilter:pom:4.0.4 from/to central (http://app1.stage.server.net/artifactory/libs-release): Not authorized, ReasonPhrase:Unauthorized. -> [Help 1]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
this is how the settings.xml file looks:
..
<servers>
<server>
<username>user</username>
<id>central</id>
<password>my-password</password>
</server>
<server>
<username>user</username>
<id>snapshots</id>
<password>my-password</password>
</server>
</servers>
<profiles>
...
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
..
any help? tnx.
I faced this issue when my proxy server was not configured correctly for maven. You should check with your network administrator about proxy server and add the it in settings.xml under conf dir.
You can look for <proxies> tag and update the fields.
When I face this issue, I too felt it happened for just a few jars, but then all other required jar files were already present in my local repository and hence I was getting it for a few jars only.
I had this error trying to deploy to an internal instance of Nexus with a Maven client that was using proxies with no settings. Attempting to access a Nexus instance on the LAN via a proxy resulted in the Not authorized, ReasonPhrase:Unauthorized error.
<nonProxyHosts>internal.hostname</nonProxyHosts> fixed the issue.
Please check access of repository or password which had given in settings.xml
Adding this in case it helps someone else. In my case I was receiving this error and none of the solutions I found seemed to help. In the end I needed to add the config option to settings.xml to set interactiveMode to false.
If you are sure that your mirror links are configured properly in the settings.xml file, then please try this:
Navigate to .m2 -> repositories
Search for "lastupdated"
Delete all the files that come in the search result.
Then do a 'mvn clean install' -> new 'lastupdated' files would be created.
Try to changes groupId for the dependencies which you have added.
It work
Related
I am trying to upload a Maven artifact I haven't built to my Organization's GitHub package registry. I am using the deploy:deploy-file Maven plugin in order to do so. Here is the command I have been using:
mvn deploy:deploy-file
-Dfile=[THE JAR FILE]
-Durl=https://maven.pkg.github.com/[ORG]
-Dregistry=https://maven.pkg.github.com/[ORG]
-DgroupId=[GID]
-DartifactId=[ARTIFACTID]
-Dversion=[VERSION]
-DgeneratePom=false
-Dtoken=[MY GITHUB TOKEN]
As a result I am receiving 401 errors from Github.
I have made sure that:
I have sufficient permissions inside of my Organization (currently Owner).
The token i am using is valid and has the appropriated scopes: I put all of them on to test.
Also, the github package page states:
<!-- Just a single step: Deploy using a GitHub token -->
$ mvn deploy -Dregistry=https://maven.pkg.github.com/[org] -Dtoken=GH_TOKEN
Why can't I find any information in Maven documentation about registry or token parameters?
Can I upload this file to the organization's registry without any kind of XML configuration file, using only the cli?
Thanks in advance.
I had success with this:
mvn deploy:deploy-file -Dfile=./[JAR].jar
-DpomFile=./pom.xml
-DrepositoryId=github
-Durl=https://maven.pkg.github.com/[OWNER]/[REPO]
-Dtoken=GH_TOKEN
And a settings.xml in my maven home directory:
<settings>
<servers>
<server>
<id>github</id>
<username>[GITHUB USERNAME]</username>
<password>[GENERATED ACCESS TOKEN]</password>
</server>
</servers>
</settings>
And inside my POM:
...
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/[OWNER]/[REPO]</url>
</repository>
</distributionManagement>
...
To workaround the repo issue - since I didn't want each package to be published to a different repo, I created a repo named packages and published the packages from all the other repos to it, using the same config as in the other two answers.
Url should have a repository name as well.
In one of my projects I have this in pom.xml
<distributionManagement>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/stirante/lol-client-java-api</url>
</repository>
</distributionManagement>
I am trying to deploy the Maven build JAR to Github Package Registry.
I am getting exception when I execute mvn deploy command.
I am using a simple Maven project which I want to create a component JAR and store in Github Package Registry.
The build is successful I now want to deploy this artifact to registry.
I have added the below in ~./m2/settings.xml.
Added a repository element under repositories in profile.
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/swastikaa-in</url>
</repository>
<servers>
<server>
<id>github</id>
<username>swastikaa</username>
<password>my personal token from github</password>
</server>
</servers>
Also, I have added the below in Maven project's pom.xml:
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/swastikaa-in/math</url>
</repository>
</distributionManagement>
Expected:
Deployment to be successful , build artifact is deployed to Github package registry.
Actual:
Exception as below:
Caused by: org.eclipse.aether.transfer.MetadataTransferException:
Could not transfer metadata com.redjohn.tools:math:0.0.2-SNAPSHOT/maven-metadata.xml
from/to github (https://maven.pkg.github.com/swastikaa-in/math):
Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
with status code 400
Caused by: org.apache.maven.wagon.TransferFailedException:
Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
with status code 400
Can someone help me in resolving the issue.
I have followed the instructions provided in the below link:
https://help.github.com/en/articles/configuring-apache-maven-for-use-with-github-package-registry
I had the same problem and I found that snapshot versions don't work well. If you deploy a non snapshot version, it should work.
Inside your settings.xml file, <url>https://maven.pkg.github.com/OWNER/REPOSITORY</url> you need to make use that OWNER is replaced with your github username and REPOSITORY is replaced with the name of your project repository in github.
I am trying to deploy maven artifact to central repository through Travis but I am facing below error:
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:deploy (injected-nexus-deploy) on project Test-plugin: Execution injected-nexus-deploy of goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:deploy failed: Nexus connection problem to URL [https://oss.sonatype.org/ ]: 401 - Unauthorized -> [Help 1]
I have set correct username and password for sonatype account, still I am getting the same error.
Below are the files uploaded:
.travis.yml
settings.xml
Looks like your settings.xml in the .m2 folder in your home directory is not having proper authorization properties set for maven to look
I am enclosing a sample XML for your reference ..
https://maven.apache.org/settings.html
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd"> ... <servers>
<server>
<id>server001</id>
<username>my_login</username>
<password>my_password</password>
<privateKey>${user.home}/.ssh/id_dsa</privateKey>
<passphrase>some_passphrase</passphrase>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server> </servers> ... </settings>
Here is the troubleshooting guide if you are getting 404
https://support.sonatype.com/hc/en-us/articles/213464518-Troubleshooting-Artifact-Download-Failures
From the docs
SNAPSHOT look-ups, or version ranges, or unversioned dependencies (typically plugins) will trigger metadata look-up. If the version referenced by the maven-metadata.xml is not there you will get a 404.
This can usually be fixed by running rebuild metadata on the affected artifact.
I am trying to run a mvn deploy goal with maven on my Liferay portlet but am getting the following error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.
2:deploy (default-deploy) on project MyPortlet: Deployment failed: repository eleme
nt was not specified in the POM inside distributionManagement element or in -Dal
tDeploymentRepository=id::layout::url parameter -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on pro
ject RiskID: Deployment failed: repository element was not specified in the POM
inside distributionManagement element or in -DaltDeploymentRepository=id::layout
I understand this error will return if you don't include the <distributionManagement /> tag in the pom.xml, however I don't wish to package this to a remote location and would like to instead deploy to my local tomcat instance; can this be configured?
The error is not about dependencyManagement but rather distributionManagement
Deployment failed: repository eleme
nt was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
The alternative (if you don't want to place it in your pom.xml file) is also provided by using the altDeploymentRepository option:
Specifies an alternative repository to which the project artifacts should be deployed ( other than those specified in <distributionManagement> ).
Format: id::layout::url
The first element, the id, must have a matching with a server defined in your settings.xml file (where you specify the credentials to use for the specific server).
The layour and the url are then specific to the target repository.
You can then invoke the command as:
mvn deploy -DaltDeploymentRepository=test:Maven2:http://somewhere:someport
Where test is the id of a server element in your Maven settings
<servers>
<server>
<id>test</id>
<username>my_login</username>
<password>my_password</password>
</server>
</servers>
Update
Based on latest clarifications (via comments and edits), here some important points:
The Maven deploy phase is meant for
done in the build environment, copies the final package to the remote repository for sharing with other developers and projects.
Hence, in your case you don't need to use the deploy phase nor the maven-deploy-plugin.
Since Tomcat is the target server, you then need to use the tomcat7-maven-plugin
Here are few instructions:
Configure your pom.xml
Add to your pom.xml the following:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>tomcat8</server>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
Configure your settings.xml
Add to your Maven settings.xml the following in the servers section:
<server>
<username>maven</username>
<password>maven</password>
<id>tomcat8</id>
</server>
Note the matching tomcat8 id between the settings and the plugin configuration above, server element.
Configure Tomcat for deploy
In the tomcat conf folder, configure the tomcat-users.xml file:
<role rolename="manager-script"/>
<user username="maven" password="maven" roles="manager-gui,manager-script"/>
note the credentials matching with what we actually specified in the Maven settings.
Try it
Then from the command line you can finally invoke:
mvn tomcat7:deploy
If you don't want to configure settings.xml nor pom.xml, you then need to pass several parameters via command line as following:
mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy \
-Durl=http://localhost:8080/manager/text \
-Dusername=maven -Dpassword=maven
Note: \ and newlines added for readibility
Check full list of options on the official documentation of its deploy goal.
#A_Di-Matteo's answer is correct for deploying to tomcat. But if you came here looking for how to deploy to a Maven repo without putting repo URLs in pom.xml then here's your answer:
mvn deploy -DskipTests -DaltDeploymentRepository=myrepoid::default::https://maven.example.org/repository/maven-releases
Instead of altDeploymentRepository, you could also use altReleaseDeploymentRepository or altSnapshotDeploymentRepository
More details in docs: https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
I am trying to compile many poms, unfortunately many of them point to a domain that doesnt exist domain:8081/repo and I want them to be domain.com:8081 ...
So, I configured the ~/.m2/settings.xml with the mirror and the proper url, as far as I remember, if the pom url is not reached, it will look for this other url and if not go to repo1.maven.org, is this correct?
Still, when compiling keep saying the repo was not found... any idea?
Thanks,
EDIT----
Since I am deploying many poms at same time, its hard to see where it fails, the error of mvn is this:
failed to read artificat descriptor.
Could not transfer artifact.
uknowon host
and the structure of the poms are like this:
<snapshotRepository>
<id>myid</id>
<name>Repository Name</name>
<url>url:8081/repositories</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
and my settings.xml
<settings>
<mirrors>
<mirror>
<id>myId</id>
<name>MirrorName</name>
<url>http://url.com:8081/repositories</url>
<mirrorOf>*,!public-snapshots,!public-legacy,!sonar</mirrorOf>
</mirror>
</mirrors>
</settings>