401 Unhautorized when creating package with maven

Hi,
I have this error:
"Failed to retrieve remote metadata org.dpsoftware:FastScreenCapture:1.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata org.dpsoftware:FastScreenCapture:1.0.1-SNAPSHOT/maven-metadata.xml from/to github ([https://maven.pkg.github.com/sblantipodi/JavaFastScreenCapture](https://maven.pkg.github.com/sblantipodi/JavaFastScreenCapture)): Authentication failed for [https://maven.pkg.github.com/sblantipodi/JavaFastScreenCapture/org/dpsoftware/FastScreenCapture/1.0.1-SNAPSHOT/maven-metadata.xml](https://maven.pkg.github.com/sblantipodi/JavaFastScreenCapture/org/dpsoftware/FastScreenCapture/1.0.1-SNAPSHOT/maven-metadata.xml) 401 Unauthorized"

when I try to create a maven package from ci.

I have this in the pom.xml

\<distributionManagement\>  
 \<repository\>  
 \<id\>github\</id\>  
 \<name\>GitHub Packages\</name\>  
 \<url\>https://maven.pkg.github.com/sblantipodi/JavaFastScreenCapture\</url\>  
 \</repository\>  
\</distributionManagement\>

but then in CI when I try to do this:

-name: Publish package
run: mvn -B deploy
env:
GITHUB\_TOKEN: ${{ secrets.GITHUB_TOKEN }}

I got the error.

can you help me please?

I succeded in uploading the first 1.0.0-SNAPSHOT the first time, but now it don’t want to get other packages. No care what version I use.

Is this a bug?

this guide does not work neither

https://help.github.com/en/actions/language-and-framework-guides/publishing-java-packages-with-maven

I’m sorry it was my fault, I forgot to import java before the mvn deploy :confused:

I had this problem too and it took me a while to figure out what “import java” means. This solved it. Add a setup-java step to the job before the step that invokes maven:

-uses: actions/setup-java@v1
 with:
   java-version: 1.8

-name: Publish package
 run: mvn -B deploy
 env:
   GITHUB\_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 Like