Wednesday, August 02, 2006

Maven2 mysteries

I am at a phase where I can actually experiment with a non-ant build system for a java with other tools (including a lisp based code generator) project.

One of the key requirements is to do very modular development with modules depending on other modules only in a binary way: that is the build system must build the dependency modules if necessary and place the binary deliverables of those modules into classpath or some such thing for any module.

I thougt maven is a good idea and it still seems so ...

Downloaded maven2 (version 2.0.4) based on advice at their web site. Also downloaded "maven 2.0.4 tasks for ant" thinking I might need them and placed it into the lib folder of maven installation. I still think I need them, but read on ...

Then I launched something like:

/cygdrive/d/projects >mvn archetype:create -DartifactId=foo -DarchetypeArtifactId=maven-archetype-quickstart

And duly received the following exception:

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] org.apache.maven.profiles.ProfileManager.loadSettingsProfiles(Lorg/apache
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NoSuchMethodError: org.apache.maven.profiles.ProfileManager.loadSettingsProfiles(Lorg/apache/maven/settings/Settings;)V
at org.apache.maven.DefaultMaven.doExecute(
at org.apache.maven.DefaultMaven.execute(
at org.apache.maven.cli.MavenCli.main(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.codehaus.classworlds.Launcher.launchEnhanced(
at org.codehaus.classworlds.Launcher.launch(
at org.codehaus.classworlds.Launcher.mainWithExitCode(

at org.codehaus.classworlds.Launcher.main(
[INFO] ------------------------------------------------------------------------

I must say I was not expecting this behaviour. I wasted like 3-4 hours doing google search, nopes no help (and hence this blog - in case you happen to search for it).

After some frustration and contemplation on whether I should give up etc, I noticed the error carefully. It struck me (obviously based on past experience) that may be there is a problem with the class in that the class does not precisely look like it was supposed to. that is the loading class expects the loaded class to look different.

Then I launched a small handy tool which I use to locate classes : the tool is a shell script that looks like this


if [ -z "$substring" ]

if [ -z "$substring" ]
cat <<EOS
Usage $0 [root-to-search-from] search-string.
root-to-search-from is optional - defaults to .
The search-string can even hold parts of the package structure
exit 1

substring=`echo $substring|tr '.' '/'`

cd "$root_dir"
for j in `find . -name '*.jar' -print`
echo "--- $j -------"
jar tvf $j | grep $substring | sed -e 's/^.* //'
echo "++++++++++++++"
cd "$old_pwd"

The launch results looked like

.../maven-2.0.4 >find-class ProfileManager
--- ./core/boot/classworlds-1.1.jar -------

--- ./lib/maven-artifact-ant-2.0.4-dep.jar -------
--- ./lib/maven-artifact-manager-2.0.4.jar -------

--- ./lib/maven-project-2.0.4.jar -------

.../maven-2.0.4 >

Ah! There are two implementations of ProfileManager.

I nuked maven-artifact-ant-2.0.4-dep.jar from the lib directory and then the project got created peacefully.

Now, is that jar required? May be, who knows?


Anonymous Carlos Sanchez said...

You had to put it in the lib folder of Ant, not Maven

10:54 PM  

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home