I have a working java spring-boot application that fetches a dependency from a gitlab repository.
That works fine on a local mvn package command. But as soon as I execute the mvn command inside a local docker container, maven tries to resolve the spring artifacts also from my gitlab repository. Why?
Dockerfile:
# syntax=docker/dockerfile:1
FROM maven:3.8.4-eclipse-temurin-11 as dependencies
COPY pom.xml .
COPY settings.xml .
RUN mvn --debug -U -B package -s settings.xml
pom.xml:
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath/>
</parent>
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://git.example.com/api/v4/projects/295/packages/maven</url>
</repository>
</repositories>
<dependencies>
...
</dependencies>
</project>
Result:
[INFO] Scanning for projects...
[DEBUG] Resolving artifact org.springframework.boot:spring-boot-starter-parent:pom:2.6.6 from [gitlab-maven (https://git.example.com/api/v4/projects/295/packages/maven, default, releases+snapshots), central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://git.example.com/api/v4/projects/295/packages/maven
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://git.example.com/api/v4/projects/295/packages/maven
[INFO] Downloading from gitlab-maven: https://git.example.com/api/v4/projects/295/packages/maven/org/springframework/boot/spring-boot-starter-parent/2.6.6/spring-boot-starter-parent-2.6.6.pom
settings.xml:
<settings>
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Private-Token</name>
<value>xxx</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
It must have been any sort of caching issue. I removed docker configs, restarted the machine, now it works.
Your query is why is resolve to your git repo right?
You are building the pom with your repo path, so it resolve to your repo
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://git.example.com/api/v4/projects/295/packages/maven</url>
</repository>
</repositories>
````
Related
I'm trying to deploy mule 4 application using jenkin pipeline but in the deployement process getting the below mentioned error:
[ERROR] Failed to execute goal org.mule.tools.maven:mule-maven-plugin:3.3.5:deploy (default-deploy) on project helloworld: Execution default-deploy of goal org.mule.tools.maven:mule-maven-plugin:3.3.5:deploy failed: Mule Runtime is not running!
Adding my pom.xml.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>helloworld</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule-application</packaging>
<name>helloworld</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<app.runtime>4.2.2</app.runtime>
<mule.maven.plugin.version>3.3.5</mule.maven.plugin.version>
<proejct.site.deploy.url>E:\IDFC\mule-enterprise-standalone-4.2.2\apps</proejct.site.deploy.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<standaloneDeployment>
<muleHome>E:\IDFC\mule-enterprise-standalone-4.2.2</muleHome>
<muleVersion>4.2.2</muleVersion>
</standaloneDeployment>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-http-connector</artifactId>
<version>1.5.11</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sockets-connector</artifactId>
<version>1.1.5</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-db-connector</artifactId>
<version>1.5.5</version>
<classifier>mule-plugin</classifier>
</dependency>
</dependencies>
<repositories>
<repository>
<id>anypoint-exchange-v2</id>
<name>Anypoint Exchange</name>
<url>https://maven.anypoint.mulesoft.com/api/v2/maven</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>https://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-releases</id>
<name>mulesoft release repository</name>
<layout>default</layout>
<url>https://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
in Jenkins till build it's working but while deploying i'm getting error.
For the deploy process Using custom workspace Directory and executing the custom batch command mvn package deploy -DmuleDeploy.
Here it's failing with the below added error.
This is my standalone server where i have to deploy: C:\AnypointStudio\mule-enterprise-standalone-4.2.2\apps
Can you please check my pom.xml anything else do i need to add there?
let me know where I am doing wrong to deploy on standalone server?
The Mule Maven Plugin is complaining that the target standalone Mule Runtime at C:\AnypointStudio\mule-enterprise-standalone-4.2.2\ is not running. The log error says as much: Mule Runtime is not running!. The documentation for the standalone deployment configuration seems to imply that it should be executing.
You'll need to ensure it is up and running before trying to deploy to it.
Note, installing a standalone Mule Runtime inside a directory called AnypointStudio is a bit confusing. The standalone runtime is not part of Anypoint Studio nor it interacts with Studio in any way.
I have configured a simple maven freestyle project. I was able to successfully build the project but not deploy to Nexus. I get this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy) on project eqs_utility: Failed to deploy artifacts: Could not find artifact com.companyName.eqs:eqs_utility:jar:1.0.1-20190529.191240-1 in nexus (https://nexus.companyRepo.com/repository/maven-snapshot/) -> [Help 1]
I have tried to change configurations to simplify the project but still nothing. Setting.xml changes.
EDITED
I added the following to my POM.xml
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>nexus</id>
<name>Company Nexus Repository</name>
<url>https://nexus.mycompany.com/repository/maven-release/</url>
</repository>
<snapshotRepository>
<uniqueVersion>true</uniqueVersion>
<id>nexus</id>
<name>Company Nexus Snapshots</name>
<url>https://nexus.companyName.com/repository/maven-snapshot/</url>
</snapshotRepository>
</distributionManagement>
Then, updated my settings.xml with this
<server>
<id>nexus</id>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
<!-- Another sample, using keys to authenticate. -->
<server>
<id>nexus</id>
<username>NexusUser</username>
<password>MyLongTokenValueHere</password>
</server>
According to Apache Maven Deploy Plugin setup
You need a section:
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>MyCo Internal Repository</name>
<url>Host to Company Repository</url>
</repository>
</distributionManagement>
As you're using Nexus, you probably need a section in the pom that aligns with your nexus repositories (one for snapshots and one for release artifacts since you can't combine them in nexus):
<distributionManagement>
<repository>
<id>mavenrepository</id>
<url>http://mavenrepository.companyName.com/nexus/content/repositories/m3</url>
</repository>
<snapshotRepository>
<id>tmavenrepository</id>
<url>http://mavenrepository.companyName.com/nexus/content/repositories/m3-snapshots</url>
</snapshotRepository>
</distributionManagement>
Plus of course, in your local settings or other private location
<server>
<id>mavenrepository</id>
<username>maven</username>
<password>foobar</password>
</server>
This is described by Sonatype and cleaner by others.
Thanks to a Dropwizard Maven archetype I generated a sample Dropwizard Maven project. The pom.xml notably uses maven-source-plugin:
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
When I run "clean install" I have the following error :
Plugin org.apache.maven.plugins:maven-source-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-source-plugin:jar:2.4: Could not transfer artifact org.apache.maven.plugins:maven-source-plugin:pom:2.4 from/to central (http://repo.maven.apache.org/maven2): Connection refused: connect -> [Help 1]
The "maven-source-plugin" dependency is stored in the Nexus repository of my company. So I tried the adding of the plugin dependency between dependencies and /dependencies :
<dependencies>
...
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
but it did not correct the problem. I also tried to add the dependency at the call of the plugin :
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</plugin>
but it did not work either
Two possible situations :
Your company uses a proxy to connect to the public Maven repository. Then ask someone in your company what the IP address of the proxy is then put it in your settings.xml file
Your company has its/their own Maven repository/ies (Nexus repository for example). Then ask someone in your company what the Nexus repository is then put it in your pom.xml or in your settings.xml. See Adding maven nexus repo to my pom.xml and https://maven.apache.org/guides/mini/guide-multiple-repositories.html
It may happen, e.g. after an interrupted download, that Maven cached a broken version of the referenced package in your local repository.
Solution: Manually delete the folder of this plugin from cache (i.e. your local repository), and repeat maven install.
How to find the right folder? Folders in Maven repository follow the structure:
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
</dependency>
is cached in ${USER_HOME}\.m2\repository\org\apache\maven\plugins\maven-source-plugin\2.4
Update the apache-maven-3.5.0-bin\apache-maven-3.5.0\conf\settings.xml file.
Check your internet explorer proxy --> Setting --> Internet explorer -->Connection --> LAN Setting
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>user</username>
<password>****</password>
<host>proxy</host>
<port>8080</port>
</proxy>
I am using JDK 7 for maven project and I used -Dhttps.protocols=TLSv1.2 as argument in JRE. It has allowed to download all maven repository which were failing earlier.
org.apache.maven.plugins:maven-source-plugin does not exist in the repository http://repo.maven.apache.org/maven2.
You have to download it from Maven central where it exists => maven-source-plugin
Verify your pom definition or your settings.xml file.
so I am assuming that this project you are doing in your private eclipse (not company provided eclipse where you work). The same problem I resolved just as below
quick fix : got to .m2 file --> create a backup of settings.xml --> remove settings.xml --> restart your eclipse.
On my side it was coming from an error in my settings.xml file.
I had a bad tag. Just removed it, refreshed and i was good to go.
Remove the content of the folder \.m2\repository\org\apache\maven\plugins\maven-resource-plugin\2.7. The cached info turned out to be the issue.
I use intelliJ and finally I created my own settings.xml and added the following content structure to it. In my project's pom.xml, the nexus repositories were defined but for some reason it was always hitting the external apache maven repo which is blocked in my company.
<settings>
<mirrors>
<id>nexus</id>
<url>nexusURL </url>
<mirrorOf>central</mirrorOf>
<mirror>
<profiles>
<profile>
<repositories>
<repository>
</settings>
I'm trying to setup Vaadin for a new project.
I'm following the steps documented in https://vaadin.com/wiki/-/wiki/Main/Creating+a+Maven+project
The following command in empty directory:
mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.1.8
Gives me a following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: The desired archetype does not exist (com.vaadin:vaadin-archetype-application:7.1.8) -> [Help 1]
I've also tried creating pom with:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>name</name>
<description>description</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>7.1.6</vaadin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<version>${vaadin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>${vaadin.version}</version>
</dependency>
</dependencies>
</project>
Running mvm clean install results in the following error:
[ERROR] Failed to execute goal on project artifact: Could not resolve dependencies for project group:artifact:war:1.0-SNAPSHOT: The following artifacts could not be resolved: com.vaadin:vaadin-server:jar:7.1.6, com.vaadin:vaadin-client-compiled:jar:7.1.6, com.vaadin:vaadin-client:jar:7.1.6, com.vaadin:vaadin-themes:jar:7.1.6: Failure to find com.vaadin:vaadin-server:jar:7.1.6 in http://10.255.251.14:9991/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
Also there are the following warnings seen:
[WARNING] The POM for com.vaadin:vaadin-server:jar:7.1.6 is missing, no dependency information available
[WARNING] The POM for com.vaadin:vaadin-client-compiled:jar:7.1.6 is missing, no dependency information available
[WARNING] The POM for com.vaadin:vaadin-client:jar:7.1.6 is missing, no dependency information available
[WARNING] The POM for com.vaadin:vaadin-themes:jar:7.1.6 is missing, no dependency information available
At first we thought there might be some problems with our nexus installation, but we also tried running these commands from external machine without nexus. Same issues.
Try to add
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<version>${vaadin.version}</version>
<scope>provided</scope>
</dependency>
Add this to your pom.xml:
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<repository>
<id>vaadin-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>vaadin-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
Then you have to force the update. Example: mvn install -U
It seems that the problem is related to maven repositories and not vaadin.
I've tried locating computer in other country (most likely different maven repository mirror too) and it worked.
Update: I had it working for an hour or so without changing anything and then it started failing again.
This might be related to the heartbleed bug everyone is going crazy about at the moment. Admins probably patching it all over the place and there might be some disruptions to repository services or our own network.
Looks like the list of available archetypes isn't up to date.
Run this command mvn archetype:update-local-catalog
We are trying to get the M2 Release Plugin to deploy released artifacts to our Artifactory server. The configuration in our pom.xml looks like this
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
</plugin>
....
<distributionManagement>
<repository>
<id>artifactory</id>
<url>http://example.com/artifactory/jenkins-release</url>
</repository>
</distributionManagement>
Using the Config File Provide Plugin we specified a global settings.xml with the proper credentials
<settings>
<servers>
<server>
<id>artifactory</id>
<username>jenkins</username>
<password>secret!</password>
</server>
</servers>
</settings>
If we now start a release build on Jenkins, Maven tells us that there it received an HTTP 401 from artifactory
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project example-maven-plugin: Failed to deploy artifacts: Could not transfer artifact com.example.maven.plugins:example-maven-plugin:jar:0.0.9 from/to artifactory (http://example.com/artifactory/jenkins-release): Failed to transfer file: http://example.com/artifactory/jenkins-release/com/example/maven/plugins/example-maven-plugin/0.0.9/example-maven-plugin-0.0.9.jar. Return code is: 401, ReasonPhrase:Unauthorized. -> [Help 1]
In the server logs we see that a user "non_authenticated_user" is trying to do a HTTP PUT request to this URL.
Is there some configuration in Maven or Jenkins we are missing? The credentials are correct and if I use the settings.xml from Jenkins on my local machine everything works as expected.
There is a bug in the Maven release plugin prior to 2.2.2 that makes it ignore the settings file being passed to Maven by the Config File Provider. The solution is to specify a newer maven release plugin in your projects pom.xml, like this:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.2</version>
</plugin>
</plugins>
</build>