error in deploying jar to remote repository in maven - maven-2

i am trying to deploy a jar file from my local machine to a remote machine which has an artifactory. I tried the following command :
mvn deploy:deploy-file -DgroupId=<some-id>
-DartifactId=<some-artifact>
-Dversion=<version>
-Dpackaging=jar
-Dfile=<path to the file in my local system>
-Durl=http://<ip of remote machine>:<port>/artifactory/repo/
-DrepositoryId=<artifactory -id in remote machine>
but on executing it gives error that:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'deploy'.
[INFO] -----------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [deploy:deploy-file] (aggregator-style)
[INFO] -----------------------------------------------------------------------
[INFO] -----------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] -----------------------------------------------------------------------
[INFO] One or more required plugin parameters are invalid/missing for 'deploy:
ploy-file'
[0] Inside the definition for plugin 'maven-deploy-plugin' specify the following
:
<configuration>
...
<url>VALUE</url>
</configuration>
-OR-
on the command line, specify: '-Durl=VALUE'
As i am specifying the value for Durl in my command why am i still getting this error?
How to resolve this?
The maven version is 2.2.1
Thanks.

Answered in comments:
Not sure about the Maven error itself, but I did notice that the
deployment URL points to Artifactory's "/repo" repository (which is a
global virtual aggregator of all the repositories in the instance);
since it's a virtual repository, one cannot deploy to it; you should
point the URL to one of Artifactory's local repositories
(libs-release-local, etc.). – noamt Jan 20 '12 at 8:44
i changed it to local repo name but still same error – pranay Jan 20
'12 at 13:02
yes i got it wokring now..actually was putting the wrong url ..thanks
a lot – pranay Jan 25 '12 at 6:33

Related

Not able to execute scripts from Jenkins although working fine locally & via command line

I am Not able to run scripts from Jenkins. How ever working fine from Command line & Local. I am within office network. Getting Below Error. I don't understand why Jenkins is trying to download Maven plugin? I am new to Jenkins. Any suggestion will be appretiated.
[INFO] ------------------------< Test:Junit-Demo >-------------------------
[INFO] Building Junit-Demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.695 s
[INFO] Finished at: 2018-04-11T14:29:52-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.68.215] failed: Connection timed out: connect -> [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/PluginResolutionException
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding="UTF-8"
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Maven, triggered by Jenkins, downloads the maven-clean-plugin as part of its normal execution. This happened on your location machine in the first run and was then cached in ~/.m2/.
Your Jenkins build agent, however, cannot connect to the server from which maven downloads artifacts:
Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.68.215] failed: Connection timed out: connect
Make sure that there is no firewall involved blocking these connections or configure Jenkins to use a local artifact repository (like Nexus or Artifactory).
Missing some info to fully know what's wrong.
To use maven in Jenkins you have to install the jenkins maven plugin and call the binary in your Jenkins file.
Did you have to do any maven configuration for your local set up?
ie inside ~/.m2 is usually where you would set up your account for nexus credentials inside settings.xml.
You would have to do this same config on your jenkins machine, either in the Jenkins user account's ~/.m2 or inside the maven plugin folder.

Error While Test The Project On Maven

i am using maven i don't have more knowledge about maven when i am install my project then it will successfully build but when i am test my project with maven it will give me an error like
Unable to copy an artifact to the working directory
i gave all permission to my project directory detail error as below so how can i resolve my
problem and how to run my project
so please help me
E
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 24 seconds
[INFO] Finished at: Thu Jan 27 17:44:59 IST 2011
[INFO] Final Memory: 35M/84M
[INFO] ------------------------------------------------------------------------
[INFO] Unable to copy an artifact to
the working directory Embedded error:
/home/nayan/workspace/ONiT/mediaPlayer/target/classes
(Is a directory) [INFO]
This looks like some of the previous tests are still running at this point and blocking maven from writing in the target directory.
As this seems to be an reactor build, do the modules themself build correctly ? I.e. can you run mvn test in each module directory seperately ?

Nexus repository contains artifact but only makes POM available

I have a Nexus instance with Maven 2 repositories hosted on a non-Internet-connected corporate development domain. I need to use the maven-jaxb-schemagen plugin from Sun, however, it was only available in Maven 1 format (along with many other Maven 1 dependencies, so this is not a one-off edge case).
I made a new Maven 1 hosted repository in Nexus (maven1), then made a Maven1-to-Maven2 virtual repository as well (maven1as2). Because some of the needed artifacts are snapshots, the policy for maven1 (and by extension maven1as2) is Snapshot.
I imported all of the Maven 1 artifacts through the filesystem to this repository's overridden local storage location.
I then added maven1as2 to my Public Repositories group. Some of the reference I have found says that Nexus will not allow you to browse or search a Maven1 repository. I have had mixed results. If I select Public Repositories or maven1as2 in Nexus, I can go to Browse Storage and drill down to com/sun/tools/jxc/maven2/maven-jaxb-schemagen-plugin/1.3-SNAPSHOT/ and view the maven-jaxb-schemagen-plugin-1.3-SNAPSHOT.pom file and its checksum. However, I cannot view the JAR artifact that should be there and is on the filesystem.
When I try to use Maven to build, I get the following:
$ mvn clean compile
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] MyProject
[INFO] MyModule1
[INFO] MyModule2
...
[INFO] ---------------------------------------------------------------------------
[INFO] Building MyProject
[INFO] task-segment: [clean, compile]
[INFO] ---------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] [cobertura:clean {execution: default}]
[INFO] No goals needed for project - skipping
[INFO] ---------------------------------------------------------------------------
[INFO] Building MyModule1
[INFO] task-segment: [clean, compile]
[INFO] ---------------------------------------------------------------------------
Downloading: http://my.nexus.server:8081/nexus/content/groups/public/com/sun/tools/jxc/maven2/maven-jaxb-schemagen-plugin/1.3-SNAPSHOT/maven-jaxb-schemagen-plugin-1.3-SNAPSHOT.pom
6K downloaded (maven-jaxb-schemagen-plugin-1.3-SNAPSHOT.pom)
[INFO] ---------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ---------------------------------------------------------------------------
[INFO] A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.sun.tools.jxc.maven2 -DartifactId=maven-jaxb-schemagen-plugin -Dversion=1.3-SNAPSHOT -Dpackaging=maven-plugin -Dfile=path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.sun.tools.jxc.maven2 -DartifactId=maven-jaxb-schemagen-plugin -Dversion=1.3-SNAPSHOT -Dpackaging=maven-plugin -Dfile=path/to/file -Durl=[url] -DrepositoryId=[id]
com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.3-SNAPSHOT
from the specified remote repositories:
nexus (http://my.nexus.server:8081/nexus/content/groups/public)
com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.3-SNAPSHOT
from the specified remote repositories:
nexus (http://my.nexus.server:8081/nexus/content/groups/public)
[INFO] ---------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ---------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Jul 06 15:05:08 EDT 2010
[INFO] Final Memory: 7M/17M
[INFO] ---------------------------------------------------------------------------
Sometimes it happens when working with m2eclipse. You chose a dependency and the default scope is pom and not jar. You didn't show your pom file. validate that all dependencies are jar scoped.
I learned that most of the time rebuilding metadata of the repositories helps to solve such problems.
I find it annoying how often this is necessary.
Select the repository
In the "Browse Storage" tab open the context menu of the root node (it sometimes is hidden behind the Firefox default context menu - pressing Esc helps in this case and brings the Nexus context menu into view)
Select rebuild metadata
Expire cache and reindex may help too for some cases.
Most of the time these steps didn't solve the problem at the first try but at last they solved it each time though.
I run Nexus as a WAR in Glassfish 2.1

Sonar default, meet "container state was: CONSTRUCTED"

Environment: hudson/sonar/maven2 in ubuntu locally with default parameters
And I got the log from hudson below, I can't figure out where is the problem.
[INFO] Sonar host: http://localhost:9000
[INFO] Sonar version: 2.0.1
[INFO] [sonar-core:internal {execution: default-internal}]
[INFO] Database dialect class org.sonar.api.database.dialect.Derby
[INFO] ------------- Analyzing Game of Life business logic module
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar
Embedded error: Can not analyze the project
Cannot stop. Current container state was: CONSTRUCTED
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar
And I notice it also has problem when run it command line without hudson
mvn sonar:sonar
I got this problem with .Net plugins for Sonar.
They needed all projects to be analyzed with JDK 6 (even non-.Net projects).
This error was raised when I tried to analyze projects with JDK 5.
Here is the URL of the .Net plugins : http://docs.codehaus.org/display/SONAR/.Net+plugin
The solution I got was to fork the compiler to use a JDK5 compiler on my projects which needed to be analyzed in JDK5 and not JDK6.
See on the .Net plugins page :
Maven and Sonar dotnet plugins need Java6 (at compile time and runtime)
What the sentence does not say is that all projects in your Sonar instance must use Java6.
A JIRA has been created : http://jira.codehaus.org/browse/SONARPLUGINS-1086 .
Got the hints from http://old.nabble.com/Another-%22Current-container-state-was%3A-CONSTRUCTED%22-problem-td28172925.html#a28194257
It seems the problem is inconsistency in maven plugins in my nexus repository, when I change to mirrors.ibiblio.org and clean the .m2 directory, everything goes fine.
BUT I don't know which plugins causes this problem and the log information is so wired, will be nice if some people points which plugin cause this problem and explain the reason for this error information

Maven FTP distribution problem

maven release:perform is failing to distribute via FTP.
The first thing I checked is that I can access the target server with the given credentials from the command line. I can with passive FTP but not with active FTP (known firewall restriction). What I can see from googling is that Maven uses passive FTP by default. Is that correct? If not, how can I cause it to use passive FTP?
Assuming Maven is using passive FTP, I would appreciate any other advice.
My configuration:
settings.xml:
<servers>
<server>
<id>repo-ftp</id>
<username>myUserName</username>
<password>myPassword</password>
</server>
</servers>
parent POM:
<distributionManagement>
<repository>
<id>repo-ftp</id>
<url>ftp://myServer</url>
</repository>
<snapshotRepository>
<id>repo-ftp</id>
<url>ftp://myServer</url>
</snapshotRepository>
</distributionManagement>
The error message:
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] FATAL ERROR
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] org.apache.maven.wagon.AbstractWagon.openConnection()V
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Trace
[INFO] java.lang.AbstractMethodError: org.apache.maven.wagon.AbstractWagon.openConnection()V
[INFO] at org.apache.maven.wagon.AbstractWagon.connect(AbstractWagon.java:143)
[INFO] at org.apache.maven.artifact.manager.DefaultWagonManager.putRemoteFile(DefaultWagonManager.java:235)
[INFO] at org.apache.maven.artifact.manager.DefaultWagonManager.putArtifact(DefaultWagonManager.java:153)
[INFO] at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:80)
[INFO] at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:162)
[INFO] at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
[INFO] at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
[INFO] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
[INFO] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
[INFO] at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:616)
[INFO] at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
[INFO] at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
[INFO] at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
[INFO] at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 16 seconds
[INFO] [INFO] Finished at: Wed Oct 21 17:43:11 UTC 2009
[INFO] [INFO] Final Memory: 25M/47M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Maven execution failed, exit code: '1'
UPDATE
I did have an extension node in the parent POM:
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-5</version>
</extension>
After reviewing the reply from cetnar I realized that I need beta-2 for my particular version of maven. When I switched the extension node to reference beta-2, maven properly complained about not having it available. So, I downloaded and installed using
mvn install:install-file -DgroupId=org.apache.maven.wagon -DartifactId=wagon-ftp -Dversion=1.0-beta-2 -Dpackaging=jar -Dfile=./wagon-ftp-1.0-beta-2-sources.jar
(which is a cut-and-paste from the error message I got, with my local copy of the .jar in the appropriate location).
Now, I get:
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] BUILD ERROR
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Error deploying artifact: Unsupported Protocol: 'ftp': Cannot find wagon which supports the requested protocol: ftp
[INFO]
[INFO] Component descriptor cannot be found in the component repository: org.apache.maven.wagon.Wagonftp.
Any advice for that problem?
UPDATE 2
I did not have wagon-ftp.jar or commons-net.jar in $M2_HOME/lib but do now. I get the same error.
$M2_HOME/lib:
commons-cli.jar -> ../../java/commons-cli.jar
commons-net.jar -> ../../java/commons-net.jar
doxia-sink-api.jar -> ../../java/doxia-sink-api.jar
jsch.jar -> ../../java/jsch.jar
jtidy.jar -> ../../java/jtidy.jar
maven2.jar -> ../../java/maven2.jar
plexus-container-default.jar -> ../../java/plexus-container-default.jar
plexus-interactivity-api.jar -> ../../java/plexus-interactivity-api.jar
plexus-utils.jar -> ../../java/plexus-utils.jar
wagon-file.jar -> ../../java/wagon-file.jar
wagon-ftp-1.0-beta-2.jar -> ../../java/wagon-ftp.jar
wagon-ftp.jar -> ../../java/wagon-ftp.jar
wagon-http-lightweight.jar -> ../../java/wagon-http-lightweight.jar
wagon-http-shared.jar -> ../../java/wagon-http-shared.jar
wagon-provider-api.jar -> ../../java/wagon-provider-api.jar
wagon-ssh-common.jar -> ../../java/wagon-ssh-common.jar
wagon-ssh-external.jar -> ../../java/wagon-ssh-external.jar
wagon-ssh.jar -> ../../java/wagon-ssh.jar
xml-apis.jar -> ../../java/xml-apis.jar
Note that all other dependencies were deployed using symbolic links to another directory so I continued the same pattern. Access rights are the same for all files. I tried providing both a wagon-ftp.jar and wagon-ftp-1.0-beta-2.jar symbolic link.
I'm not very excited about the prospect of upgrading to the latest version of maven (for fear of new problems), but is that my best option? Any other ideas?
SOLUTION
It worked! Kind of. Now I get an authentication error, but that's a different issue.
The a-ha moment was the mention of -sources and I realized I had downloaded wagon-ftp-1.0-beta-2-sources.jar but installed with -Dversion=1.0-beta-2 (no -sources)... so I copied the sources JAR to the binary jar file name :-).
Thank you all for your help with this!
The setup looks good. And yes, passive mode is the default (see WAGON-143). That said, according to the trace (java.lang.AbstractMethodError is thrown when something tries to call an abstract method), it's obvious that your wagon isn't compatible with your version of maven. Wagon madness...
It's surely not the best place but this is actually documented in the Guide to using Extenstions (pay a special attention to the "Note" at the bottom):
Extensions are used to enable Wagon
providers, used for the transport of
artifact between repositories, and
plug-ins which provide lifecycle
enhancements. Wagon providers
<project>
...
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
</build>
...
</project>
Note: Wagon 1.0-beta-3+ requires Maven 2.1.0 or above. For Maven 2.0.10
and earlier, use Wagon 1.0-beta-2.
EDIT: About the new error, the maven deploy plugin FAQ describes something very similar:
If you are using the deploy:deploy-file goal and encounter this error:
"Error deploying artifact: Unsupported Protocol: 'ftp': Cannot find wagon which supports the requested protocol: ftp"
Then you need to place the appropriate wagon provider in your %M2_HOME%/lib. In this case the provider needed is ftp, so we have to place the wagon-ftp jar in the lib directory of your Maven 2 installation.
If the error description is something like this:
"Error deploying artifact: Unsupported Protocol: 'ftp': Cannot find wagon which supports the requested protocol: ftp org/apache/commons/net/ftp/FTP"
Then you need to place the commons-net jar in %M2_HOME%/lib.
I don't get why one would have to do that but try to put wagon-ftp-1.0-beta-2.jar in %M2_HOME%/lib.
EDIT2: I've read the question again and it looks like you did install a "sources" jar which, of course, doesn't contain the required classes for the runtime. Before following the advice above, try to put wagon-ftp-1.0-beta-2.jar in your repository (and not wagon-ftp-1.0-beta-2-sources.jar).
Did you define wagon-ftp as a extension in your pom?
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-alpha-3</version>
</extension>
</extensions>
If yes I thing the problem is in wrong versions maven and wagon-ftp. Here is one article about this problem.
In maven-user-list I found that you need to use 1.0-beta-2 of the ftp wagon with 2.0.9. 1.0-beta-3 will work with 2.0.10 and Wagon 1.0-beta-5 release will only work as an extension in Maven 2.1.0-M1 and above.