I have multi module maven project.When I try to build site, e.g. execute maven site on parent project it fails to resolve dependency to one of modules.
But if I just compile (mvn clean compile on parent project) it or run tests (mvn clean test on parent project) there are no dependency problems.
What could cause such behaviour?
UPD
Maven version
Apache Maven 3.0.2 (r1056850; 2011-01-09 02:58:10+0200)
Java version: 1.6.0_26, vendor: Sun Microsystems Inc.
Java home: c:\Program Files\Java\jdk1.6.0_26\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
maven-site-plugin version
[DEBUG] Included: org.apache.maven.plugins:maven-site-plugin:jar:2.0.1
Error message
[ERROR] Failed to execute goal on project myproj-client: Could not resolve dependencies for project mycompany.myproj:myproj-client:jar:0.0.1-SNAPSHOT: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project myproj-client: Could not resolve dependencies for project mycompany.myproj:myproj-client:jar:0.0.1-SNAPSHOT: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:190)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:104)
at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:258)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:201)
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:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
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.project.DependencyResolutionException: Could not resolve dependencies for project mycompany.myproj:myproj-client:jar:0.0.1-SNAPSHOT: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:156)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:165)
... 22 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:526)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifacts(DefaultRepositorySystem.java:304)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:334)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:150)
... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:517)
... 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/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :myproj-client
I have the same problem. I didn't dig into Maven's source code too much. But here is my observation.
Supposed that you never mvn install myproj-common in your local repository, neither deployed it onto any remote repositories. When you run mvn clean site on the parent project, things happen like this:
maven determines the order of myproj-common is before
myproj-client according to their dependency relationship
mvn clean site is run on myproj-common. All previous result in myproj-common/target are deleted and myproj-common/target/site is
generated. (Note that after this step, neither compiled classes nor packaged jar exists in myproj-common/target)
mvn clean site is run on myproj-client. Maven first checks the
dependency of this project, and tries to find myproj-common's
artifact (classes or jar) in these places: (a) myproj-common/target (b) local repository (3) remote repositories.
mvn site fails on myproj-client, since it cannot find the artifact of myproj-common
This explains why mvn clean compile site and mvn clean package site works. They both would have prepared myproj-common artifacts in its target directory before mvn site runs on myproj-client.
And mvn install followed by mvn site works also.
A special exception is that if you put something like emma-maven-plugin in reporting, it will automatically compile and instrument classes. In this case, mvn clean site always works.
I am not sure why Maven tries to find myproj-common's jar in step 3, it seems to have nothing to do with mvn site. The exception happens quite early in maven core, before getting into maven-site-plugin. It looks not like a problem of maven-site-plugin but a common behavior of all maven lifecycles (except clean I believe).
i was facing the same but for struts and paypal_base dependecies, i fixed by doing following.
i checked, and found that jar files didn't exists in appropriate folder in maven repository(.m2/reposotory....).
I have installed that jar files via following mvn command
mvn install:install-file -Dfile=C:\Dependencies\paypal_base.jar \
-DgroupId=paypal -DartifactId=paypal_base -Dversion=0.1 \
-Dpackaging=jar
and
mvn install:install-file -Dfile=C:\Dependencies\struts.jar \
-DgroupId=struts -DartifactId=struts -Dversion=0.1 \
-Dpackaging=jar
(-DFile is the location of jar file in you system)
Rebuild the project by Maven.
My Project was successful build.
you must check the jar, and use above instruction is jar not exist.
may be this will helpful.
This might be an issue with the site plugin not having access to the reactor, and thus not seeing that the project artifact is available in your project sources. (This is merely a hypothesis, perhaps supported by MSITE-302.)
Try running first mvn install, which installs your artifacts in the local repository, and then running mvn site.
For more information on the reactor, try:
http://maven.apache.org/guides/mini/guide-multiple-modules.html
What is the "reactor" in Maven?
Heh, for some reason, after I made some changes to module and parent pom files, problem vanished. I don't know exactly what was done, but currently mvn site on parent project is working normally. Unfortunately I have no time to investigate what is the roots of the problem. But it seems that changing site version to 3.0 put me on the right way. Also I could execute site (before it was fixed) in the following way mvn compile site, in this case it could find dependency.
It looks like maven is looking for myproj-common:jar:0.0.1-SNAPSHOT in the repository.
The reason for failure could be:
maven is not able to access the snapshot artifacts in the repository.
To enable snapshot artifacts:
please check you pom.xml for snapshots tag under the repository section.
<repository>
<name>xyz</name>
<id>repoid</id>
<url>http://x.y.z</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
Related
Did a fresh install of Eclipse 4.9, and can no longer build my Java project within Eclipse (still builds fine from command line).
The console output does not give me much to go on... just complains about the plugin...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myprojectcommon: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myprojectcommon: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:862)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
I'm running Eclipse 4.9 on OSX High Sierra, w/ JDK 1.8_191. Maven version is 3.5.4, and Eclipse is configured to use this external Maven. JAVA_HOME and M2_HOME are set (though I don't think they are needed for OSX). I have tried building my existing workspace as well as importing the project into a fresh one.
Kind of at wit's end here... any help would be greatly appreciated.
EDIT 1: Then using a Terminal inside Eclipse, it does not recognize the mvn command, nor does it see any system variables like M2_HOME. Eclipse itself is configured to use my external maven installation, but I have also tried using the embedded. In both cases, Eclipse Terminal does not recognize mvn.
Try to locate and delete .m2/repository local repository. It should solve the problem !
if you are using Java 8, in your pom.xml, try adding this:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Or configure in plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>your maven compiler plugin version</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
Fix: Eclipse needs to be launched from command line in order for PATH and other Env Vars to be picked up
Steps:
Created a new script called eclipseLauncher and made it executable (chmod 755)
#!/bin/bash
/Applications/eclipse/jee-2018-09/Eclipse.app/Contents/MacOS/eclipse &
Turned script into an app:
a. Create an AppleScript (save as type .app) that points to the launcher script…
do shell script "open /Applications/eclipse/scripts/eclipseLauncher"
b. This app can then be moved to the dock and executed from there
NOTE: The app executes a script rather than directly issuing the commands. When I simply ran the command from the app, I could not get the terminal window to close after Eclipse was launched. Only by invoking the script could I get it to work like I wanted.
Usually, I create maven jar project with archetype maven-archetype-quickstart, it works well.
But I want to create Maven project with no sample App.java class, thus I tried maven-archetype-simple archetype, and get error.
Maven command:
mvn archetype:generate -DgroupId=eric -DartifactId=hello -Dversion=0.1 -DarchetypeArtifactId=maven-archetype-simple -DinteractiveMode=false -X -DarchetypeCatalog=local
Error tip:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-archetype-plugin:2.4:generate
(default-cli) on project standalone-pom: The defined artifact is not
an archetype -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal
org.apache.maven.plugins:maven-archetype-plugin:2.4:generate
(default-cli) on project standalone-pom: The defined artifact is not
an archetype at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:116)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at
org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at
org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497) at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: The defined
artifact is not an archetype at
org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:205)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more Caused by:
org.apache.maven.archetype.exception.ArchetypeGenerationConfigurationFailure:
The defined artifact is not an archetype at
org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationConfigurator.configureArchetype(DefaultArchetypeGenerationConfigurator.java:150)
at
org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:189)
... 22 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/MojoFailureException
The questions are:
Is maven-archetype-simple a valid archetype?
In the official doc of maven, it says maven-archetype-simple is a archetype, refer: https://maven.apache.org/guides/introduction/introduction-to-archetypes.html , but it won't work in my test, so get confused.
How to create Maven project without the generated code App.java?
The artifact maven-archetype-simple does exist on Maven Central, but it isn't a valid archetype since it doesn't containt the right metadata files. A valid archetype must have in its JAR file:
either a META-INF/maven/archetype-metadata.xml (this is the new format);
or a META-INF/maven/archetype.xml or even a META-INF/archetype.xml (this is the old format).
And that specific artifact, as it is present on Central, doesn't have those files. As such, it isn't considered a valid archetype for the plugin. Those files store the required parameters for the archetype, their possible default values, the files that it should use, etc. so they really are required.
I'm not sure there exists an archetype that would generate just a lone pom.xml with the given Maven coordinates. This is effectively what using the maven-archetype-quickstart, without generating the App.java and AppTest.java would do. Keep in mind that an archetype is really intended at creating a project from a pre-defined template, like a sample Java EE application, or a sample Maven project; all of those would require more set-up than just writing a POM file.
If you really, really, do not want those files, you can either
Create your own archetype
Create a new Maven project, for example my-simple-archetype, with the following directory structure:
pom.xml
src
\---main
\---resources
+---archetype-resources
| pom.xml
|
\---META-INF
\---maven
archetype-metadata.xml
Content of pom.xml at the root:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eric</groupId>
<artifactId>my-simple-archetype</artifactId>
<version>0.1</version>
<packaging>maven-archetype</packaging>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>2.4</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Content of the src/main/resources/archetype-resources/pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</project>
And finally, content of the src/main/resources/META-INF/maven/archetype-metadata.xml:
<archetype>
<id>my-simple-archetype</id>
</archetype>
Now you can build this project and install it:
cd my-simple-archetype
mvn clean install
This will update your local catalog so that this new archetype is available. You can finally use it! In a new directory, do
mvn archetype:generate -DgroupId=eric -DartifactId=hello -Dversion=0.1 -DarchetypeArtifactId=my-simple-archetype -DarchetypeGroupId=eric -DinteractiveMode=false
And you will have as result your wanted project... which consists of the lone pom.xml. So, of course, you can now customize this archetype of yours.
Remove the files
Or you decide that it is not worth the effort, and it is a lot simpler to remove the files after their creation:
mvn archetype:generate -DgroupId=eric -DartifactId=hello -Dversion=0.1 -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
rmdir /S /Q hello\src
Or rm -rf hello/src if you're on a Linux machine.
About maven-archetype-simple, even if it would be valid (which isn't the case), it's a little outdated (2006). I suggest you use something more up to date so that plugins and java versions aren't too old.
java8-quickstart-archetype would fit the bill:
mvn archetype:generate -DgroupId=eric -DartifactId=hello \
-Dversion=0.1 -DarchetypeArtifactId=java8-quickstart-archetype \
-DarchetypeGroupId=pl.org.miki -DinteractiveMode=false
This archetype sources can be found here: github.com/mikolak-net/java8-quickstart-archetype.
It is a valid maven archetype, see https://mvnrepository.com/search?q=maven-archetype-simple
I'm trying to repackage log4j so I can use it with Android. In order to do so, I have to use openbeans library and replace each java.beans with com.googlecode.openbeans.
Obviously this is not sufficient, since before repacking the through maven log4j I've to include openbeans-1.0.jar in the project.
So I've found this method.
I've installed openbeans through the following command:
mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
I've checked that the correct execution of the command checking if the .jar exists in the following path (and it does):
~/.m2/repository/com/googlecode/openbeans/1.0/openbeans-1.0.jar
Then I edited the pom.xml file adding:
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
</dependency>
But if I try mvn package then this error is returned:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run (rmdir_tests_output) on project log4j: Execution rmdir_tests_output of goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.2 or one of its dependencies could not be resolved: Failure to find com.googlecode:openbeans:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
Like the install-file didn't worked.
I've tried also with this method, using the following code (obviously I copied the .jar in the project root dir):
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/openbeans-1.0.jar</systemPath>
</dependency>
And here the error returned is:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project log4j: Compilation failure
[ERROR] /home/luca/apache-log4j-1.2.17/src/main/java/org/apache/log4j/config/PropertyGetter.java:[31,21] error: package com.googlecode does not exist
What is wrong in what I'm doing?
Even if I still don't understand why, I found out that executing:
mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode.openbeans -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
And using in pom:
<dependency>
<groupId>com.googlecode.openbeans</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
</dependency>
The code is compiled without error. But as I said, still wondering why.
The I am attempting to use my custom Maven plugin in a completely new system. It appears to not resolving the parent POM used by the custom Maven plugin.
I have tried several things but I am at a loss.
Any insight would be greatly appreciated. Thank you.
Update
This is is very strange.... this error only occurs when I clean my local repository (simulating a clean system such as a new developer or integration system). If I run the 'mvn -U install' command immediately again (without changing the command at all) then it builds successfully!
This screams 'transitive dependency' but how do I find such an infraction?
Update
I am thinking that this is a bug in Maven. The reactor doesn't find the parent POM even though it is located in the same project! What do you all think?
Custom Plugin 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>
<parent>
<groupId>my.org</groupId>
<artifactId>parent-java-with-foundation</artifactId>
<version>11.1.1.8-SNAPSHOT</version>
<relativePath></relativePath>
</parent>
<groupId>my.org.maven</groupId>
<artifactId>maven-plugin</artifactId>
<version>11.1.1.8-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
</project>
Error Trace:
[ERROR] Plugin my.org.maven:maven-plugin:11.1.1.8-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for my.org.maven:maven-plugin:jar:11.1.1.8-SNAPSHOT: Could not find artifact my.org:parent-java-with-foundation:pom:11.1.1.8-SNAPSHOT -> [Help 1] org.apache.maven.plugin.PluginResolutionException: Plugin my.org.maven:maven-plugin:11.1.1.8-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for my.org.maven:maven-plugin:jar:11.1.1.8-SNAPSHOT
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:122)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:146)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:265)
at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:190)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecution(DefaultLifecycleExecutionPlanCalculator.java:157)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecutions(DefaultLifecycleExecutionPlanCalculator.java:144)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:121)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:134)
at org.apache.maven.lifecycle.internal.BuilderCommon.resolveBuildPlan(BuilderCommon.java:92)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
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:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
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:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for my.org.maven:maven-plugin:jar:11.1.1.8-SNAPSHOT
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:370)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:217)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:288)
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:108)
... 25 more
Caused by: org.apache.maven.model.resolution.UnresolvableModelException: Could not find artifact my.org:parent-java-with-foundation:pom:11.1.1.8-SNAPSHOT
at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:126)
at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:817)
at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:669)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:307)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:361)
... 28 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact my.org:parent-java-with-foundation:pom:11.1.1.8-SNAPSHOT
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:459)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:262)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:239)
at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:122)
... 32 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact my.org:parent-java-with-foundation:pom:11.1.1.8-SNAPSHOT
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:449)
... 35 more
There can be several reasons for this. If the parent POM isn't part of the reactor (= the current build) and you deleted your local cache, then Maven has to find it somewhere.
If you have a company wide repository, make sure that this version is available from there. Make especially sure that you can download SNAPSHOT versions (some repos can disable that plus you can configure Maven never to download snapshots from certain repos).
If you don't have a company wide repository, then you need to run mvn install in the parent project, first. Maven doesn't try to find missing pieces anywhere on your hard disk.
I am new to maven and i have been creating simple web application with maven using hibernate, spring etc. i get following error occur when i run mvn eclipse:eclipse command.
[WARNING] Workspace defines a VM that does not contain a valid jre/lib/rt.jar: C:\Program Files\Java\jre7
[WARNING] could not read workspace project:c:\Users\Acer\workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\myproject
org.codehaus.plexus.util.xml.pull.XmlPullParserException: processing instruction can not have PITarget with reserveld xml name (position: START_D
OCUMENT seen \r\n<?xml ... #2:7)
at org.codehaus.plexus.util.xml.pull.MXParser.parsePI(MXParser.java:2453)
at org.codehaus.plexus.util.xml.pull.MXParser.parseProlog(MXParser.java:1447)
at org.codehaus.plexus.util.xml.pull.MXParser.nextImpl(MXParser.java:1395)
at org.codehaus.plexus.util.xml.pull.MXParser.next(MXParser.java:1093)
at org.codehaus.plexus.util.xml.Xpp3DomBuilder.build(Xpp3DomBuilder.java:187)
at org.codehaus.plexus.util.xml.Xpp3DomBuilder.build(Xpp3DomBuilder.java:83)
at org.codehaus.plexus.util.xml.Xpp3DomBuilder.build(Xpp3DomBuilder.java:48)
at org.apache.maven.plugin.eclipse.reader.ReadWorkspaceLocations.readArtefact(ReadWorkspaceLocations.java:341)
at org.apache.maven.plugin.eclipse.reader.ReadWorkspaceLocations.readWorkspace(ReadWorkspaceLocations.java:536)
at org.apache.maven.plugin.eclipse.reader.ReadWorkspaceLocations.init(ReadWorkspaceLocations.java:94)
at org.apache.maven.plugin.eclipse.EclipsePlugin.getWorkspaceConfiguration(EclipsePlugin.java:2063)
at org.apache.maven.plugin.eclipse.EclipsePlugin.fillDefaultClasspathContainers(EclipsePlugin.java:1580)
at org.apache.maven.plugin.eclipse.EclipsePlugin.setup(EclipsePlugin.java:978)
at org.apache.maven.plugin.ide.AbstractIdeSupportMojo.execute(AbstractIdeSupportMojo.java:500)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
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:601)
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)
[INFO] no substring wtp server match.
this is my pom.xml
could anybody tell me what i am doing wrong here. thanks in advance for any help
I was also getting the error:
[WARNING] Workspace defines a VM that does not contain a valid jre/lib/rt.jar: C:\Program Files\Java\jre6
but I don't get the
[WARNING] could not read workspace project:c:\Users\Acer\workspace.metadata.plugins\org.eclipse.core.resources.projects\myproject
(perhaps you were not setting your workspace path up correctly on the mvn command line by using the option -Declipse.workspace=...)
Anyway, the first warning was caused by me using a JDK in a non-standard place (JAVA_HOME=C:\tools\java\jdk1.6.0_31) and setting my Eclipse workspace up to use that as the default. The Maven Eclipse plugin does not seem to choose the default JDK correctly, The "mvn eclipse:eclipse" would not work until I removed the JDK in "C:\Program Files\Java\jre6" from the list of installed JDKs within Eclipse. I only have the correct one in the list now.
I looks like a java issue. Check your java_home directory. Is it pointing to C:\Program Files\Java\jre7 ? If so let maven also point to read same location by configure the toolchains.xml in your maven directory (e.g D:\maven-2.2.1\conf) to your java version
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.7</version> <!--This should be same as is configured via the toolchains plugin -->
<vendor>ibm</vendor> <!--This should be same as is configured via the toolchains plugin -->
</provides>
<configuration>
<jdkHome>C:\Program Files\Java\jdk1.7.0</jdkHome>
</configuration>
</toolchain>
</toolchains>
Add your own JRE, remove the default JRE installed in Eclipse. Yeah, it works.I could get no warning information when typing the command mvn eclipse:eclipse.
Try to store your maven projects in a directory that is not your eclipse workspace then import the projects to eclipse (without copying it!). Now the mvn eclipse:eclipse should work without warnings.
Seems to me maven fails to parse Eclipse's workspace settings properly. I was hitting the warning, and then I removed all JREs (I had two JREs and one JDK under Window-Preferences-Java-Installed JREs) and left only the JDK. No warnings since.
I am using Java 8, and I found that every time I did the eclipse:eclipse it was changing the JRE to JavaSE-1.7 instead of the JavaSE-1.8.
After more review of a bare bones pom.xml I saw the line in my properties section for maven.compiler.source and maven.compiler.target pointing to 1.7. Once I changed that to 1.8 everything works as expected.
I also have multiple version of Java setup. That didn't seem to be a problem. Updating this line seemed to do the trick, no more warnings when I do eclipse:eclipse now.
Hope it helps.