Using dependency in pom.xml and getting authorization error - java

I am using the following dependency
<dependency>
<groupId>net.dean.jraw</groupId>
<artifactId>JRAW</artifactId>
<version>${jraw.version}</version>
</dependency>
in my pom.xml file, but I am getting this error:
Authentication failed for https://repo.spring.io/libs-release/net/dean/jraw/JRAW/1.1.0/JRAW-1.1.0.pom 401 Unauthorized

The referenced repository requires authentication. You can configure the repository inside your project's pom.xml file, but authentication data is sensitive information and should go in your Maven installation's settings.xml file, as suggested in Servers configuration.

As announced by JFrog, anonymous access is no longer supported:
We will no longer support anonymous download of 3rd-party Maven Central artifacts from repo.spring.io, even if previously cached by an authenticated user. They should be resolved instead from the central servers.
To download artifacts anonymously, you'll have to add a central server such as jcenter. So I'd suggest you add a repository in pom.xml as below:
<repository>
<id>jcenter</id>
<name>jcenter</name>
<url>https://jcenter.bintray.com</url>
</repository>

Related

Error while reading JAR from my Remote Repository [Dropbox as Maven Repository]

So I created my own remote repository with Dropbox following this tutorial. Further, I used the following command to deploy 3rd party JARS to my repository.
mvn deploy:deploy-file -DgroupId=com.prowritingaid.java -DartifactId=pro_writing_aid_java -Dversion=2.0.0 -Dpackaging=jar -Dfile=pro_writing_aid_java-2.0.0.jar -Durl=file:/home/de-10/Dropbox/ProWritingAid
The deployment was successful and it successfully synchronised with Dropbox as well. But now when I try to refer to these jars via pom.xml, it isn't working.
I added the Dropbox URL to my repositories list:
<repository>
<id>ProWritingAid</id>
<name>Remote ProWritingAid Repository</name>
<url>https://www.dropbox.com/sh/fbv...</url>
</repository>
and I've defined the dependencies like:
<!-- Keshavram Kuduwa's Dropbox Repository -->
<dependency>
<groupId>com.prowritingaid.java</groupId>
<artifactId>pro_writing_aid_java</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Keshavram Kuduwa's Dropbox Repository -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>2.7.5</version>
</dependency>
The compile-time error is:
Description Resource Path Location Type
Archive for required library: '/home/de-10/.m2/repository/com/prowritingaid/java/pro_writing_aid_java/2.0.0/pro_writing_aid_java-2.0.0.jar' in project 'papertrue' cannot be read or is not a valid ZIP file papertrue Build path Build Path Problem
But on the other hand, when I install these packages locally with the following, it works:
mvn install:install-file -DgroupId=com.prowritingaid.java -DartifactId=pro_writing_aid_java -Dversion=2.0.0 -Dpackaging=jar -Dfile=pro_writing_aid_java-2.0.0.jar
Moreover, if I delete these locally installed packages and force update the project, the error shows up again. I also replaced the JAR in the remote repository but it didn't help.
The Jar I was deploying didn't have a pom.xml file and hence the error. I tried something different, to use an in-project repository -> Creating an In-Project Maven Repository and deploying 3rd party JARs to it.

Exception while trying to deploy Maven build JAR to github package registry

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.

Not able to load maven depedency for spark-cloudant. getting Missing artifact cloudant-labs:spark-cloudant:jar:2.0.0-s_2.11

In Java I am adding below maven dependency,
<dependency>
<groupId>cloudant-labs</groupId>
<artifactId>spark-cloudant</artifactId>
<version>2.0.0-s_2.11</version>
</dependency>
but it is not loading package even in pom.xml file showing below error,
Missing artifact cloudant-labs:spark-cloudant:jar:2.0.0-s_2.11
Can anyone help me please why it is causing issue?
I am able to add another maven dependencies but particularly this is not working..
It's not in the official maven repository. (http://search.maven.org/#search%7Cga%7C1%7Cspark-cloudant)
But when you check: https://mvnrepository.com/artifact/cloudant-labs/spark-cloudant/2.0.0-s_2.11 there is note:
Note: this artifact it located at Spark Packages repository
(https://dl.bintray.com/spark-packages/maven/)
So you will need to add following to your pom.xml:
<repositories>
<repository>
<id>bintray</id>
<name>bintray.com</name>
<url>https://dl.bintray.com/spark-packages/maven/</url>
</repository>
</repositories>
EDIT:
According to https://spark.apache.org/news/new-repository-service.html
Bintray, the original repository service used for https://spark-packages.org/, is in its sunset process, and will no longer be available from May 1st. To consume artifacts from the new repository service, please replace “dl.bintray.com/spark-packages/maven” with “repos.spark-packages.org” in the Maven pom files or sbt build files in your repositories.
So this should work:
<repositories>
<repository>
<id>bintray</id>
<name>bintray.com</name>
<url>https://repos.spark-packages.org</url>
</repository>
</repositories>
Check your maven repo to verify that the file name and version matches what you've specified. Most Maven repo's give you an example of what to use, copy/paste.
ex: Sonatype Nexus is a repo that I use and they let you search and get snippets so you never have to worry about typing things wrong.

Deploy SNAPSHOT to oss.jfrog.org (JCenter)

I tried doing a mvn deploy for oss.jfrog.org for my project. However I am getting this error:
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://oss.jfrog.org/simple/oss-snapshot-local/com/myorg/mylibrary/com/myorg/mylibrary/0.0.1-SNAPSHOT/mylibrary-0.0
.1-20141211.050111-1.pom. Return code is: 409, ReasonPhrase: Conflict.
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:573)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:493)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:474)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:454)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:871)
... 28 more
When I look into the JFrog Repository Browser, I can see that the jar is there withe the correct version, what could be this error, and why is the jar deployed anyway even with this error?
Here's my POM setting:
<distributionManagement>
<repository>
<id>bintray-myorg-maven-mylibrary</id>
<name>artifactory-snapshots</name>
<url>http://oss.jfrog.org/simple/oss-snapshot-local/com/myorg/mylibrary/</url>
</repository>
</distributionManagement>
Could it be because of the bintray-* id?
simple shouldn't be a part of your URL.
Artifactory thinks that simple is the name of the repository and oss-snapshot-local is a part of your groupId. Since pom shows a different groupId, it fails with 409.

Downloading dependencies from a secured remote repository

I'm trying to download dependencies from a remote repository which requires authentication. Is there a way to provide credentials in my pom configuration? Thank you
<repositories>
<repository>
<id>alfresco-private</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/private</url>
</repository>
</repositories>
No there isn't beacuse POM is a 'public artifact' that you could share with
your development team so it should not contains passwords.
"The repositories for download and deployment are defined by the repositories and distributionManagement elements of the POM. However, certain settings such as username and password should not be distributed along with the pom.xml. This type of information should exist on the build server in the settings.xml."
Read here: http://maven.apache.org/settings.html
To elaborate on #Cisco's answer, you would put something like this in your own local settings.xml:
<servers>
<server>
<id>alfresco-private</id>
<username>H-H</username>
<password>H-HsPassword</password>
</server>
...

Categories

Resources