views:

310

answers:

3

Hello again!

I have been busy in my project creating a webapp (in struts) that manages maven, using maven-2.2.1-uber.jar link text. The problem comes when the boss says it has to use some archetypes the company has created (so no predefined archetypes for you naughty boy!). So ok, I use the -DarchetypeRepository option (with ServletWrapper I get my complete web direction, becouse the repository will be inside the app), and the log seems to find it, but then the build fails -miserably- with this little text 'Build Failure - The defined artifact is not an archetype' as simple as that. Of course I have a lot of INFO lines that say abslutily nothig related. I have read the maven definitive guide searching for some kind of help, but it has been disapointing at best.

My thoughts are thatmaybe I am missing in somewhere of all the folders tree some xml that actually sais maven that my pom.xml is an archetype not a project. But I really, really, can't find anything on the net or in the manuals that explains easy-handed how the archetype:generate (with special parameters) works and where I have to put every folder and/or file.

So just to say my thoughts aloud (and hopefully you understand what I am trying to ask): I have a template where I do some xml changes (variables, etc...), then I have to call maen and do an archetype:generate with a variable project. The problem seems to be that my actual confuguration doesn't like what I am doing. After the generation of the archetype, witch luckly will create some directory trees and leave me a POM.xml somewhere I still have to do some variable changes and more xml manage stuff, so it whould be very kind from maven to don't destroy anything in this process.

Any ideas why this maven-thing is not happly-ever-after asuming that my archetype is defintly an archetype? Allthought I think the code is ok, it could be wrong, as I am using maven-ubber and I call the actual CSMavenCli.main(String[, ClassWorld), I don't think it is the case this time.

Thanks and all! :)

Random.

+1  A: 

But I really, really, can't find anything on the net or in the manuals that explains easy-handed how the archetype:generate (with special parameters) works and where I have to put every folder and/or file.

Your best bet would be to look at the sources of existing archetypes IMHO, ideally something close to what you're doing.

Any ideas why this maven-thing is not happy-ever-after assuming that my archetype is definitely an archetype?

Honestly, I'm not sure I understood what you're doing so, no, no idea.

Pascal Thivent
A: 

Here's a guess ... the message:
'Build Failure - The defined artifact is not an archetype', describes the problem.

I suspect that what the maven build is receiving from your web-app is not an archetype.
Try pointing your web browser at the archetype url that your web-app serves up, it should look something like this.

If it doesn't, then check that your web-app isn't trying to process the resulting XML as a view template, and that the XML is being streamed to the HttpResponse with the correct mime-type.
Also check that the archetype resource is not protected by security definitions in your web.xml.

crowne
Thanks for your response :) Unfortunately, the web-app is looking to the right place and I am serving the right pom.xml. Also, the web.xml has very little security since it is going to be a intranet project (it is actually all disabled for development issues). I have tried with the maven console (see my other post) and is probably some maven configuration that I am failing at. Thanks!
Random
A: 

First of all, thanks for answering :)

Today I'm trying to get a better understanding of how archetypes works looking at the tutorial on maven here, althought is still very disapointing.

My problem is that I am having a build failure in maven when I try to do the mvn archetype:generate instruction. This is, as simple as possible, my problem. The build problem says that 'The defined artifact is not an archetype'.

I have tried the decreapted instruction archetype:create and the error is more or less the same but it adds that 'Embedded error: The META-INF/maven/archetype.xml descriptor cannot be found.' In my archetype there is an archetype.xml so it seems that the decreapted instruction is decreapted for a good reason.

My total instruction is at follows

mvn archetype:generate
-DgroupId=my_groupid
-DartifactId=my_artifactid
-Dversion=1.0
-DarchetypeGroupId=archetype-foo-lib
-DarchetypeArtifactId=my.archetype.foo
-DarchetypeVersion=1.0
-DarchetypeRepository=C:/.m2/repository
-Dbasedir=C:/.m2/repository/archetype-foo-lib
-B
-DinteractiveMode=false

In basedir I have the pom.xml and the dom4j.jar and the repository is up (in a little tomcat server). Also, the archetype is installed and the archetypegroupid, archetypeartifacid and archetypeversion are the same as the one in the src\main\resources\archetype-resources folder. I also tried to change the slashes to '\' in the basedir (just in case) with no better results.

As I am now trying to do it directly in maven console you can forget about the webapp project and all that stuff. I can hopefully make it work there once it starts working in the console.

Alas! Also I have the stacktrace (as I have also done this with -e parameter)

+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus
.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate {execution: default-cli}]
[INFO] Generating project in Batch mode
[INFO] Archetype defined by properties
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] The defined artifact is not an archetype
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: The defined artifact is not an archetype

at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:715)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone
Goal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:284)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.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: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:585)
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.MojoFailureException: The defined artifact is
not an archetype
at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execu
te(CreateProjectFromArchetypeMojo.java:201)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:694)
... 17 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Mar 30 11:08:59 CEST 2010
[INFO] Final Memory: 8M/15M
[INFO] ------------------------------------------------------------------------

Since the repository could be bad, I have also changed the -Darchetyperepository to c:.m2\repository but it also fails myserably to acomplish something diferent.

I hope this post is more insightfull.

Thanks for all :) Random

Edit: Ok, new data. I am know investigating why it seems to not be an archetype, and it seems that mvn archetype:generate -DarchetypeCatalog=local has 0 archetypes. So it appears that it's not installed. I have done the mvn install and the mvn archetype:crawl but it doesn't work. Any ideas why it doesn't let me install my own archetypes? Thanks again :)

Edit Again: Problem with local archetypes resolved, I had to move the archetype-catalog.xml from ~/.m2/repository/ to ~/.m2/ and then just like that Maven found my local archetypes. Strange off all, it still gives me the same error. I have also changed my archetype repository and base dir.

Last Edit (I hope so!): well, I finally found the error. It's so stupid I feel my self ashemed to write t down (it's been three days by know becouse of this). My archetypeArtifactId and my archetypeGroupId where exchanged (I mean, one was the other). Once I started passing the corrtect parameters (defined in archetype-catalog.xml that, although, I still had to move to the correct place) it started to do wonders. Thanks too all peoplo who read or wrote :)

Random