maven copy-dependencies fails on status 403 forbidden - maven

Project I'm working on uses Vaadin framework (old version 7) and java 8. Project is implemented as multiple projects (modules).
Everything worked fine for a few months until yesterday. I did some changes on 'core' part of the project, ran mvn install and jumped into the main project. There I ran
mvn clean
mvn dependency:copy-dependencies
to get my changes and dependencies copied from core to the main project. Last goal (copy-dependencies) always fails with this error
(note that I covered some information in the error message on purpose):
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< myproject.main >-------------------------
[INFO] Building Main version
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/com/vaadin/addon/jpacontainer/3.1.1/jpacontainer-3.1.1.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/com/vaadin/addon/vaadin-touchkit-agpl/3.0.0/vaadin-touchkit-agpl-3.0.0.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/resetbuttonfortextfield/1.2.1/resetbuttonfortextfield-1.2.1.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/addon/confirmdialog/2.1.2/confirmdialog-2.1.2.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/com/vaadin/tapio/googlemaps/0.6.1/googlemaps-0.6.1.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/addons/contextmenu/4.5/contextmenu-4.5.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/addons/lazyquerycontainer/vaadin-lazyquerycontainer/7.3.3.6/vaadin-lazyquerycontainer-7.3.3.6.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/addons/popupbutton/2.6.0/popupbutton-2.6.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.383 s
[INFO] Finished at: 2021-08-17T11:37:09+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project main: Could not resolve dependencies for project *myproject.core:version*: Failed to collect dependencies at *myproject.core:version* -> com.vaadin.addon:jpacontainer:jar:3.1.1: Failed to read artifact descriptor for com.vaadin.addon:jpacontainer:jar:3.1.1: Could not transfer artifact com.vaadin.addon:jpacontainer:pom:3.1.1 from/to mvn-repository jetty (https://mvnrepository.com/artifact/): authorization failed for https://mvnrepository.com/artifact/com/vaadin/addon/jpacontainer/3.1.1/jpacontainer-3.1.1.pom, status: 403 Forbidden -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[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
The weird thing is that I don't know about any change in the project or my pc that could cause this issue.
I already tried:
mvn -U dependency:copy-dependencies
running mvn package on before trying to copy dependencies (fails with the same error)
Resetting my Intellij environment
Recompiling every dependent projects
I read the wiki article from the error message but I do not consider it to much use - project work before that without me having to set for example proxy or TLS. Do you have any suggestions on how to solve this problem ?

The problem was indeed in the maven repository link. It seems that the dependencies have changed recently.
In my case the solution was to remove the repository in POM that caused trouble, namely
<repository>
<id>mvn-repository jetty</id>
<url>https://mvnrepository.com/artifact/</url>
</repository>

Related

Why deploying maven packages on terminal throws an error but the maven package ends up being published on GitHub packages anyway?

I have been using Clojure, ClojureScript, lein, shadow-cljs, re-frame,
reagent, Emacs, and CIDER to work on a Clojure/ClojureScript dynamic
web app project.
Now, I am trying to make depencies be private Maven packages hosted
for free on GitHub packages. Ok, I managed to publish a package!
After the successful attempt to publish my first maven package, it
ended up with the name of repository-name.repository-name
which looks ugly. As I was trying to tweak it, I ended up changing
this line on my project.clj file:
:pom-addition [:distribution-management [:repository [:id "github"]
[:name "GitHub Packages"]
[:url "https://maven.pkg.github.com/organization-name/repository-name"]]])
Instead of [:url "https://maven.pkg.github.com/organization-name/repository-name"] I
tweaked it to be [:url "https://maven.pkg.github.com/organization-name"].
Now, things got really weird in my opinion.
After executing the terminal command to publish it:
➜ mvn deploy -DaltReleaseDeploymentRepository="${REPO}" -DaltSnapshotDeploymentRepository="${REPO}"
The terminal throws:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.563 s
[INFO] Finished at: 2022-10-28T12:33:16-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project project-name: Failed to retrieve remote metadata project-name:project-name/maven-metadata.xml: Could not transfer metadata project-name:project-name/maven-metadata.xml from/to github (https://maven.pkg.github.com/organization-name): transfer failed for https://maven.pkg.github.com/organization-name/project-name/project-name/maven-metadata.xml, status: 422 Unprocessable Entity -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[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/MojoExecutionException
Now, when I go to https://github.com/orgs/my-organization/packages, the package was indeed published!
And with the name of repository-name instead of repository-name.repository-name.
Why is that so? If the build failed, why is the packaged being published?
Also, what would be standard name for Maven packages on GitHub
packages (especially considering these are Maven packages for a
Clojure project)?

Fresh Vaadin 8.1 app "multimodule" app fails to build

When creating a new Vaadin 8.1.0 app named bogus using the archetype vaadin-archetype-application-multimodule, the build fails in IntelliJ 2017.2 when running Maven Projects panel > bogus-ui > Plugins > jetty > jetty:run
I get these error messages on console.
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java -Dmaven.multiModuleProjectDirectory=/Users/basilbourque/IdeaProjects/bogus/bogus-ui "-Dmaven.home=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3" "-Dclassworlds.conf=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/m2.conf" "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=55637:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2017.2 org.eclipse.jetty:jetty-maven-plugin:9.3.9.v20160517:run
objc[11304]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java (0x1060bd4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10712c4e0). One of the two will be used. Which one is undefined.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building bogus-ui 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> jetty-maven-plugin:9.3.9.v20160517:run (default-cli) > test-compile # bogus-ui >>>
Downloading: http://maven.vaadin.com/vaadin-addons/com/example/bogus-backend/1.0-SNAPSHOT/maven-metadata.xml
Downloading: http://maven.vaadin.com/vaadin-addons/com/example/bogus-backend/1.0-SNAPSHOT/bogus-backend-1.0-SNAPSHOT.pom
[WARNING] The POM for com.example:bogus-backend:jar:1.0-SNAPSHOT is missing, no dependency information available
Downloading: http://maven.vaadin.com/vaadin-addons/com/example/bogus-backend/1.0-SNAPSHOT/bogus-backend-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.334 s
[INFO] Finished at: 2017-07-30T22:58:18-07:00
[INFO] Final Memory: 11M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project bogus-ui: Could not resolve dependencies for project com.example:bogus-ui:war:1.0-SNAPSHOT: Could not find artifact com.example:bogus-backend:jar:1.0-SNAPSHOT in vaadin-addons (http://maven.vaadin.com/vaadin-addons) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[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
Process finished with exit code 1
Using Java 8 Update 144 on macOS Sierra 10.12.5 with IntelliJ Ultimate edition 2017.2.
The linked Question, Maven: How to use jetty:run in a multi-module Maven project, without needing to install, is not a duplicate of this Question. That one asks about one module (the Web Module) picking up on changes made in other modules and causing a rebuild rather than retrieving built items from local repository. I am asking how to run the app in the first place, long before needing to trigger re-builds.
Lifecycle > install on root/parent module
Maven needs to find dependencies before running.
You need to run 'mvn install' on root (parent) project or on your backend module (and other project that backend depends on).
you need to run mvn clean install command on the the parent project from root directory>

Unable to get dependency information when running mvn jetty:run

I cloned a project from github and try to build it. Follow its instruction I run mvn package but when I try to run mvn jetty:run. It failed and give me:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Unable to get dependency information: Unable to read the metadata file for artifact 'org.mortbay.jasper:apache-jsp:jar': Cannot find parent: org.eclipse.jetty:jetty-parent for project: org.mortbay.jasper:jasper-jsp:pom:8.0.9.M3 for project org.mortbay.jasper:jasper-jsp:pom:8.0.9.M3
org.mortbay.jasper:apache-jsp:jar:8.0.9.M3
Why this happen?
Upgrade maven to version 3 or higher. I had maven 2.2.1, then I upgraded it to 3.3.9 and this issue was solved.
Also use JDK 1.7 or higher.

Maven gives “Resolving Version for Plugin” Error when trying to create a project

I am a newbie to both Linux and Maven. I am trying to get maven working so I can install Mahout. I am having more than just one problem with the process but I will focus on the most basic one:
I am trying to follow this guide
to learn how to get started with maven. when I run the following command in the terminal
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
I get the following error:
dave#CodeKingdom:~/workspace/maven_test$ mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
[INFO] Scanning for projects...
[WARNING] The metadata /home/dave/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata-central.xml is invalid: end tag name </HEAD> must be the same as start tag <META> from line 1 (position: START_TAG seen ...e/maven/plugins/maven-archetype-plugin/maven-metadata.xml"></HEAD>... #1:385)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.446s
[INFO] Finished at: Thu Apr 10 17:43:57 PDT 2014
[INFO] Final Memory: 8M/310M
[INFO] ------------------------------------------------------------------------
[ERROR] Error resolving version for plugin 'org.apache.maven.plugins:maven-archetype-plugin' from the repositories [local (/home/dave/.m2/repository), central (http://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[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/PluginVersionResolutionException
I can't make much sense of the resources out there. What I gather based on my googling is that maven is unable to connect to internet to download the necessary artifacts. But I am not sure whether I should modify setting.xml or pom.xml to fix this or whether I should do something completely different. Plus I can't seem to find a pom.xml file in my maven folder. There is a settings.xml file but I am not clear on how or if I should modify it.
Any help is appreciated.

Get the dependency tree of a maven project with a missing dependency

First of all, let me start by saying mvn dependency:tree does not work in my scenario.
I'm working on an already existing codebase which is giving a build failure. The issue was that the maven repos (including nexus) does not have a POM for a transitive dependency (org.apache.ws.security:wss4j:pom:1.5.2) in this project.
I want to find where this dependency came from. It's probably a transitive dependency, because it isn't listed in the project's pom nor in parent poms. Invoking mvn dependency:tree does not work because it also fails with the same error I get when I use mvn install (Connection timeout). The error is given below.
So, how can I identify which dependency tries to download this pom? I'd like a general answer to find the dependency tree rather than focusing on wss4j pom stated above.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Sample/XKMS 4.5.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://ws.zones.apache.org/repository2/org/apache/ws/security/wss4j/1.5.2/wss4j-1.5.2.pom
[WARNING] The POM for bouncycastle:bcprov-jdk13:jar:132 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:10.155s
[INFO] Finished at: Wed Mar 14 10:35:20 IST 2012
[INFO] Final Memory: 7M/490M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project wso2appserver-samples-xkms: Could not resolve dependencies
for project org.wso2.appserver:wso2appserver-samples-xkms:jar:4.5.0-SNAPSHOT: Failed to collect dependencies for [org.wso2.xkms:xkms:jar:2.2 (compile)]: Failed to read artifact descriptor for org.apache.ws.security:wss4j:jar:1.5.2:
Could not transfer artifact org.apache.ws.security:wss4j:pom:1.5.2 from/to ws-zones-repository (http://ws.zones.apache.org/repository2): Error transferring file: Connection timed out -> [Help 1]
mvn dependency:tree --debug
outputs the tree before failing in my case.
One way to find this out, is to install the m2eclipse Maven plugin for Eclipse. (If you have and are using Eclipse, that is.) The name is unrelated to the version; it works happily with at least Maven 2.2.1 and 3.
http://www.eclipse.org/m2e/
Then, open your root pom in Eclipse, and click on the Dependency Hierarchy tab. On the right-hand side will be all the dependencies the project will download, and on the left is what dependencies ask for what. If a dependency says (managed from X), it means another dependency wants a different version of this dependency This isn't flawless, however. I still had too look at some of the other poms to find the dependency I was looking for. But it should make life easier, and at least point you in the right direction.

Resources