Could not find artifact (snapshot) in Nexus repository - java

I installed the Nexus repository in my notebook, then upload a snapshot project in it. This is how it looks:
Now, I'm trying to build a Docker image, with another project that has the previous project as a dependency. This is my Dockerfile:
FROM maven:3.5.2-jdk-8-alpine AS MAVEN_BUILD
COPY settings.xml /usr/share/maven/ref/
COPY pom.xml /build/
RUN echo $(route -n | awk '/UG[ \t]/{print $2}')
RUN sed -i "s/localhost/$(route -n | awk '/UG[ \t]/{print $2}')/g" /build/pom.xml
COPY src /build/src/
WORKDIR /build/
RUN mvn package -DskipTests=true
# Other stuff that doesn't matter...
I've added this lines to pom.xml to resolve dependencies from Nexus (locahost is replaced (see Dockerfile) with docker gateway IP):
<repositories>
<repository>
<id>maven-group</id>
<url>http://localhost:8081/repository/maven-group/</url>
</repository>
</repositories>
It works as expected until maven needs to dowload my own library dependecy, the one uploaded to Nexus, failing with the message:
[ERROR] Failed to execute goal on project springboot-servicio-producto: Could not resolve dependencies for project com.abarazal.springboot.app.producto:springboot-servicio-producto:jar:0.0.1-SNAPSHOT: Could not find artifact com.abarazal.springboot.app.commons:springboot-servicio-commons:jar:0.0.1-SNAPSHOT in maven-group (http://172.17.0.1:8081/repository/maven-group/) -> [Help 1]
In pom.xml the dependency is declared as:
<dependency>
<groupId>com.abarazal.springboot.app.commons</groupId>
<artifactId>springboot-servicio-commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
What am I missing to make it work?

Check if you have more than 10% free disk space.
This may be an issue caused by elastic search.

Related

Error when trying to deploy to AZURE Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test

Hi developers friends I need help please When I try to deploy from github to my Azure AppService the github console shows me the following error.
Hi developers friends I need help please When I try to deploy from github to my Azure AppService the github console shows me the following error.
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project FastFoodApp: There are test failures.
Please refer to /home/runner/work/Project-Name/target/surefire-reports for the individual test results. Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream. -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch. Re-run Maven using the -X switch to enable full debug logging.
I already tried adding mvn clean install -DskipTests in the .yml file. Also adding in the pom.xml file
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
</dependency>
Also
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
Also I tried commenting out all code in src/test/java -> test.java
But in the end it always shows me the same error
this is the .yml file
name: Build and deploy JAR app to Azure Web App - fastfoodapi
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up Java version
uses: actions/setup-java#v1
with:
java-version: '11'
- name: Build with Maven
run: mvn clean install
- name: Upload artifact for deployment job
uses: actions/upload-artifact#v2
with:
name: java-app
path: '${{ github.workspace }}/target/*.jar'
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact#v2
with:
name: java-app
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy#v2
with:
app-name: 'fastfoodapi'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_2896B985447E4F1D85D4FE3ECA3795AC }}
package: '*.jar'
Try the following steps to resolve the error:
Right Click on project > Run as Maven Test.
The missing plugin will be downloaded automatically.
Right Click on project > Update Maven project, after that the error should be gone.
References:
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test" and "test(s) <[]> cannot be found"
How to solve "failed to execute goal "maven-surefire-plugin:2.19.1" in maven
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test

JAVA deploy first maven project failed

Please tell me what i do wrong.
I download maven project from springboot.io and import to IDE(intelliJ).
Start to deploy I get error
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy
> (default-deploy) on project securing-web-initial: Deployment failed:
> repository element was not specified in the POM inside
> distributionManagement element or in
> -DaltDeploymentRepository=id::layout::url parameter -> [Help 1] [ERROR]
I read like this Problem with deploying spring boot application and add to POM.xml
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Internal repo</name>
<url>E:\!Distrib\repo</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>example-repo</id>
<name>Example Repository</name>
<url>
E:\!Distrib\repo
</url>
</repository>
</repositories>
Nothing changed.
If I use a URL C:\!Users\tgdavies\testrepo I get the error message: Failed to deploy artifacts/metadata: Cannot access C:\!Users\tgdavies\testrepo with type default using the available connector factories: BasicRepositoryConnectorFactory
If I use file:C:\Users\tgdavies\testrepo deploy succeeds.
But your issue is that you do not need to run mvn deploy. Read the tutorial you linked to -- it does not suggest running mvn deploy. To test your code
If you use Maven, you can run the application by using ./mvnw spring-boot:run. Alternatively, you can build the JAR file with ./mvnw clean package and then run the JAR file, as follows:
java -jar target/gs-rest-service-0.1.0.jar
Import I made correctly. It is very easy. I suggested it need a lot of task after import maven project because Run button was not active. As additional automatically was open maven window with deploy and install items)).
intelliJ did not make configuration for run. As a result run button was not active.

Hudson Maven ${basedir} can't find dependency

I have a created a maven repo in a directory called lib in the base of my project.
I can use maven to build this project and fetch dependencies from the repo in the lib directory. When I try to build this project with Hudson, Hudson can not find the dependencies in the lib repo.
Here are the relevant parts of the project pom:
<dependency>
<groupId>manitou</groupId>
<artifactId>manitou.cxf.jar</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>ErpClientsLibRepo</id>
<url>file://${basedir}/lib</url>
</repository>
</repositories>
Here are the errors from Maven when ran from Hudson:
[INFO] o.h.m.e.h.MavenExecutionResultHandler - Build failed with exception(s)
[INFO] o.h.m.e.h.MavenExecutionResultHandler - [1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project DigabitERPClients: Could not resolve dependencies for project com.digabit:DigabitERPClients:jar:1.2.0: Failure to find manitou:manitou.cxf.jar:jar:1.0.0 in file:///opt/eng/hudson/jobs/20-DigabitJParent/workspace/DigabitErpClients/lib was cached in the local repository, resolution will not be reattempted until the update interval of ErpClientsLibRepo has elapsed or updates are forced
[DEBUG] Closing connection to remote
[ERROR] Failed to execute goal on project DigabitERPClients: Could not resolve dependencies for project com.digabit:DigabitERPClients:jar:1.2.0: Failure to find manitou:manitou.cxf.jar:jar:1.0.0 in file:///opt/eng/hudson/jobs/20-DigabitJParent/workspace/DigabitErpClients/lib was cached in the local repository, resolution will not be reattempted until the update interval of ErpClientsLibRepo has elapsed or updates are forced -> [Help 1]
Here is a dir listing at the path Maven (As ran by Hudson) seems to be looking at:
[root#vail lib]# cd /opt/eng/hudson/jobs/20-DigabitJParent/workspace/DigabitErpClients/lib
[root#vail lib]# ls
manitou
[root#vail lib]# ls manitou/
manitou.cxf.jar
[root#vail lib]#
Any ideas what I'm doing wrong? Thanks
I went into the hudson project and forced maven to update, now the build works :S

Can't create maven project from console on Windows - error

I tried to generate maven project in Windows XP.
I created folder with pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>selenium.web.driver</groupId>
<artifactId>OMS_selenium_Test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>selenium_tests</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<scope></scope>
</dependency>
</dependencies>
</project>
Opened cmd and going into this folder.
Run the next command:
C:\Documents and Settings\Admintemp\maven_test>mvn archetype:generate -DgroupId=
selenium.web.driver -DartifactId=OMS_selenium_Test -Dversion=1.0-SNAPSHOT -Dinte
ractiveMode=false
Instead of generating project with this data I caught next errror:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.2:generate (default-cli) on project OMS_selenium_Test: Unable to add module to
the current project as it is not of packaging type 'pom' -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
Why this exactly happen?
Maybe I miss smt, but I can't figure out what exactly...
How to solve this trouble and generate project with maven?
Your mistake has been to create a POM file by hand. Maven will do this automatically when you run the command you attempted. Delete your POM file and try running the command again.
Maven assumed you wanted to add a sub-module to an existing Maven project. This failed because your existing POM file was "jar" project (e.g. normal Java code) when it was expecting a "pom" project.
This happens when you run the generate command from within the same folder where you ran the mvn archetype:create-from-project from (or in this case, the POM you generated made maven think this was an existing project).
Ernestas answer worked because they switched to a different folder and ran the same command.
Well, I tried the following commands and it worked for me:
> cd C:\Temp
> mvn archetype:generate -DgroupId=selenium.web.driver -DartifactId=OMS_selenium_Test -Dversion=1.0-SNAPSHOT -DinteractiveMode=false
EDIT
Now I have my project in: C:\Temp\OMS_selenium_Test

The POM for project is missing, no dependency information available

Background
Trying to add a Java library to the local Maven repository using a clean install of Apache Maven 3.1.0, with Java 1.7. Here is how the Java archive file was added:
mvn install:install-file \
-DgroupId=net.sourceforge.ant4x \
-DartifactId=ant4x \
-Dversion=0.3.0 \
-Dfile=ant4x-0.3.0.jar \
-Dpackaging=jar
This created the following directory structure:
$HOME/.m2/repository/net/sourceforge/ant4x/
├── 0.3.0
│ ├── ant4x-0.3.0.jar.lastUpdated
│ └── ant4x-0.3.0.pom.lastUpdated
└── ant4x
├── 0.3.0
│ ├── ant4x-0.3.0.jar
│ ├── ant4x-0.3.0.pom
│ └── _remote.repositories
└── maven-metadata-local.xml
The project's pom.xml file references the dependent project (the tree above) as follows:
<properties>
<java-version>1.5</java-version>
<net.sourceforge.ant4x-version>0.3.0</net.sourceforge.ant4x-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
...
<dependency>
<groupId>net.sourceforge</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
Problem
After running mvn compile, the following error was returned (full log on Pastebin):
[ERROR] Failed to execute goal on project ant4docbook: Could not resolve dependencies for project net.sourceforge:ant4docbook:jar:0.6-SNAPSHOT: Failure to find net.sourceforge:ant4x:jar:0.3.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
The documentation notes a number of issues that could be present, however none of these appear to apply.
Ideas
I tried the following, as per the documentation:
Copy default settings to user's home directory for Maven:
cp /opt/apache-maven-3.1.0/conf/settings.xml $HOME/.m2/.
Edit the user's settings.xml file.
Update the value for the local repository:
${user.home}/.m2/repository
Save the file.
I also tried the following commands:
mvn -U
mvn clear -U
I tried using Maven 3.0.5, but that failed, too.
Question
How do you force Maven to use the local version of the library, rather than trying to seek out a library that is not yet available to download?
Related
Related questions and information that did not resolve the issue:
The POM for org.springframework.security:org.springframework.security.web:jar:3.0.5.RELEASE is missing, no dependency information available
How can I locate the POM which requests a missing POM?
Maven: Including jar not found in public repository
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
http://giallone.blogspot.ca/2012/12/maven-install-missing-offline.html
Change:
<!-- ANT4X -->
<dependency>
<groupId>net.sourceforge</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
To:
<!-- ANT4X -->
<dependency>
<groupId>net.sourceforge.ant4x</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
The groupId of net.sourceforge was incorrect. The correct value is net.sourceforge.ant4x.
The scope <scope>provided</scope> gives you an opportunity to tell that the jar would be available at runtime, so do not bundle it. It does not mean that you do not need it at compile time, hence maven would try to download that.
Now I think, the below maven artifact do not exist at all. I tries searching google, but not able to find. Hence you are getting this issue.
Change groupId to <groupId>net.sourceforge.ant4x</groupId> to get the latest jar.
<dependency>
<groupId>net.sourceforge.ant4x</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
Another solution for this problem is:
Run your own maven repo.
download the jar
Install the jar into the repository.
Add a code in your pom.xml something like:
Where http://localhost/repo is your local repo URL:
<repositories>
<repository>
<id>wmc-central</id>
<url>http://localhost/repo</url>
</repository>
<-- Other repository config ... -->
</repositories>

Categories