Maven assembly plugin fails with NullPointerException? - java

I get a NullPointerException and I don't like it. It is a larger build with several submodules (which differ in their maven config only slightly), for most of the modules it does work, but for some not. Any ideas what the problem might be?
[INFO] [assembly:assembly]
[INFO] Reading assembly descriptor: src/assemble/all.xml
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NullPointerException
at org.apache.maven.artifact.DefaultArtifact.equals(DefaultArtifact.java:358)
at java.util.HashMap.put(HashMap.java:376)
at java.util.HashSet.add(HashSet.java:200)
at java.util.AbstractCollection.addAll(AbstractCollection.java:305)
at org.apache.maven.plugin.assembly.artifact.DefaultDependencyResolver.buildManagedVersionMap(DefaultDependencyResolver.java:160)
at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:179)
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:370)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:268)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
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.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)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 41 seconds
[INFO] Finished at: Fri Jun 19 10:44:03 CEST 2009
[INFO] Final Memory: 32M/99M
[INFO] ------------------------------------------------------------------------

Looking at line 358 of the head revision, my guess is that something, somewhere has no version defined.
I don't really "know" Maven, but I'd suggest checking your versions carefully. Of course, it's possible that I'm not looking at the same source code as you're using - have a look at the source for your actual version to see what's at DefaultArtifact.java line 358.

If the versions are not empty like Jon-skeet suggested it could be a maven-enforcer-plugin bug:
https://issues.apache.org/jira/browse/MENFORCER-156
Essentially, the maven-enforcer-plugin (in at least version 1.3) "puts the MavenProject in a state where it claims that all dependencies are resolved, but the artifact-files are not bound."
For me this reoccurred in version 1.4.1.

Related

Unable to compile Eclipse PAHO MQTT Client project

I am following the following steps:
git clone http://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.java.git
cd org.eclipse.paho.mqtt.java.git
mvn package -DskipTests
This step result in:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.eclipse.paho:java-parent
Reason: Cannot find layout implementation corresponding to: 'p2' for remote repository with id: 'eclipse-kepler'. for project org.eclipse.paho:java-parent
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Cannot find layout implementation corresponding to: 'p2' for remote repository with id: 'eclipse-kepler'. for project org.eclipse.paho:java-parent
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
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:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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.project.ProjectBuildingException: Cannot find layout implementation corresponding to: 'p2' for remote repository with id: 'eclipse-kepler'. for project org.eclipse.paho:java-parent
at org.apache.maven.project.DefaultMavenProjectBuilder.buildArtifactRepositories(DefaultMavenProjectBuilder.java:949)
at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1206)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:823)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
... 12 more
Caused by: org.apache.maven.artifact.InvalidRepositoryException: Cannot find layout implementation corresponding to: 'p2' for remote repository with id: 'eclipse-kepler'.
at org.apache.maven.project.ProjectUtils.getRepositoryLayout(ProjectUtils.java:157)
at org.apache.maven.project.ProjectUtils.buildArtifactRepository(ProjectUtils.java:110)
at org.apache.maven.project.ProjectUtils.buildArtifactRepositories(ProjectUtils.java:56)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildArtifactRepositories(DefaultMavenProjectBuilder.java:942)
... 19 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Component descriptor cannot be found in the component repository: org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayoutp2.
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:323)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:440)
at org.apache.maven.project.ProjectUtils.getRepositoryLayout(ProjectUtils.java:153)
... 22 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sat Nov 22 11:37:37 CET 2014
[INFO] Final Memory: 2M/136M
[INFO] ------------------------------------------------------------------------
If remove 'eclipse-kepler' reposiroty in pom.xml get other type of errors.
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] Eclipse Paho
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.client.mqttv3:eclipse-plugin:1.0.1
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.client.mqttv3.test:jar:1.0.1
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.client.eclipse.feature:eclipse-feature:1.0.1
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.client.eclipse.view:eclipse-plugin:1.0.1
[INFO] Paho P2 Repository
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.mqtt.utility:jar:1.0.1
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.ui:pom:1.0.1
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.ui.core:eclipse-plugin:1.0.1
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.ui.app:eclipse-repository:1.0.1
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.ui.plugin:pom:1.0.1
[INFO] Eclipse Paho - MQTT Android Service
[INFO] Unnamed - org.eclipse.paho:org.eclipse.paho.android.service:jar:1.0.1
[INFO] ------------------------------------------------------------------------
[INFO] Building Eclipse Paho
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - org.eclipse.paho:org.eclipse.paho.client.mqttv3:eclipse-plugin:1.0.1
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Internal error in the plugin manager executing goal 'org.eclipse.tycho:tycho-packaging-plugin:0.20.0:build-qualifier': Unable to find the mojo 'build-qualifier' (or one of its required components) in the plugin 'org.eclipse.tycho:tycho-packaging-plugin'
Component descriptor cannot be found in the component repository: org.codehaus.plexus.logging.Logger.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Internal error in the plugin manager executing goal 'org.eclipse.tycho:tycho-packaging-plugin:0.20.0:build-qualifier': Unable to find the mojo 'build-qualifier' (or one of its required components) in the plugin 'org.eclipse.tycho:tycho-packaging-plugin'
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:698)
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:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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.PluginManagerException: Unable to find the mojo 'build-qualifier' (or one of its required components) in the plugin 'org.eclipse.tycho:tycho-packaging-plugin'
at org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:674)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:468)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Unable to lookup component 'org.apache.maven.plugin.Mojoorg.eclipse.tycho:tycho-packaging-plugin:0.20.0:build-qualifier', it could not be started
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:339)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:440)
at org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:652)
... 19 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLifecycleException: Error starting component
at org.codehaus.plexus.component.manager.AbstractComponentManager.startComponentLifecycle(AbstractComponentManager.java:109)
at org.codehaus.plexus.component.manager.AbstractComponentManager.createComponentInstance(AbstractComponentManager.java:95)
at org.codehaus.plexus.component.manager.PerLookupComponentManager.getComponent(PerLookupComponentManager.java:48)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:331)
... 21 more
Caused by: org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException: Error composing component
at org.codehaus.plexus.personality.plexus.lifecycle.phase.CompositionPhase.execute(CompositionPhase.java:33)
at org.codehaus.plexus.lifecycle.AbstractLifecycleHandler.start(AbstractLifecycleHandler.java:101)
at org.codehaus.plexus.component.manager.AbstractComponentManager.startComponentLifecycle(AbstractComponentManager.java:105)
... 24 more
Caused by: org.codehaus.plexus.component.composition.CompositionException: Composition failed of field projectTypes in object of type org.eclipse.tycho.buildversion.BuildQualifierMojo because the requirement ComponentRequirement{role='org.eclipse.tycho.core.TychoProject', roleHint='null', fieldName='projectTypes'} was missing
at org.codehaus.plexus.component.composition.FieldComponentComposer.assignRequirementToField(FieldComponentComposer.java:154)
at org.codehaus.plexus.component.composition.FieldComponentComposer.assembleComponent(FieldComponentComposer.java:73)
at org.codehaus.plexus.component.composition.DefaultComponentComposerManager.assembleComponent(DefaultComponentComposerManager.java:68)
at org.codehaus.plexus.DefaultPlexusContainer.composeComponent(DefaultPlexusContainer.java:1486)
at org.codehaus.plexus.personality.plexus.lifecycle.phase.CompositionPhase.execute(CompositionPhase.java:29)
... 26 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Unable to lookup component 'org.eclipse.tycho.core.TychoProjecteclipse-test-plugin', it could not be started
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:339)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:440)
at org.codehaus.plexus.DefaultPlexusContainer.lookupMap(DefaultPlexusContainer.java:390)
at org.codehaus.plexus.component.composition.FieldComponentComposer.assignRequirementToField(FieldComponentComposer.java:103)
... 30 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLifecycleException: Error starting component
at org.codehaus.plexus.component.manager.AbstractComponentManager.startComponentLifecycle(AbstractComponentManager.java:109)
at org.codehaus.plexus.component.manager.AbstractComponentManager.createComponentInstance(AbstractComponentManager.java:95)
at org.codehaus.plexus.component.manager.ClassicSingletonComponentManager.getComponent(ClassicSingletonComponentManager.java:92)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:331)
... 33 more
Caused by: org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException: Error composing component
at org.codehaus.plexus.personality.plexus.lifecycle.phase.CompositionPhase.execute(CompositionPhase.java:33)
at org.codehaus.plexus.lifecycle.AbstractLifecycleHandler.start(AbstractLifecycleHandler.java:101)
at org.codehaus.plexus.component.manager.AbstractComponentManager.startComponentLifecycle(AbstractComponentManager.java:105)
... 36 more
Caused by: org.codehaus.plexus.component.composition.CompositionException: Composition failed of field resolver in object of type org.eclipse.tycho.core.osgitools.OsgiTestBundleProject because the requirement ComponentRequirement{role='org.eclipse.tycho.core.osgitools.EquinoxResolver', roleHint='null', fieldName='resolver'} was missing
at org.codehaus.plexus.component.composition.FieldComponentComposer.assignRequirementToField(FieldComponentComposer.java:154)
at org.codehaus.plexus.component.composition.FieldComponentComposer.assembleComponent(FieldComponentComposer.java:73)
at org.codehaus.plexus.component.composition.DefaultComponentComposerManager.assembleComponent(DefaultComponentComposerManager.java:68)
at org.codehaus.plexus.DefaultPlexusContainer.composeComponent(DefaultPlexusContainer.java:1486)
at org.codehaus.plexus.personality.plexus.lifecycle.phase.CompositionPhase.execute(CompositionPhase.java:29)
... 38 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Unable to lookup component 'org.eclipse.tycho.core.osgitools.EquinoxResolver', it could not be started
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:339)
at org.codehaus.plexus.component.composition.FieldComponentComposer.assignRequirementToField(FieldComponentComposer.java:129)
... 42 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLifecycleException: Error starting component
at org.codehaus.plexus.component.manager.AbstractComponentManager.startComponentLifecycle(AbstractComponentManager.java:109)
at org.codehaus.plexus.component.manager.AbstractComponentManager.createComponentInstance(AbstractComponentManager.java:95)
at org.codehaus.plexus.component.manager.ClassicSingletonComponentManager.getComponent(ClassicSingletonComponentManager.java:92)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:331)
... 43 more
Caused by: org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException: Error composing component
at org.codehaus.plexus.personality.plexus.lifecycle.phase.CompositionPhase.execute(CompositionPhase.java:33)
at org.codehaus.plexus.lifecycle.AbstractLifecycleHandler.start(AbstractLifecycleHandler.java:101)
at org.codehaus.plexus.component.manager.AbstractComponentManager.startComponentLifecycle(AbstractComponentManager.java:105)
... 46 more
Caused by: org.codehaus.plexus.component.composition.CompositionException: Composition failed of field logger in object of type org.eclipse.tycho.core.osgitools.EquinoxResolver because the requirement ComponentRequirement{role='org.codehaus.plexus.logging.Logger', roleHint='null', fieldName='logger'} was missing
at org.codehaus.plexus.component.composition.FieldComponentComposer.assignRequirementToField(FieldComponentComposer.java:154)
at org.codehaus.plexus.component.composition.FieldComponentComposer.assembleComponent(FieldComponentComposer.java:73)
at org.codehaus.plexus.component.composition.DefaultComponentComposerManager.assembleComponent(DefaultComponentComposerManager.java:68)
at org.codehaus.plexus.DefaultPlexusContainer.composeComponent(DefaultPlexusContainer.java:1486)
at org.codehaus.plexus.personality.plexus.lifecycle.phase.CompositionPhase.execute(CompositionPhase.java:29)
... 48 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Component descriptor cannot be found in the component repository: org.codehaus.plexus.logging.Logger.
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:323)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:312)
at org.codehaus.plexus.component.composition.FieldComponentComposer.assignRequirementToField(FieldComponentComposer.java:129)
... 52 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Sat Nov 22 11:45:51 CET 2014
[INFO] Final Memory: 20M/265M
[INFO] ------------------------------------------------------------------------
Can somebody help me?
You can try to upgrade maven from 2.x to 3.x.
Note that on Ubuntu, the 'maven' package is newer than the 'maven2' package. The following commands fixed it for me:
sudo apt-get remove maven2
sudo apt-get install maven

Maven not able to find plugin descriptor

Im trying to build a legacy project, which has dependencies like torque. When I try to execute the command mvn torque:create-db
But I see the following error
D:\someproject\cps-rfq\someproject-new\someproject>mvn torque:create-db
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin descriptor for the plugin Plugin [torque:maven-torque-plugin]
was not found. Please verify that the plugin JAR D:\someproject\cps-rfq\lib\torque\ma
ven-torque-plugin\3.3-RC3\maven-torque-plugin-3.3-RC3.jar is intact.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.IllegalStateException: The plugin descriptor for the plugin Plugin [to
rque:maven-torque-plugin] was not found. Please verify that the plugin JAR D:\IR
DEV\cps-rfq\lib\torque\maven-torque-plugin\3.3-RC3\maven-torque-plugin-3.3-RC3.
jar is intact.
at org.apache.maven.plugin.DefaultPluginManager.addPlugin(DefaultPluginM
anager.java:360)
at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(De
faultPluginManager.java:224)
at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPlug
inManager.java:184)
at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(Def
aultPluginManager.java:1642)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(Defa
ultLifecycleExecutor.java:1540)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor
(DefaultLifecycleExecutor.java:1787)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListBy
AggregationNeeds(DefaultLifecycleExecutor.java:462)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:175)
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:6
0)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.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)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sat Jun 29 11:56:10 IST 2013
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
But I can see the D:\someproject\cps-rfq\lib\torque\maven-torque-plugin\3.3-RC3\maven-torque-plugin-3.3-RC3.jar file in the repo.
I would suggest to use the final release version like this:
mvn torque:maven-torque-plugin:3.3:create-db
Furthermore i would suggest to first try to delete the folder in your local repository:
D:\someproject\cps-rfq\lib\torque
And retry your build, cause it looks weired that the RC version has been in use instead of the release version.

How to start launch the HSQLDB server as described in the Hibernate tutorial?

Trying to follow step #4 in this Hibernate tutorial:
mvn exec:java -Dexec.mainClass="org.hsqldb.Server" -Dexec.args="-database.0 file:target/data/tutorial"
I am getting this error:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'.
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial
[INFO] task-segment: [exec:java]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing exec:java
[INFO] No goals needed for project - skipping
[INFO] [exec:java {execution: default-cli}]
[WARNING]
java.lang.ClassNotFoundException: org.hsqldb.Server
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:662)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An exception occured while executing the Java class. org.hsqldb.Server
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon Dec 17 16:35:42 EST 2012
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
This is despite downloading the latest hsqldb package and installing it per the FAQ. The hsqldb.jar file is located in C:\hsqldb-2.2.9\hsqldb-2.2.9\hsqldb\lib and the classpath env var points at it:
CLASSPATH=C:\hsqldb-2.2.9\hsqldb-2.2.9\hsqldb\lib
So why am I receiving this ClassNotFoundException: org.hsqldb.Server error?
What am I doing wrong?
First of all, your CLASSPATH is not generally correct for any jar. A jar name must be specified, for example:
CLASSPATH=C:\hsqldb-2.2.9\hsqldb-2.2.9\hsqldb\lib\hsqldb.jar
Second, CLASSPATH is not necessary for this tutorial, as it is a Maven project. You should add the relevant dependency to the pom.xml file that is described in section 1.1.1 of the tutorial you mention. Simply add this block to the ones listed in the pom.xml, inside the tab:
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.9</version>
</dependency>
According to http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html, you need to specify the whole path ending with .jar. If there are multiple jar files, maybe try specifying C:\path\to\hibernate*.jar
If you only specify directories, only *.class files are loaded.
Other possiblity is the CLASSPATH variable you set only valid for a shell session, not globally -- hence the maven command is not reading it. Try setting it via Windows system settings.
I would recommend to download fresh copy of tutorial from http://sourceforge.net/projects/hibernate/files/hibernate3/3.3.2.GA/ and try to build it. If you will be missing dependendiens like hsqldb or commons-logging and others I got this problem solved by adding maven project repository - https://repository.jboss.org/nexus/content/repositories/thirdparty-releases. Once all artifacts downloaded I was able to run HSQLDB server. Would recommend to compare your current project with freshly downloaded one. It should solve your problem.

maven-exec-plugin throws exception for no apparent reason

I type the following in a Windows shell in the root of a Maven project that contains a class with a
public static void main(String[] args)
method that I'd like to run.
mvn exec:java -Dexec.mainClass="com.spp.config.main.SqlGeneratorHarness" -e
The class exists and is compiled in that package
(i.e., target/classes/com/spp/config/main/SqlGeneratorHarness.class).
I see...
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Invalid task '.mainClass=com.spp.config.main.SqlGeneratorHarness': you must specify a valid
lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
[INFO] ------------------------------------------------------------------------
[INFO] Trace org.apache.maven.BuildFailureException: Invalid task' .mainClass=com.spp.config.main.SqlGeneratorHarness': you must specify
a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1830)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAggregationNeeds(DefaultLifecycleExecutor.java:462)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:175)
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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue Sep 27 14:33:52 PDT 2011
[INFO] Final Memory: 3M/122M
[INFO] ------------------------------------------------------------------------
I've tried variations like
mvn exec:exec -Dexec.executable="java" [...]
and
mvn org.codehaus.mojo:exec-maven-plugin:1.2.1:java [...]
to no avail. What gives?
I'm running Maven 2.2.1, Java JDK 1.6.0_27 on Windows 7 Enterprise 64-bit.
A snippet from my pom.xml for the exec-maven-plugin is...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
</plugin>
where the version is set in the <properties>
So... revisiting this... if you use Windows PowerShell, you will get the exception I originally reported. If, however, you use cmd.exe, then you should be able to run the class with the command as I posted (with or without wrapping double-quotes).
There's something very basic going wrong. Try losing the quotation marks. They're not needed there. In fact, try starting with something simpler, like
mvn -e exec:java -Dexec.mainClass=foo
That should give you the error "An exception occured while executing the Java class. foo", and the root cause should be a ClassNotFoundException:
Caused by: java.lang.ClassNotFoundException: foo
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
Type it out yourself. Don't copy/paste the command from somewhere else.
Just a quick checklist:
Rename ~/.m2 folder and run mvn exec:java ... again and let Maven to download everything again from central.
Check that your exec plugin is downloaded from central. (Check that your local repository contains the same files as the central.)
Looking for suspicious repository and pluginRepository tags in the pom.xml (and parent poms as well).
Looking for suspicious repository, pluginRepository and mirror tags in the settings.xml.
Checking the project in an other machine - copy it and try to build/run exec:java in an other machine.
Download Maven 3.x and try to run the exec with it.

compiling a Java EE 6 project using maven fails

I am a beginner in Java EE 6 and now trying to learn Java EE 6 with help of a book 'Java EE 6 novice to professional'. It is using maven to build a project, but when I tried to compile the downloaded source code of that book without using any IDE it fails and showing some errors as follows
C:\Utilities\Java utilities\Java EE 6 book source programs\Chapter02\src>mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugin
s/8/maven-plugins-8.pom
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/5/maven
-parent-5.pom
Downloading: http://repo1.maven.org/maven2/org/apache/apache/3/apache-3.pom
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compil
er-plugin/2.0.2/maven-compiler-plugin-2.0.2.jar
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute mojo: resources. It requires a project with an existing po
m.xml, but the build is not using one.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10 seconds
[INFO] Finished at: Sun Jan 16 18:33:38 IST 2011
[INFO] Final Memory: 3M/56M
[INFO] ------------------------------------------------------------------------
C:\Utilities\Java utilities\Java EE 6 book source programs\Chapter02\src>mvn -e comp
ile
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute mojo: resources. It requires a project with an existing po
m.xml, but the build is not using one.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Cannot execute mojo: res
ources. It requires a project with an existing pom.xml, but the build is not usi
ng one.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:584)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:500)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:479)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:331)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:292)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:345)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:132)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:290)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.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:
resources. It requires a project with an existing pom.xml, but the build is not
using one.
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:380)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:559)
... 16 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sun Jan 16 18:34:13 IST 2011
[INFO] Final Memory: 3M/56M
[INFO] ------------------------------------------------------------------------
As I am not familiar even with j2ee, I couldn't solve it. Can anyone help me???
It seems that you are missing a pom.xml file.
It looks like it is a problem with maven, not java (ee). You have to create a pom.xml file for your project to tell maven which dependencies your program has and how to compile the program. Unfortunately I am not very familiar with maven, but I suggest that you read a maven beginner tutorial.
Not sure if you've fixed the issue. I think you need to run the mvn compile command from here:
C:\Utilities\Java utilities\Java EE 6 book source programs\Chapter02>
that is because this the pom.xml is in this folder.

Categories

Resources