Failed to deploy artifacts: Could not find artifact - maven

I want to deploy a library to my companies remote repository.
It's the first time I want to deploy the library project to the remote repository.
I get the following error message:
org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com/)
Maybe I understand something complete wrong, but the error message says, that in the remote repository doesn't exist the artifact that I try to deploy for the first time. So of course there is not such artifact. Why does maven tries to fetch the artifact when I try to upload the artifact?
My pom file:
<?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.0http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.http</groupId>
<artifactId>httpkit</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>httpkit</name>
<properties>
<platform.version> 4.1.1.4</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- Deploy to internal maven repository -->
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Internal Repository</name>
<url>http://jenkins.internal.com/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>16</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I call
mvn deploy
from command line
Any suggestion how to fix that problem?
EDIT: The failure log (running mvn deploy -X)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project httpkit: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com) -> [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 httpkit: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
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 find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
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 find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com)
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.ArtifactNotFoundException: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.repo (http://jenkins.internal.com/)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:947)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:941)
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
[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

Have you tried to add the server in your settings.xml file? The default settings xml is located in your ~/.m2/ directory. Should contain something like that:
<servers>
<server>
<id>my-internal-nexus-repo</id>
<username>yourUserName</username>
<password>yourPassword</password>
</server>
</servers>
Here is a link to the http://maven.apache.org/settings.html maven doc for adding servers.
One other thing which might be a shot in the dark. I've noticed you are trying to connect to what the url suggests might be a Jenkins instance. Jenkins is a Continious Integration server and seemed strange to me that you are finding your repositories there. I would expect a Nexus url or something.

A possible cause is that you simply misspelt the repository name, or used the wrong repository name entirely
So using the OP's example:
Failed to deploy artifacts: Could not find artifact com.http:httpkit:jar:0.0.1 in internal.
repo (http://jenkins.intrnal.com)
could actually mean
Failed to deploy artifacts: Could not find internal.repo (http://jenkins.intrnal.com)

We have faced this issue. After couple of hours, we figured it is disk space issue in internal repository.

I ran into a similar problem and solved by
Adding my nexus server as a nonProxyHost in settings.xml
Setting the 3rd party's Repository Policy to Release rather than
Snapshot.
See more details in my stackoverflow answer.
Note that I was doing a "mvn deploy:deploy-file" (which uploads a 3rd party artifact to the shared repository) whereas you are doing a "mvn deploy" (which uploads YOUR artifact from your built project to the shared repository), but the root cause maybe the same.

In my case my server url in snapshotRepository section of pom.xml was pointing to http, while my internal repository was hosted in https.

Regarding the error:
Failed to deploy artifacts: Could not transfer artifact
Solution:
A very simple way to fix this is just by changing/updating the version in the pom.xml file. Suppose 01.16.03 is already used then try using 01.16.04 instead. It should work.

Okay...I encountered the same issue some days ago.
And after fiddling around with all sort of permutations and combination, I finally arrived at the conclusion.
Those who says that the reactor automatically sorts and resolves all dependencies on its own are incorrect. It seems that the link below describes it all. Kindly look at the last point under "Reactor Sorting" section:
https://maven.apache.org/guides/mini/guide-multiple-modules.html#Reactor_Sorting
It suggests that the order in which the modules are defined are taken into consideration when no other rules applies.
I hope that helps other. :)

It is because your Maven not able to find settings file. If deleting .m2 not work, try below solution
Go to your JOB configuration
than to the Build section
Add build step :- Invoke top level maven target and fill Maven version and Goal
than click on Advance button and mention settings file path as mention in image

Today i encountered the same issue.My solution was to upgrade pom version.Sure,you can also modify the nexus settings so that the same version number can be uploaded repeatedly,but the second method I haven't practiced myself, you can try.

In my case, Blob Store is almost running out of space. I have forgotten to set up clean-up policies. Once the disk space is cleared this issue is solved.

Maven knows the URL of the repository to deploy to from the repository (or snapshotRepository) sub elements of the distributionManagement element in the POM:
<distributionManagement>
<repository>
<id>{some ID}</id>
<name>{some helpful name}</name>
<url>http://example.com:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
...
</snapshotRepository>
</distributionManagement>
But Maven will also need to know the user-name and password to use. That can't be in the (public, published) POM, but is instead in a server element in your Maven settings file (~/.m2/settings.xml):
<servers>
<server>
<id>{some ID}</id>
<username>{username}</username>
<password>{password}</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
...
</servers>
Because the settings file can contain credentials for multiple servers, it needs a means of associating your POM repository with the appropriate settings server. It uses the content of the id sub element to identify which server credentials to use with which repository.
Obviously, if you use the wrong id (completely wrong or having a typo) then Maven will not know which credentials to use. However, Maven does not output a warning or error message in this case. It tries (using no credentials?) to do the upload, which of course fails with 401 Unauthorized.
Therefore, if deployment fails with a mysterious 401 Unauthorized, one thing to check is that your repository and server id values are the same.

Related

Releasing to Maven Central

I was added as a developer to the Maven project and now I need to make a release.
I've added nexus-staging-maven-plugin to pom.xml file.
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
Also I've added distributionManagement to pom.xml
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
I've placed my credentials to ~/.m2/settings.xml
<settings>
<servers>
<server>
<id>ossrh</id>
<username>divanov-oss.sonatype.org-account</username>
<password>divanov-oss.sonatype.org-password</password>
</server>
</servers>
</settings>
I also tried to create and use "Access User Token" on oss.sonatype.org
as my credentials.
Now I'm executing to deploy release into maven central.
mvn clean deploy
which ends up in the error:
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.3:deploy
(injected-nexus-deploy) on project project: Failed to deploy artifacts:
Could not transfer artifact
project:jar:4.4.0-20141228.104011-1 from/to ossrh
(https://oss.sonatype.org/content/repositories/snapshots): Access denied to:
https://oss.sonatype.org/content/repositories/snapshots/project/project/4.4.0-SNAPSHOT/project-4.4.0-20141228.104011-1.jar,
ReasonPhrase: Forbidden. -> [Help 1]
or
[INFO] Performing remote staging...
[INFO]
[INFO] * Remote staging into staging profile ID "329a0bc2b7ce06"
[ERROR] Remote staging finished with a failure: 403 - Forbidden
[ERROR]
[ERROR] Possible causes of 403 Forbidden:
[ERROR] * you have no permissions to stage against profile with ID "329a0bc2b7ce06"? Get to Nexus admin...
How can I check my access rights within Maven project I'm trying to release?
Your credentials are likely fine, you'd be getting a 401 error if they weren't. You're getting 403 (forbidden). This means the credentials were accepted, but you don't have permission to publish the artifacts. The most common cause of this is that you are using a different Maven group ID than the one assigned to you. File an issue at https://issues.sonatype.org in the "Community Support - Open Source Project Repository Hosting" and we'll get this worked out.
The credentials that you need to use shouldn't be of Sonatype JIRA, but of oss.sonatype.org. You need to register there separately.
[Update] The question was changed, so this answer is not relevant anymore. I'll keep it, since it's a common mistake.

Maven install error: Dependency could not be resolved

I am using Maven 3.1.1. When I run mvn install I get the following error:
D:\spring source>mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpringDependencies 1.0
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.648s
[INFO] Finished at: Mon Dec 16 15:01:47 IST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of it
s dependencies could not be resolved: Failed to read artifact descriptor for org
.apache.maven.plugins:maven-dependency-plugin:jar:2.8: Could not transfer artifa
ct org.apache.maven.plugins:maven-dependency-plugin:pom:2.8 from/to central (htt
p://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.mave
n.apache.org -> [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/PluginResoluti
onException
My pom.xml is:
<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>spring-source-download</groupId>
<artifactId>SpringDependencies</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>download-dependencies</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory> ${project.build.directory}/dependencies </outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Could not transfer artifact
org.apache.maven.plugins:maven-dependency-plugin:pom:2.8 from/to
central (http://repo.maven.apache.org/maven2): repo.maven.apache.org:
Unknown host repo.maven.apache.org
It seems like your maven cannot access remote central repository.
Check if you have an established internet connection.
Check if you can access default maven repo http://repo.maven.apache.org/maven2 in your browser.
Check if you have correct configuration in <repositories> and <proxies> in your your settings.xml
This error comes due to the proxy settings.
First of all, check whether you are able to connect to maven repository(http://repo1.maven.org/maven2) from browser.
Then update Maven proxy setting create/update a settings.xml in .m2 directory with following details:
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>{your proxy server host name}</host>
<port>{your proxy server port}</port>
<nonProxyHosts>maven</nonProxyHosts>
</proxy>
</proxies>
Solution given by Maven community: http://maven.apache.org/guides/mini/guide-proxies.html
This is caused by corrupted maven or plugins folder. To resolve this:
Delete \.m2\repository\org\apache\maven
mvn dependency:resolve -X
Where is my Settings.xml?
Windows users
It's in your C:/Users/<Username>/.m2/settings.xml
Also, this is for specific user.
Global one can be present at :
<Maven-Installation-Directory>/conf/settings.xml
But changing the User one might solve the issue if you can't find the global one.
Also, equally important, go to Preferences in Eclipse/STS:
Goto Maven -> User Settings
and verify if both global and user settings.xml files are mentioned in the properties, if not mention them by browsing.
1. Proxy Issue
Check Windows Proxy Setting.
If there is any proxy which your computer is using then you need to add proxy settings in your settings.xml file too.
Just add this chunk of code in your settings.xml
<proxies>
<proxy>
<id>proxy-id</id>
<active>true</active>
<protocol>http</protocol>
<host>ca-something.net</host>
<port>80</port>
<nonProxyHosts>localhost|10.140.240.90.*</nonProxyHosts>
</proxy>
</proxies>
2. Protocol Issue
Visit http://repo.maven.apache.org/: If it says Https required.
Then, you need to add this chunk of code to your settings.xml inside <mirrors>
<mirror>
<id>central-secure</id>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
Now it should be good to go.
3. None of the above works
Try disconnecting any company private VPN and try mvn clean build.
Disconnect from VPN and then run the command.
Probably a bit late to the party, but there appears to be an unknown host exception thrown out of maven even if the resource/dependency is unavailable at that address.
Which could mean that the problem may actually be that you have a transitive dependency that is pointing you to the wrong version of a jar (or one that is transitively included multiple times - one of which may be an unresolvable version). (I see it's looking for version 2.8 of the plugin but you specified version 3.1.1, so it's likely you have another dependency transitively including the wrong version).
You can exclude transitive inclusion of a dependency using the exclusions tag.
This issue was resolved for us by providing the correct proxy host in .m2/settings.xml.
Example:
<proxies>
<proxy>
<id>XXXXXXXXXX</id>
<active>true</active>
<protocol>http</protocol>
<host>na-xxxx-proxy.na.xxxxxxxxxx.net</host>
<port>80</port>
<nonProxyHosts>localhost|10.140.240.90.*</nonProxyHosts>
</proxy>
</proxies>

Could not connect to remote://localhost:9999. The connection timed out Jboss 7.1.1 Final

I am deploying builds to local and remote Jboss AS 7.1.1 Final at port 9999. Maven uses jboss plugin 'jboss-as-maven-plugin:7.1.1.Final' to manage builds to servers. I have confirmed that server is up and running and port is accessible at 9999. But "many times" build fails with following error for both local and remote Jboss. Jboss ic configured in Standalone mode single node cluster.
Stranglely build doesn't fail every time but most of the time. Not sure if we need to upgrade Maven plugin to higher version.
[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
org.jboss.as.plugins:jboss-as-maven-plugin:7.1.1.Final:undeploy
(default-cli) on project Test: Error executing UNDEPLOY [DEBUG]
Closing connection to remote [ERROR] Failed to execute goal
org.jboss.as.plugins:jboss-as-maven-plugin:7.1.1.Final:undeploy
(default-cli) on project Test: Error executing UNDEPLOY:
java.net.ConnectException: JBAS012144: Could not connect to
remote://localhost:9999. The connection timed out -> [Help 1]
UPDATE
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.1.1.Final</version>
<configuration>
<filename>${project.build.finalName}.jar</filename>
<username>${userName}</username>
<password>${password}</password>
</configuration>
</plugin>
I am now using latest version of Maven plug-in but it seems that connection timeout error is more frequent now. I am starting to think if Jboss behaves differently when trying to make too many remote deployment with different sub projects of the application. I am having 21 sub projects being deployed from a master POM. Sample configuration is as follows
<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.master</groupId>
<artifactId>master</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>Master</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
<module>module4</module>
<module>module5</module>
<module>module6</module>
<module>module7</module>
<module>module8</module>
<module>module9</module>
<module>module10</module>
<module>module11</module>
<module>module12</module>
<module>module13</module>
</modules>
First, check plugin configuration.
For example:
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.9.Final</version>
<inherited>true</inherited>
<configuration>
<hostname>${jboss.hostname}</hostname>
<port>${jboss.port}</port>
<username>${jboss.user}</username>
<password>${jboss.pass}</password>
<timeout>30000</timeout>
</configuration>
</plugin>
If hostname, port number(default 9999), username and password are ok, you can try increasing "timeout" (default is 5000ms, you can try with 30000ms).
It worked for me.
4 Possible Solutions to Question
Remove your Local Cache settings which will be your local m2 repo Or Point to new m2 repo from your maven settings.xml file.
Try to connect to your local nexus/archiva (if any other) using relevant/appropriate credentials.It is only your Maven Plugin causing this problem.
Try to use the latest JBoss Deploy Plugin available in this link.
Alternatively check your windows/Linux firewall settings have been enabled or it.

Cannot create archetype from existing maven project

I'm trying to create an archetype from an existing multi module maven project. For this, I change the directory to the root directory (where the root pom.xml is in) and issue a "mvn archetype:create-from-project". The build doesn't finish and I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:create-from-project (default-cli) on project siaci-d: charsetName -> [Help 1]
Running again with the -e and -X flags I can see the following stack trace:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:create-from-project (default-cli) on project siaci-d: charsetName
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoFailureException: charsetName
at org.apache.maven.archetype.mojos.CreateArchetypeFromProjectMojo.execute(CreateArchetypeFromProjectMojo.java:285)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
I checked the maven-archetype-plugin documentation and didn't find any reference to a charsetName attribute. So, I'm a bit lost about how to fix this. I'm using maven 3.0.4 with java 1.6.0_25 on a Ubuntu box. Any advice?
Any idea of what is going wrong here?
You posted this question some time ago, however this answer may help others.
I had the same problem in a project. This error happens when you have a file in your project that contains characters in a different encondig. A solution to this problem is replacing this characters — if it's not many, generate the archetype, revert the characters to the original and at last, change to the right enconding at the archetype metadata file.
Another option is to change the default enconding UTF-8 in the archetype generation, like this:
mvn archetype:create-from-project -Darchetype.properties=../archetype.properties
For more information, follow this guides:
http://maven.apache.org/archetype/maven-archetype-plugin/create-from-project-mojo.html#defaultEncoding
http://maven.apache.org/archetype/maven-archetype-plugin/examples/create-with-property-file.html
I was dealing with the same error then I found out what was messing up the archetype creation...
First, I chose the encoding ISO-8859-1 by inserting the properties below on pom.xml:
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
<project.resources.sourceEncoding>${project.build.sourceEncoding}</project.resources.sourceEncoding>
</properties>
Afterwards, I inserted the archetype-plugin with all configurations below at the build section of pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.2</version>
<configuration>
<defaultEncoding>${project.build.sourceEncoding}</defaultEncoding>
<encoding>${project.build.sourceEncoding}</encoding>
<archetypeArtifactId>archetype-wsjpa</archetypeArtifactId>
<archetypeGroupId>br.com.example</archetypeGroupId>
<archetypeVersion>1.0</archetypeVersion>
<archetypeFilteredExtentions>java,xml</archetypeFilteredExtentions>
</configuration>
</plugin>
By doing so, you should provide all archetype generation configuration in your own pom.xml instead of writing a property file (archetype.properties) to declare this configuration.
And finally, I ran maven with mvn clean install then mvn archetype:create-from-project -e -X
Even so, you still may notice some encoding errors like the one reported in this post, even if you have updated your pom.xml as shown above... If you're still having the same error after setting the correct encoding for your project, try to figure out which project file still contains invalid characters.
To find the troublemaker file you should observe the debug lines that Maven shows on the console like this one: "[DEBUG] InputFileName:src\main\resources\META-INF\persistence.xml" and check which project files has been written to the folder ${basedir}\target\generated-sources\archetype\src\main\resources\archetype-resources.
When encoding errors occurs during archetype creation, the aforementioned folder doesn't match the original project contents and it happens because Maven couldn't copy some resources due to invalid or incompatible characters which is not contained in the property specified charset.

DependencyResolutionException when upgrading from Maven 2.2.1 to Maven 3.0.4

I'm trying to upgrade my project from Maven 2.2.1 to Maven 3.0.4 but am running into problems with a dependency resolution. I spent a full day trying to research this by looking through Maven documentation and similar posts, but I'm still stuck. This is my first question on stackoverflow, so hopefully I've followed etiquette here well enough. Thanks for your help!
My project structure is as follows:
pom.xml (acme-parent)
child-alpha
+-----> pom.xml
In addition, I have the following files in my own repository:
http://maven.my-own-repo.com/acme/child-dep-jdk15/maven-metadata-local.xml
http://maven.my-own-repo.com/acme/child-dep-jdk15/1.0/child-dep-jdk15-1.0.jar
http://maven.my-own-repo.com/acme/child-dep-jdk15/1.0/child-dep-jdk15-1.0.pom
child-alpha/pom.xml in turn has a profile dependency on my own acme:child-dep-jdk15, which has been separately built into a jar file and has its own .pom file specifying a parent that is the same acme-parent parent as child-alpha.
Here are excerpts from the relevant files:
acme-parent pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>acme</groupId>
<artifactId>acme-parent</artifactId>
<name>Acme Parent Project</name>
<version>1</version>
<packaging>pom</packaging>
<properties>...</properties>
<modules>
<module>child-alpha</module>
</modules>
<repositories>
<repository>
<id>acme-repo</id>
<url>http://maven.my-own-repo.com</url>
</repository>
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>...</pluginRepositories>
<build>
<plugins>...</plugins>
</build>
<dependencies>...</dependencies>
</project>
child-alpha pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>acme</groupId>
<artifactId>acme-parent</artifactId>
<version>1</version>
</parent>
<artifactId>child-alpha</artifactId>
<name>Child Alpha Project</name>
<version>1.0</version>
<packaging>jar</packaging>
<scm>...</scm>
<properties>...</properties>
<build>
<resources>...</resources>
<plugins>...</plugins>
</build>
<profiles>
<profile>
<id>jdk15</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.5</jdk>
</activation>
<dependencies>
<dependency>
<groupId>acme</groupId>
<artifactId>child-dep-jdk15</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>...</dependencies>
</project>
child-dep-jdk15-1.0.pom:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>acme</groupId>
<artifactId>acme-parent</artifactId>
<version>1</version>
</parent>
<groupId>acme</groupId>
<artifactId>child-dep-jdk15</artifactId>
<name>Acme Child Dependency</name>
<version>1.0</version>
<packaging>jar</packaging>
<build>...</build>
<dependencies>...</dependencies>
</project>
When I tried to build child-alpha (while in the child-alpha directory), I ran the following command:
mvn -U -e clean install
And I got the following log messages and stack trace (extraneous messages removed):
Downloading: http://maven2.my-own-repo.com/acme/acme-parent/1/acme-parent-1.pom
Downloading: http://repo1.maven.org/maven2/acme/acme-parent/1/acme-parent-1.pom
[...]
[ERROR] Failed to execute goal on project child-alpha: Could not resolve dependencies for project acme:child-alpha:jar:1.0: [...]
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project acme:child-alpha:jar:1.0: [...]
Caused by: org.sonatype.aether.collection.DependencyCollectionException: Failed to collect dependencies for [...]
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:258)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:308)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:150)
... 23 more
Caused by: org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for acme:child-dep-jdk15:jar:1.0
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:331)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:186)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:412)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:240)
... 25 more
Caused by: org.apache.maven.model.resolution.UnresolvableModelException: Could not find artifact acme:acme-parent:pom:1 in acme-repo (http://maven.my-own-repo.com)
at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:126)
at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:813)
at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:664)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:310)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:232)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:322)
... 28 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact acme:acme-parent:pom:1 in acme-repo (http://maven.my-own-repo.com)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:122)
... 33 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact acme:acme-parent:pom:1 in acme-repo (http://maven.my-own-repo.com)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:947)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:941)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:669)
at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
While using Maven 2, I've never needed the acme-parent pom.xml at the following location:
http://maven2.my-own-repo.com/acme/acme-parent/1/acme-parent-1.pom
The reason we don't have the parent pom.xml on our own repo is is that we have a script used when creating version control branches that changes some values in acme-parent pom.xml depending on which branch we're on, so it would be complicated to put that pom.xml in the repo and keep it correctly updated for all the different branches we're trying to build concurrently with our continuous integration server.
In Maven 2, when doing builds of child-alpha, Maven would have no trouble finding acme-parent pom.xml one directory up, i.e. with a relative path of ../pom.xml, so it would never try going to my repositories to find it. Having the parent pom.xml in my local checkout only and not having it in the repo worked fine in Maven 2.
However, when I tried building child-alpha under Maven 3.0.4, the exception above occurred. At first, I thought I needed to explicitly set the relativePath within the tags at the top of child-alpha's pom.xml, but that didn't fix it -- and acme-parent's pom.xml is indeed already in the default relativePath of ../pom.xml, so there's no need to explicitly set it.
Then, I tried commenting out the child-dep-jdk15 dependency within the section of child-alpha's pom.xml. The child-alpha maven build completes successfully with this dependency commented out.
I don't understand why child-alpha won't build in Maven 3 when the child-dep-jdk15 dependency is in place. If Maven was able to correctly find the acme-parent pom.xml initially (per the block at the top), why is it now trying to download it from the repos when processing the child-dep-jdk15 dependency? Have I configured something incorrectly, and if so, how should I fix it?
One other thing: if I first run mvn -N install in the same directory as acme-parent's pom.xml, and then try building child-alpha, then the child-alpha build succeeds, even when keeping the dependency child-dep-jdk15 in the code. After I run that command, I'm able to verify acme-parent-1.pom is in my local .m2 directory. While this workaround may be okay for individual developers, it'd be a problem for our continuous integration server, which needs to be able to run concurrent builds for different branches.
I'd strongly prefer not to have to reconfigure my repository to host the acme-parent pom.xml due to the version control branching changes I've mentioned above.
In Maven 3 if you just had a failed download and have fixed it (e.g. by uploading the jar to a repository) it will cache the failure. To force a refresh add -U to the command line.
For other possible reasons of DependencyResolutionException see Maven Confluence.

Resources