Maven - unable to download dependencies behind Proxy Error Code - 307 Temporary Redirect - maven

I am using Maven to run a Java project. My issue is that I am not able to download the dependencies. It is giving the following error
[ERROR] Plugin org.apache.maven.plugins:maven-surefire-plugin:2.7.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.7.1: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central (http://repo1.maven.org/maven2): Failed to transfer http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.7.1/maven-surefire-plugin-2.7.1.pom. Error code 307, Temporary Redirect -> [Help 1]
The settings.xml is properly configured with the proxy details (since I am behind a proxy) Still, I am not able to access the maven repo to download.
UPDATE: Thanks a lot landal79.I revisited this issue after some time. Still this issue gives me a nightmare.
Currently, I am not able to create any Maven Project. I am 100% sure this is due to a proxy issue. But not able to
nail it down to where exactly the issue.
When I try creating a project selecting an archetype, I am not able to create a maven project. I am getting the below error
"Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-
quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Users\rrr.m2\repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Users\rrr.m2\repository)"
I try creating this project through Eclipse. The settings.xml point to the right proxy ( cross checked with the Network connections dialog (window ->General->NetworkConenction Dialog). But the issue still persists.
So what I did was installed standalone Maven and create a maven project from command prompt. To my surprise,I am not able to download the archetypes in Maven Repo though other plugins are getting downloaded (Surefire plugin and JUNit jar for example)
Is there any work around to resolve the archetype download issue?
I tried your solution, but the issue still persists. When I create a simple maven project (without using any archetypes) I am getting "Unable to build Project " Error
PS: The proxy settings are defined in settings.xml and they are correct. Also, the eclipse proxy settings are correct (Since I am able to install plugins from Eclipse MarketPlace)
Eclipse experts - please help me resolve this issue. Thanks a lot in advance for help.
Thanks

Related

Jenkins build failed: Could not find dependency version in maven remote repo

I created a new version in the one project, the version is x.xx.x-SNAPSHOT and used in another project as an external library then pushed it. now Jenkins build is failed.
it's saying that this new dependency is not found in my company repo. I don't have an idea how to fix this.
ERROR: The POM for jar: X.XX.X-SNAPSHOT is missing, no dependency information available
Could not find artifact :jar: X.XX.X-SNAPSHOT in artifactory (maven.xx.xx/repo)
could you please help me?
Thank you
It's fixed now. the problem was, i haven't upload new version in maven remote repo(my company repo). now I did mvn deploy. then it's uploaded and jenkins found the needed dependency.

Maven: All Plugins & Dependencies are underlined Red

ANY IDEAS?? I downloaded a Maven project for IntelliJ and cannot build it. I get errors for dependencies and plugins:
(SOLVED: THIS was because I was trying to run it on my work laptop in work, and the company firewall was blocking me from downloading from the public Maven repository. Thank you)
VIEW BUILD LOG HERE
VIEW IDEA LOG HERE
From reviewing the log files, its as people have mentioned IntelliJ is not able to actually download the dependencies.
The reason why is:
Caused by: java.lang.RuntimeException:
org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.springframework:spring-aop:pom:4.1.2.RELEASE from/to central (https://repo.maven.apache.org/maven2):
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
This typically can occur when all your external traffic is being routed by a corporate proxy that is performing a man-in-the-middle type of scan where the traffic is decrypted, scanned and then re-encrypted.
We experience the same thing in our office so our solution was:
Install your own version of the java SDK (Ex. using SDKMan)
In your new install import into the default trust store the certificates required to validate the new certificate chain
Helps to access the URL in Chrome to view the certificate chain)
If it doesn't look like the Screenshot then there is a proxy
Update IntelliJ so the Project SDK is the new one
Update IntelliJ so JDK for importer is the new one
Click the Reimport All Maven Projects in IntelliJ
This should allow it to continue to work without problems, alternatively in IntelliJ you can run the adhoc maven goal of:
mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
And it should install all the required dependencies into the local maven cache by ignoring all the SSL certificate problems however this is generally a bad idea.
At this point you can then click the Reimport All Maven Projects in IntelliJ to have it refresh but I found this always doesn't work as IntelliJ sometimes downloads additional plugin dependencies that it can get hung up on that are outside of the clean install goals.

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from any of the configured repositories. while using in STS

I am able to create Spring Boot Starter Project and Maven Web Project from the STS, but somehow unable to create the maven-archetype-quickstart project in eclipse, its giving me below error
In my project, I am using cacert file and custom setting.xml
try
maven clean install -U
as your repository is cached so try to flush the cache using -U
I was able to solve this issue by simply deleting the .m2 folder and create maven project from scratch.
After facing the same issue and going through the message several times - I found that in the local repository i.e. .m2, under the location - org\apache\maven\archetypes\maven-archetype-quickstart\1.1 - we found the error in the file - 'm2e-lastUpdated.properties' as '#default-central-https://repo.maven.apache.org/maven2/.lastUpdated=1551236380266
https://repo.maven.apache.org/maven2/.error=Could not transfer artifact org.apache.maven.archetypes:maven-archetype-quickstart:jar:1.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org'
So my Eclipse was not able to download the required JARS may be cause it is behind the firewall and in that case - Place the 'maven-archetype-quickstart-1.1.jar' and 'maven-archetype-quickstart-1.1.pom' in your local repo at the location - 'org\apache\maven\archetypes\maven-archetype-quickstart\1.1' using the link - JARS_POM and then follow the same step to create the maven Project.
Better solution is to use proxy through 'setting.xml' file of Maven to bypass the firewall to download Maven plugins and jars.
You should also check if the maven archetype catalog to eclipse is configured properly.

Can't build workspace in spring tool suite

I am having a problem while creating a spring roo project in spring tool suite..
the problem is it says "building workspace has encountered a problem.error occured during the build.
on viewing details:
Errors occurred during the build.
Errors running builder 'Maven Project Builder' on project 'first'.
Could not calculate build plan: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:aspectj-maven-plugin:jar:1.4
Plugin org.codehaus.mojo:aspectj-maven-plugin:1.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:aspectj-maven-plugin:jar:1.4
Could not calculate build plan: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:aspectj-maven-plugin:jar:1.4
Plugin org.codehaus.mojo:aspectj-maven-plugin:1.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:aspectj-maven-plugin:jar:1.4
It seems your downloaded dependencies got corrupted somehow.
Try running:
mvn -U clean install
I do answer beacuse I do not have enough reputation to make comment.So;
In STS I got the same error then found #dhamibirendra's answer and I tried and it worked in different way. (Right Clik On Project -->Run as Maven Build(not 3dot)) then write U- clean install on goal and run.(Do not forget to set Maven Runtime to external) After is done I got same error again on same project. Then I delete existing project and create new one and works with no problem. Maybe it helps someone.
Right Click On Project -->Run as Maven Build and click on the option on build clean and install one by one and also run this command in the Goal section U- clean install and click on Run.And refresh the project if you still see the problem then please delete the old project and create new one.
Delete the pom.xml file and paste it again in web content folder.This worked for me.

Maven build error on maven install

I imported a maven project onto my eclipse. I clicked on Run As->Maven Install. But I got the following build error. Please help
plugin org.apache.maven.plugins:maven-jar-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-jar-plugin:jar 2.3.2:Could not transfer artifact org.apache.maven.plugins:maven-jar-plugin:pom: 2.3.2 from/to central(http://repo1.maven.org/maven2):Error transferring file: repo1.maven.org: Unknown host repo1.maven.org
I checked /m2/repository. But could not find anything related.
Somehow it is not able to download the required artifacts from the Maven Central repo.
A suggestion please check your network connectivity, are you behind any firewall or try to change your proxysettings.
Otherwise in the worst case try to download required artifacts manually and put them in .m2/repository (as per ur local system) and try to install again.
http://search.maven.org/#browse|672389075
It should work.
Thanks

Resources