Why "Blocked mirror for repositories" error though using HTTPS URL in maven settings.xml - maven-3

my maven version is 3.8.5, and the following is mirrors config in maven settings.xml
<mirrors>
<mirror>
<id>aliyun</id>
<mirrorOf>*</mirrorOf>
<name>aliyun</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<blocked>true</blocked>
</mirror>
</mirrors>
When blocked set false , mvn packge running ok, but it set true , then output following error
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 209, column 21
[ERROR] Non-resolvable import POM: Could not transfer artifact org.springframework.security:spring-security-bom:pom:5.6.3 from/to aliyun (https://maven.aliyun.com/nexus/content/groups/public/): Blocked mirror for repositories: [central (https://repo.maven.apache.org/maven2, default, releases)] # org.springframework.boot:spring-boot-dependencies:2.6.7, /data/mvn/repository/org/springframework/boot/spring-boot-dependencies/2.6.7/spring-boot-dependencies-2.6.7.pom, line 2751, column 19
[ERROR] Non-resolvable import POM: Could not transfer artifact org.springframework.session:spring-session-bom:pom:2021.1.3 from/to aliyun (https://maven.aliyun.com/nexus/content/groups/public/): Blocked mirror for repositories: [central (https://repo.maven.apache.org/maven2, default, releases)] # org.springframework.boot:spring-boot-dependencies:2.6.7, /data/mvn/repository/org/springframework/boot/spring-boot-dependencies/2.6.7/spring-boot-dependencies-2.6.7.pom, line 2758, column 19
#
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.adwetec:adwetec:1.0 (/data/adwetec-user/adwetec-idm/pom.xml) has 2 errors
[ERROR] Non-resolvable import POM: Could not transfer artifact org.springframework.security:spring-security-bom:pom:5.6.3 from/to aliyun (https://maven.aliyun.com/nexus/content/groups/public/): Blocked mirror for repositories: [central (https://repo.maven.apache.org/maven2, default, releases)] # org.springframework.boot:spring-boot-dependencies:2.6.7, /data/mvn/repository/org/springframework/boot/spring-boot-dependencies/2.6.7/spring-boot-dependencies-2.6.7.pom, line 2751, column 19 -> [Help 2]
[ERROR] Non-resolvable import POM: Could not transfer artifact org.springframework.session:spring-session-bom:pom:2021.1.3 from/to aliyun (https://maven.aliyun.com/nexus/content/groups/public/): Blocked mirror for repositories: [central (https://repo.maven.apache.org/maven2, default, releases)] # org.springframework.boot:spring-boot-dependencies:2.6.7, /data/mvn/repository/org/springframework/boot/spring-boot-dependencies/2.6.7/spring-boot-dependencies-2.6.7.pom, line 2758, column 19 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
WHY?How to set it ?

You have to configure the central access in your settings.xml correctly like this:
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>https://central</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://central</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>

Related

Not able to re-run failed tests with Junit5 and Surefire plugin

I am trying to re-run the failed tests using Junit5 and maven-surefire-plugin.
I have tried passing up the rerunFailingTestsCount as property and also as config property in pom.xml.
mvn '-Dsurefire.rerunFailingTestsCount=2' '-Dtest=com.salesforceiq.engagementapis.TestReRun#testfailure' clean test
https://maven.apache.org/surefire-archives/surefire-2.18.1/maven-failsafe-plugin/examples/rerun-failing-tests.html
But it seems failed tests are not re-running
This is my simple test class
public class TestReRun {
#Test
public void testfailure(){
Assert.assertTrue(false);
}
}
This is pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<rerunFailingTestsCount>2</rerunFailingTestsCount>
<failIfNoTests>false</failIfNoTests>
<useSystemClassLoader>false</useSystemClassLoader>
<perCoreThreadCount>false</perCoreThreadCount>
<forkCount>0</forkCount>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>1.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-api</artifactId>
<version>1.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.2.0-M1</version>
</dependency>
Actual results:
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.11 s <<< FAILURE! - in com.salesforceiq.engagementapis.TestEngagementFetchAPIs
[ERROR] testfailure Time elapsed: 0.176 s <<< FAILURE!
java.lang.AssertionError
at com.salesforceiq.engagementapis.TestEngagementFetchAPIs.testfailure(TestEngagementFetchAPIs.java:242)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] TestEngagementFetchAPIs.testfailure:242
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.805 s
[INFO] Finished at: 2019-09-21T15:40:15-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.0:test (default-test) on project siqapiautomation: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/nishkam.agrawal/Documents/projects/siqapiautomation/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException```
The feature "re-run" is supported since of 3.0.0-M4, see the Feature Matrix.
For more details see these Jiras:
Support #ParameterizedTest for JUnit 5 test reruns
Rerun Failing Tests with JUnit 5
Surefire / Failsafe rerun failed tests functionality fails with JUnit 5 if using #DisplayName
Don't use forkCount=0. It is mostly useless in non-trivial projects.
it's not yet implemented :(
see https://github.com/junit-team/junit5/issues/1558 and https://issues.apache.org/jira/browse/SUREFIRE-1584

Cannot build Docker image using spotify plugin

I have been using spotify plug-in to build docker images, but it suddenly stops working for some reason, and it spews out error complaining about exec failure on spotify plug-in
[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) # SimpleWebApp ---
[INFO] Building jar: /home/test/opd_workspace/my_simple_webapp/target/SimpleWebApp-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.3.5.RELEASE:repackage (default) # SimpleWebApp ---
[INFO]
[INFO] --- docker-maven-plugin:0.2.3:build (default-cli) # SimpleWebApp ---
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Copying /home/test/opd_workspace/my_simple_webapp/target/SimpleWebApp-0.0.1-SNAPSHOT.jar -> /home/test/opd_workspace/my_simple_webapp/target/docker/SimpleWebApp-0.0.1-SNAPSHOT.jar
[INFO] Copying src/main/docker/Dockerfile -> /home/test/opd_workspace/my_simple_webapp/target/docker/Dockerfile
[INFO] Building image imgprefix/SimpleWebApp
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.282s
[INFO] Finished at: Wed Jun 01 19:42:14 EDT 2016
[INFO] Final Memory: 27M/340M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.2.3:build (default-cli) on project SimpleWebApp: Exception caught: Request error: POST unix://localhost:80/v1.12/build?t=imgprefix/SimpleWebApp: 500: HTTP 500 Internal Server Error -> [Help 1]
My pom.xml plug-in is very simple, and maven project build and package is ok
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.2.3</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
Following the line:
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.2.3:build (default-cli) on project SimpleWebApp: Exception caught: Request error: POST unix://localhost:80/v1.12/build?t=imgprefix/SimpleWebApp: 500: HTTP 500 Internal Server Error -> [Help 1]
It seems you are using UNIX as operating system and Docker answers you an error 500.
I'm using MACOS and It works perfectly for me with the same configuration as yours but before I need to evaluation Docker environment variables in my terminal with:
eval $(docker-machine env default)
Using that library you can't use respository names with uppercase. Only [a-z0-9-_.] are allowed.
So change
SimpleWebApp
to
simple-web-app
or something similar.

Maven http.authentication.preemptive against Artifactory

I am having enormous difficulty downloading "protected" artifacts from my Artifactory server. Can anyone confirm that the (maven) settings.xml excerpt below is sufficient to cause GET requests to carry authentication info preemptively?
Maven 3.3.9. Artifactory 4.4.2.
<servers>
<server>
<id>myServerId</id>
<username>myUserId</username>
<password>myPlainTextPassword</password>
<configuration>
<httpConfiguration>
<all>
<params>
<property>
<name>http.authentication.preemptive</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>
Thanks,
Robin
Maven output:
C:\>mvn -U clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building fc 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.myserver.co.uk/artifactory/libs-release/com/group/artifact/126/artifact-126.pom
Downloading: http://www.license4j.com/maven/com/group/artifact/126/artifact-126.pom
Downloading: http://repo.myserver.co.uk/artifactory/private-local/com/group/artifact/126/artifact-126.pom
Downloading: https://repo.maven.apache.org/maven2/com/group/artifact/126/artifact-126.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.906 s
[INFO] Finished at: 2016-01-31T19:41:52+02:00
[INFO] Final Memory: 8M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project fc: Could not resolve dependencies for project uk.co.myserver:fc:jar:1.0-SNAPSHOT: Failed to collect dependencies at com.group:artifact:jar:126: Failed to read artifact descriptor for com.group:artifact:jar:126: Could not transfer artifact com.group:artifact:pom:126 from/to releases (http://repo.myserver.co.uk/artifactory/libs-release): Access denied to: http://repo.myserver.co.uk/artifactory/libs-release/com/group/artifact/126/artifact-126.pom , ReasonPhrase:Forbidden. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Artifactory Access Log:
2016-02-01 11:14:33,562 [DENIED DOWNLOAD] libs-release:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:33,564 [DENIED DOWNLOAD] private-release-local:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:34,436 [ACCEPTED DELETE] libs-release:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:35,010 [DENIED DOWNLOAD] private-local:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:35,011 [DENIED DOWNLOAD] private-release-local:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:35,012 [ACCEPTED DELETE] private-local:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
All of the below exist identically in pom.xml and in settings.xml and, since they all reference the same Artifactory server, they share identical username/password/http.authentication.preemptive parameters :
<id>releases</id>
<id>snapshots</id>
<id>private-local</id>
<id>plugin-releases</id>
<id>plugin-snapshots</id>
<id>deploy-releases</id>
<id>deploy-snapshots</id>
Only the below is not mentioned in settings.xml, as access should be anonymous and it is a separate repository instance on someone else's server:
<id>license4j-runtime-library</id>
Here is the corresponding output from the request log:
20160202060102|58|REQUEST|193.66.174.253|admin|GET|/ui/systemlogs/logData|HTTP/1.1|200|0
20160202060102|1099|REQUEST|199.19.249.196|anonymous|GET|/libs-release/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060102|706|REQUEST|199.91.135.165|anonymous|GET|/libs-release/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060102|5|REQUEST|193.66.174.253|anonymous|GET|/libs-release/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060103|3|REQUEST|199.19.249.196|anonymous|GET|/private-local/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060103|3|REQUEST|193.66.174.253|anonymous|GET|/private-local/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060113|60|REQUEST|193.66.174.253|admin|GET|/ui/systemlogs/logData|HTTP/1.1|200|0
Note that there are two requests to private-local, both of which occur as "anonymous". With preemptive authentication I would have expected all of these to have been as "myUserId".
What are the permissions that you have for your anonymous user on Artifactory?
On Artifactory --> Admin --> Security --> General --> Is the checkbox for "Hide existence of unauthorised resources" is checked?
Other than that can you also paste the relevant part from the request.log?
When going behind a proxy the httpConfiguration for the server must be:
<server>
<id>**********</id>
<username>**********</username>
<password>**********</password>
<configuration>
<httpConfiguration>
<all>
<usePreemptive>true</usePreemptive>
</all>
</httpConfiguration>
</configuration>
</server>

Return Code 401 with Maven 3 uploading SNAPSHOT to Artifactory

I am running the following:
Apache Maven 3.0.5, Artifactory(Open-Source) 3.1.0
No Jenkins/Hudson, just the default Artifactory setup.
Excerpt from pom.xml:
<distributionManagement>
<repository>
<id>ServerA2</id>
<name>ServerA2-releases</name>
<url>http://192.168.1.16:8081/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>ServerA2</id>
<name>ServerA2-snapshots</name>
<url>http://192.168.1.16:8081/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
Excerpt from settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>admin</username>
<password>XXX</password>
<id>central</id>
</server>
<server>
<username>admin</username>
<password>XXX</password>
<id>snapshots</id>
</server>
<server>
<username>admin</username>
<password>XXX</password>
<id>ServerA2</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://192.168.1.16:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://192.168.1.16:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://192.168.1.16:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://192.168.1.16:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
Now to the problem:
I have no problems doing mvn deploy when I set the version in pom.xml to <version>1.0</version>. The Artifact was uploaded successfully
But I encounter the following error when I set the version in pom.xml to <version>1.0-SNAPSHOT</version>
Output from mvn clean deploy -X -e
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) # pinder ---
[DEBUG] org.apache.maven.plugins:maven-deploy-plugin:jar:2.7:
[DEBUG] org.apache.maven:maven-plugin-api:jar:2.0.6:compile
[DEBUG] org.apache.maven:maven-project:jar:2.0.6:compile
[DEBUG] org.apache.maven:maven-settings:jar:2.0.6:compile
[DEBUG] org.apache.maven:maven-profile:jar:2.0.6:compile
[DEBUG] org.apache.maven:maven-artifact-manager:jar:2.0.6:compile
[DEBUG] org.apache.maven:maven-repository-metadata:jar:2.0.6:compile
[DEBUG] org.apache.maven:maven-plugin-registry:jar:2.0.6:compile
[DEBUG] org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG] junit:junit:jar:3.8.1:compile
[DEBUG] classworlds:classworlds:jar:1.1-alpha-2:compile
[DEBUG] org.apache.maven:maven-model:jar:2.0.6:compile
[DEBUG] org.apache.maven:maven-artifact:jar:2.0.6:compile
[DEBUG] org.codehaus.plexus:plexus-utils:jar:1.5.6:compile
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
[DEBUG] Imported: < project>sg.com.pinder:pinder:0.0.1-SNAPSHOT
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7
[DEBUG] Included: org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
[DEBUG] Included: junit:junit:jar:3.8.1
[DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:1.5.6
[DEBUG] Excluded: org.apache.maven:maven-plugin-api:jar:2.0.6
[DEBUG] Excluded: org.apache.maven:maven-project:jar:2.0.6
[DEBUG] Excluded: org.apache.maven:maven-settings:jar:2.0.6
[DEBUG] Excluded: org.apache.maven:maven-profile:jar:2.0.6
[DEBUG] Excluded: org.apache.maven:maven-artifact-manager:jar:2.0.6
[DEBUG] Excluded: org.apache.maven:maven-repository-metadata:jar:2.0.6
[DEBUG] Excluded: org.apache.maven:maven-plugin-registry:jar:2.0.6
[DEBUG] Excluded: org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1
[DEBUG] Excluded: classworlds:classworlds:jar:1.1-alpha-2
[DEBUG] Excluded: org.apache.maven:maven-model:jar:2.0.6
[DEBUG] Excluded: org.apache.maven:maven-artifact:jar:2.0.6
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-deploy-plugin:2.7, parent: sun.misc.Launcher$AppClassLoader#645ad7b2]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy' with basic configurator -->
[DEBUG] (f) artifact = sg.com.pinder:pinder:jar:0.0.1-SNAPSHOT
[DEBUG] (f) attachedArtifacts = []
[DEBUG] (s) localRepository = id: local
url: file:///home/Eric_Vader/.m2/repository/
layout: none
[DEBUG] (f) offline = false
[DEBUG] (f) packaging = jar
[DEBUG] (f) pomFile = /home/Eric_Vader/workspace/pinder/pom.xml
[DEBUG] (f) project = MavenProject: sg.com.pinder:pinder:0.0.1-SNAPSHOT # /home/Eric_Vader/workspace/pinder/pom.xml
[DEBUG] (f) retryFailedDeploymentCount = 1
[DEBUG] (f) skip = false
[DEBUG] (f) updateReleaseInfo = false
[DEBUG] -- end configuration --
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://192.168.1.16:8081/artifactory/libs-snapshot-local as admin
Downloading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/maven-metadata.xml
[DEBUG] Could not find metadata sg.com.pinder:pinder:0.0.1-SNAPSHOT/maven-metadata.xml in ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local)
[DEBUG] Writing resolution tracking file /home/Eric_Vader/.m2/repository/sg/com/pinder/pinder/0.0.1-SNAPSHOT/resolver-status.properties
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.000s
[INFO] Finished at: Fri Dec 27 16:48:15 SGT 2013
[INFO] Final Memory: 18M/216M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project pinder: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project pinder: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:141)
at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
... 21 more
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:280)
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:211)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:443)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:137)
... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact sg.com.pinder:pinder:jar:0.0.1-20131227.084815-1 from/to ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local): Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:951)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:939)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:837)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:467)
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:274)
... 26 more
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar. Return code is: 401
at org.apache.maven.wagon.providers.http.LightweightHttpWagon.finishPutTransfer(LightweightHttpWagon.java:257)
at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:423)
at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:402)
at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:376)
at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:163)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:811)
... 28 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Excerpt from access.log:
2013-12-27 16:48:15,328 [DENIED DEPLOY] libs-snapshot-local:sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.jar for anonymous/192.168.1.164.
2013-12-27 16:48:15,335 [DENIED DEPLOY] libs-snapshot-local:sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20131227.084815-1.pom for anonymous/192.168.1.164.
I tried most of the things suggested by other similar questions like:
trying setting the Maven Snapshot Version Behavior setting, snapshot tag in settings.xml.
One thing to note is that the log on the Artifactory server does not log anything when the error occur.
That's what's going on - you have 2 repositories under the id central - both libs-release-local (in distributionManagement) and libs-release (in settings). Same for snapshots.
That drives Maven crazy in some unpredicted ways (Maven good in that).
So, shadowing central and snapshots in settings is the right way to go, but repositories in distributionManagement should be called differently. I can suggest you copying the respective snippets from repository page in Artifactory:
Okay, i have figured out a fix for this.
Go to the Artifactory admin page at port 8081(default) navigate to:
Admin -> Security -> General
Ensure that the checkbox next to
Allow Anonymous Access
is UNCHECKED.
Next, make sure you have the appropriate login information in the settings.xml to access your repository for read and write access.
Doing that fixed this issue for me.
CHEERS.
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://192.168.1.16:8081/artifactory/libs-snapshot-local as admin
Downloading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/maven-metadata.xml
[DEBUG] Could not find metadata sg.com.pinder:pinder:0.0.1-SNAPSHOT/maven-metadata.xml in ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local)
[DEBUG] Writing resolution tracking file /home/Eric_Vader/.m2/repository/sg/com/pinder/pinder/0.0.1-SNAPSHOT/resolver-status.properties
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20140101.065126-1.jar
Uploaded: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20140101.065126-1.jar (2 KB at 11.1 KB/sec)
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20140101.065126-1.pom
Uploaded: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/pinder-0.0.1-20140101.065126-1.pom (2 KB at 18.4 KB/sec)
Downloading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/maven-metadata.xml
[DEBUG] Could not find metadata sg.com.pinder:pinder/maven-metadata.xml in ServerA2 (http://192.168.1.16:8081/artifactory/libs-snapshot-local)
[DEBUG] Writing resolution tracking file /home/Eric_Vader/.m2/repository/sg/com/pinder/pinder/resolver-status.properties
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/maven-metadata.xml
Uploaded: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/0.0.1-SNAPSHOT/maven-metadata.xml (769 B at 8.3 KB/sec)
Uploading: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/maven-metadata.xml
Uploaded: http://192.168.1.16:8081/artifactory/libs-snapshot-local/sg/com/pinder/pinder/maven-metadata.xml (279 B at 3.0 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.890s
[INFO] Finished at: Wed Jan 01 14:51:27 SGT 2014
[INFO] Final Memory: 11M/216M
[INFO] ------------------------------------------------------------------------
I had a similar error but was caused by the maven-source-plugin. The fix was to remove the "executions" from the child pom. Looks like some issue with jar and jar-no-fork running twice. I worked around it as follows:
Left parent pom with
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
and changed child pom from:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
to:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
in web UI, go to http://ip:8081/artifactory/webapp/#/profile .
enter the password to unlock.
Copy the Encrypted Password.
in settings.xml in <password> set the encrypted password without " .
my problem solved with this way.

Maven simple-weather tutorial

I am following the simple-weather tutorial in Maven by Example. When I execute the program, I get below exception. Does this need any specific classpath setting?
POM
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.maven.weather</groupId>
<artifactId>simple-weather</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>simple-weather</name>
<url>http://maven.apache.org</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<organization>
<name>Sonatype</name>
<url>http://www.sonatype.com</url>
</organization>
<developers>
<developer>
<id>jason</id>
<name>Jason Van Zyl</name>
<email>jason#maven.org</email>
<url>http://www.sonatype.com</url>
<organization>Sonatype</organization>
<organizationUrl>http://www.sonatype.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
<timezone>-6</timezone>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
Main.java
package com.example.maven.weather;
import java.io.InputStream;
import org.apache.log4j.PropertyConfigurator;
public class Main {
public static void main(String[] args) throws Exception {
// Configure Log4J
PropertyConfigurator.configure(Main.class.getClassLoader()
.getResource("log4j.properties"));
// Read the Zip Code from the Command-line (if none supplied, use 60202)
String zipcode = "60202";
try {
zipcode = args[0];
} catch( Exception e ) {}
// Start the program
new Main(zipcode).start();
}
private String zip;
public Main(String zip) {
this.zip = zip;
}
public void start() throws Exception {
// Retrieve Data
InputStream dataIn = new YahooRetriever().retrieve( zip );
// Parse Data
Weather weather = new YahooParser().parse( dataIn );
// Format (Print) Data
System.out.print( new WeatherFormatter().format( weather ) );
}
}
Run:
mvn exec:java -Dexec.mainClass=com.exa
mple.maven.weather.Main
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building simple-weather 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) # simple-weather >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) # simple-weather <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # simple-weather ---
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurato
r.java:433)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.
java:336)
at com.example.maven.weather.Main.main(Main.java:12)
... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.902s
[INFO] Finished at: Thu May 30 14:23:06 IST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (d
efault-cli) on project simple-weather: An exception occured while executing the
Java class. null: InvocationTargetException: NullPointerException -> [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/MojoExecutionE
xception
It seems like your application can't find log4j.properties
Do you use standard maven project structure? Where is log4j.properties located?
'resources' folder should be in main folder (src/main/resources) instead of src/resources .

Resources