how to use maven resource plugin correcly - maven

There was a build failure when the project clean and install,
i think reason to build failure is maven resource plugin.
i have gotten the following error during the build the project
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-resources-plugin:2.7:resources from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-resources-plugin:2.7, parent: sun.misc.Launcher$AppClassLoader#70dea4e]
[WARNING] Error injecting: org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering
java.lang.NoClassDefFoundError: Lorg/sonatype/plexus/build/incremental/BuildContext;
at java.lang.Class.getDeclaredFields0 (Native Method)
at java.lang.Class.privateGetDeclaredFields (Class.java:2583)
at java.lang.Class.getDeclaredFields (Class.java:1916)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:675)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:380)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies (ConstructorBindingImpl.java:164)
at com.google.inject`enter code here`.internal.InjectorImpl.getInternalDependencies (InjectorImpl.java:613)
at com.google.inject.internal.InjectorImpl.cleanup (InjectorImpl.java:569)
following errors were also shown when debugging
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.291 s
[INFO] Finished at: 2017-11-04T02:15:13+05:30
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project cas: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources failed: A required class was missing while executing org.apache.maven.plugins:maven-resources-plugin:2.7:resources: Lorg/sonatype/plexus/build/incremental/BuildContext;
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-resources-plugin:2.7
following maven resource plugin was used in the pom
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
please help me to solve this problem, i have tried many ways to resolve this , but still couldn't find a solution for this.
i am using the following maven version
buddika#buddika-pc:~$ mvn -version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T13:28:13+05:30)
Maven home: /usr/local/apache-maven/apache-maven-3.5.2
Java version: 1.8.0_73, vendor: Oracle Corporation
Java home: /home/buddika/installs/JDK8/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-98-generic", arch: "amd64", family: "unix"
Thank You...

NoClassDefFoundError: Lorg/sonatype/plexus/build/incremental/BuildContext. Means there is no jar of sonatype..add that jar and try to build..
Remember NoClassDefFoundError means jar is not present in your local.. add it and try..

Related

Jenkins build error for a maven test project on ubuntu 16.04

I am encountering the error below while running a maven test project on Ubuntu 16.04. When I run the project from the terminal it works fine. But I need to run it through Jenkins now.
I have given all permissions for jenkins user. I cannot seem to understand the reason for this error so that I can troubleshoot further. Can someone please help as I am new to Devops and learning?
Console Output
`EnvInject] - Loading node environment variables.
Building in workspace /var/lib/jenkins/workspace/Maven Test Parsing POMs Established TCP socket on 43944 [IceScrum] $ /usr/lib/jvm/java-8-oracle //bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-agent-1.12-alpha-1.jar:/usr/share/maven/boot/plexus-classworlds-2.x.jar:/usr/share/maven/conf/logging jenkins.maven3.agent.Maven33Main /usr/share/maven/ /var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.2.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven33-interceptor-1.12-alpha-1.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 43944 <===[JENKINS REMOTING CAPACITY]===>channel started Executing Maven: -B -f /opt/IceScrum/pom.xml verify [INFO] Scanning for projects...`
`[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2 [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) # cxm7 --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /opt/IceScrum/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # cxm7 --- [INFO] No sources to compile [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # cxm7 --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /opt/IceScrum/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) # cxm7 --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.17:test (default-test) # cxm7 --- [INFO] No tests to run.
[INFO] Surefire report directory: /opt/IceScrum/target/surefire-reports`
`[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project cxm7: Error creating properties files for forking: Permission denied -> [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.
[JENKINS] Archiving /opt/IceScrum/pom.xml to cxm/cxm7/0.0.1-SNAPSHOT/cxm7-0.0.1-SNAPSHOT.pom
/opt/IceScrum/pom.xml is not inside /var/lib/jenkins/workspace/Maven Test/opt/IceScrum/; will archive in a separate pass [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
channel stopped
Finished: FAILURE`
After I ran the script with -X switch. I got the following results.
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_151, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-oracle/jre Default locale: en_IN, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-101-generic", arch: "amd64", family: "unix"
[DEBUG] Populating class realm maven.api [INFO] Error stacktraces are turned on.[DEBUG] Reading global settings from /usr/share/maven/conf/settings.xml
[DEBUG] Reading user settings from /root/.m2/settings.xml [DEBUG] Reading global toolchains from /usr/share/maven/conf/toolchains.xml[DEBUG] Reading user toolchains from /root/.m2/toolchains.xml [DEBUG] Using local repository at /root/.m2/repository [DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /root/.m2/repository [INFO] Scanning for projects
[DEBUG] Extension realms for project org.apache.maven:standalone-pom:pom:1: (none) [DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null] [INFO]``[INFO] BUILD FAILURE``[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/cyberadmin). Please verify you invoked Maven from the correct directory. -> [Help 1]org.apache.maven.lifecycle.MissingProjectException: The goal you specified requires a project to execute but there is no POM in this directory (/home/cyberadmin). Please verify you invoked Maven from the correct directory.
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:84)
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: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)
[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/MissingProjectException

Maven 3.5 build error

I have installed maven latest version 3.5 ,iam trying to build a fuse project and getting below error and warning.
output of mvn -version in command prompt:
C:\Temp\Fuse6.3>mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T20:39:06+01:00)
Maven home: C:\Temp\fuse 6.3\apache-maven-3.5.0\bin\..
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: C:\Temp\fuse 6.3\java\jdk1.8.0_151\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Can you please help.
[INFO] ------------------------------------------------------------------------
[WARNING] Could not transfer metadata com.company.esb.fuse:core:0.0.1-SNAPSHOT/maven-metadata.xml from/to redhat-ga-repository (https://maven.repository.redhat.com/ga): Cannot access https://maven.repository.redhat.com/ga with type default using the available connector factories: BasicRepositoryConnect
orFactory
[WARNING] Could not transfer metadata com.company.esb.fuse:core:0.0.1-SNAPSHOT/maven-metadata.xml from/to jboss-earlyaccess-repositor (http://maven.repository.redhat.com/earlyaccess/all/): Cannot access http://maven.repository.redhat.com/earlyaccess/all/ with type default using the available connector
factories: BasicRepositoryConnectorFactory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.260 s
[INFO] Finished at: 2017-10-23T10:58:29+01:00
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project core: Could not resolve dependencies for project com.company.esb.fuse:core:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.company.esb.fuse:core:jar:0.0.1-SNAPSHOT -> org.apache.camel:camel-core:jar:2.17.0.redhat-630262: Failed to read artifact descripto
r for org.apache.camel:camel-core:jar:2.17.0.redhat-630262: Could not transfer artifact org.apache.camel:camel-core:pom:2.17.0.redhat-630262 from/to redhat-ga-repository (https://maven.repository.redhat.com/ga): Cannot access https://maven.repository.redhat.com/ga with type default using the availab
le connector factories: BasicRepositoryConnectorFactory: No transporter factories registered -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Maven by example - NullPointer executing hibernate3:hbm2ddl

I am following the Maven by example guide to learn Maven.
I am busy working through chapter 7, which is a simple multimodule enterprise project containing spring and hibernate. The example files for this chapter can be downloaded here, in the ch-multi-spring directory.
Sections 7.1 to 7.6 talk about the specifics of each module. In section 7, the database is generated and the application is run. It is at this step that I receive the following error:
> mvn hibernate3:hbm2ddl -X
<Some output left out>
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Multi-Spring Chapter Simple Parent Project ........ FAILURE [0.752s]
[INFO] Multi-Spring Chapter Simple Object Model .......... SKIPPED
[INFO] Multi-Spring Chapter Simple Weather API ........... SKIPPED
[INFO] Multi-Spring Chapter Simple Persistence API ....... SKIPPED
[INFO] Multi-Spring Chapter Simple Command Line Tool ..... SKIPPED
[INFO] Multi-Spring Chapter Simple Web Application ....... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.330s
[INFO] Finished at: Thu Apr 24 15:31:18 CEST 2014
[INFO] Final Memory: 9M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) on project simple-parent: There was an error creating the AntRun task. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) on project simple-parent: There was an error creating the AntRun task.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
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: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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java: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.MojoExecutionException: There was an error creating the AntRun task.
at org.codehaus.mojo.hibernate3.AbstractHibernateMojo.execute(AbstractHibernateMojo.java:84)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.lang.NullPointerException
at org.codehaus.plexus.configuration.DefaultPlexusConfiguration.add(DefaultPlexusConfiguration.java:175)
at org.codehaus.plexus.configuration.DefaultPlexusConfiguration.addChild(DefaultPlexusConfiguration.java:151)
at org.codehaus.mojo.hibernate3.util.PlexusConfigurationUtils.setHibernateConfiguration(PlexusConfigurationUtils.java:289)
at org.codehaus.mojo.hibernate3.util.PlexusConfigurationUtils.parseHibernateTool(PlexusConfigurationUtils.java:67)
at org.codehaus.mojo.hibernate3.AbstractHibernateToolMojo.getConfiguration(AbstractHibernateToolMojo.java:60)
at org.codehaus.mojo.hibernate3.AbstractHibernateMojo.execute(AbstractHibernateMojo.java:76)
... 21 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
Since I'm still learning Maven, and not familiar with Hibernate, I have no idea what the problem could be. I haven't changed anything in the downloaded example files.
I was getting the same error.
I modified the version number of hibernate3-maven-plugin plugin:
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<!-- insted of 2.1 as documented inside the Maven by example guide -->
<version>2.2</version>
....
</groupId>
And this fixed the issue. Moreover, I'm using JDK 1.8. Below the 'mvn -v' output:
Java version: 1.8.0_20, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_20\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
I figured out the answer.
Here is the summary of my findings:
the mvn hibernate3:hbm2ddl command should be run from the simple-webapp or simple-command folder. (The specification for the plugin should be present in the POM for that module.)
increasing the hibernate3-maven-plugin version to 3.0 will reintroduce the problem, I believe I read some posts that the configuration format had been changed, but I didn't look further into it.
the mvn hibernate3:hbm2ddl will report the error shown below if JAVA_HOME is set to JDK1.7 instead of 1.6 (Found solution to this here)
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.1:hbm2ddl (default-cli) on project simple-command: Could not get ConfigurationTask.

Can't build C/C++ projects using maven-nar plugin

I'm trying to setup a simple project with an empty function (.c and .h file) on windows 7, using maven, cygwin and gcc. Following are details about my environment:
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 22:51:28+0900)
Maven home: C:\Program Files\apache-maven-3.0.5
Java version: 1.6.0_37, vendor: Sun Microsystems Inc.
Java home: C:\Progra~1\Java\jdk1.6.0_37\jre
Default locale: ko_KR, platform encoding: MS949
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
gcc (GCC) 4.5.3
When I try to build using the maven-nar plugin, I get the following error:
$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test-maven 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # test-maven ---
[INFO]
[INFO] --- maven-nar-plugin:2.1-SNAPSHOT:nar-validate (default-nar-validate) # test-maven ---
[INFO] Using AOL: x86-Windows-msvc
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.600s
[INFO] Finished at: Thu May 30 18:03:18 KST 2013
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-nar-plugin:2.1-SNAPSHOT:nar-validate (default-nar-validate) on project test-maven: Cannot deduce version number from: -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I have google'd and it seems to be related to maven not finding the gcc compiler.
Cannot deduce version number from: -> [Help 1]
The output from the mvn command also suggests that maven is trying to build my project with msvc which is not available on my machine.
[INFO] Using AOL: x86-Windows-msvc
I have the gcc compiler in my path etc and I have tried to follow some of the steps suggested in this very old thread.
Does anyone know how to overcome this problem? If I'm in the wrong forum, could someone please point me to the right one?
Yes, that error is caused by a command line tool being unavailable on the path. However, in this case, since your AOL is x86-Windows-msvc, the relevant command line tool is link, not gcc. (You can see this in the source code.)
Of course, you aren't trying to use the MSVC compiler at all, so you shouldn't need link in your path anyway. To use gcc instead, you need to configure that in your POM in the maven-nar-plugin configuration. Here is a sample configuration (from this project, which you will of course need to tweak to your needs):
<configuration>
<c>
<name>gcc</name>
<includes>
<include>**/*.c</include>
</includes>
<options>
<option>-I${JAVA_HOME}/include</option>
<option>${java.os.include}</option>
<option>${stack.protector.option}</option>
<option>${architecture.option}</option>
<option>${subsystem.option}</option>
<option>${debug.option}</option>
</options>
</c>
<linker>
<name>gcc</name>
<options>
<option>${architecture.option}</option>
<option>${subsystem.option}</option>
</options>
<sysLibs>
<sysLib>
<name>${libdl.name}</name>
</sysLib>
</sysLibs>
</linker>
<libraries>
<library>
<type>executable</type>
<!-- <run>true</run> -->
<subSystem>gui</subSystem>
</library>
</libraries>
</configuration>

Trying to compile mahout but getting error - Cannot execute mojo: resources. Build is not using pom.xml

I have completed the following steps:
Installed Java 1.6
I am using Ubuntu 11.10. Added the $JAVA_HOME path in /etc/bash.bachrc
Installed maven. mvn --version is showing the installed maven correctly.
Downloaded Mahout from http://svn.apache.org/repos/asf/mahout/trunk
Now, I go inside mahout/trunk and try to do mvn clean install or mvn clean install -X -e, then it gives the follwoing error -
Cannot execute mojo: resources. It requires a project with an existing
pom.xml, but the build is not using one.
I just want to try the examples in the mahout/examples. How to fix this error?
There is a pom.xml in the directory.
Full terminal output is here:
+ Error stacktraces are turned on.
Apache Maven 2.2.1 (rdebian-6)
Java version: 1.6.0_23
Java home: /usr/lib/jvm/java-6-openjdk/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux" version: "3.0.0-16-generic" arch: "i386" Family: "unix"
[DEBUG] Building Maven user-level plugin registry from: '/home/kartikeya/.m2/plugin-registry.xml'
[DEBUG] Building Maven global-level plugin registry from: '/usr/share/maven2/conf/plugin-registry.xml'
[INFO] Scanning for projects...
[DEBUG] Wagons could not be registered as the extension container was never created
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins:pom:12 for project: null:maven-clean-plugin:maven-plugin:2.3 from the repository.
[DEBUG] Retrieving parent-POM: org.apache.maven:maven-parent:pom:9 for project: org.apache.maven.plugins:maven-plugins:pom:12 from the repository.
[DEBUG] Retrieving parent-POM: org.apache:apache:pom:4 for project: org.apache.maven:maven-parent:pom:9 from the repository.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot execute mojo: clean. It requires a project with an existing pom.xml, but the build is not using one.
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:414)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Mar 21 11:32:36 IST 2012
[INFO] Final Memory: 2M/55M
[INFO] ------------------------------------------------------------------------
Thank you ajozwik and Owen.
I installed maven2 from the aptitude. I took the following steps to fix this issue:
Removed Maven2 sudo apt-get remove maven2
Installed Maven 3.0.4 for ubuntu as directed in - Installing maven2 without openjdk
Even after doing this, I got the error -
Unable to locate the javac Compiler in:[ERROR] /usr/lib/jvm/java-6-openjdk/jre/../lib/tools.jar
To fix this, JDK needs to be reinstalled. It worked for me!. For those even, if this solution doesn't work, please have a look at - Why maven ignores my JAVA_HOME?
Regards.
"Cannot execute mojo: resources. It requires a project with an existing pom.xml"
This error means there is not pom.xml in the working directory

Resources