Maven quirk ( archetype-j2ee-simple )
The issue has been fixed. There were two points.
1. I was using the wrong (deprecated) goal archetype:create instead of archetype:generate.
2. With the plugin archetype-j2ee-simple there is a bug which is already reported here.
I got my answer from Antony Stubbs on Stackoverflow.
At last I also decided to join the maven bandwagon, I will start using maven for managing my projects. Convention over configuration sounds indeed a nice idea. When I first heard about maven I didn’t have a good “feeling” about it, may be because I was too comfortable with ant and believe to be able to achieve any task with it. But now after reading some documentation and articles about maven, I came to realise it is completely new paradigm than ant. In my opinion the best aspect of maven is that you always have the big picture of your project in mind instead of a small task or operation to be done. I started liking maven and also started learning it. For reference I have started following Maven: The Definitive Guide. Another great advantage could be that if you know maven and a join a new team which also uses maven for project management, you don’t have to spend hours or may be days trying to figure out the structure of their project and being able to build it.
Although I started liking maven, sometimes it feels like a strange tool, where you have to configure a lot to achieve your goal. if you want some custom stuff in your project. I also find it annoying that by default the compiler-plugin assumes you want to build for java 1.4 or java 1.3. Moreover, because there are always so called sensible or obvious defaults assumed, in maven world, not all the obvious defaults are obvious to you and you have to know the documentation well to be able to know what those defaults are. and how you can achieve something different. It feels somewhat like javadocs, until you get used to the apis you need frequently, you have to rely on auto-completion of your IDE or have the javadoc always open. There is no wonder that the second part of the book, I mentioned contains only the maven reference.
But, yes, I am here to talk about the quirk of maven which I encountered during my learning process. I am just a maven beginner, so may be this is normal behavior, but I don’t think so.
So, while starting to learn maven, I started with a contrived JavaEE application (brave huh), which is taken as example in the very good book EJB 3 in Action. I searched the net and found out about the maven archetype j2ee-simple here. I used following commandline to generate the stubs of a simple JavaEE project, actually I was interested in the standard directory structure.
mvn archetype:create -DgroupId=com.hardik -DartifactId=ActionBazaar -DarchetypeArtifactId=maven-archetype-j2ee-simple
The project was created perfectly, but by default it was not compiling. When I executed mvn intall I had following errors.
$ mvn install
[INFO] Scanning for projects…
[ERROR] FATAL ERROR
[INFO] Error building POM (may not be this project’s POM).
Project ID: unknown
Reason: Could not find the model file ‘/home/hardik/projects/ActionBazaar/site’. for project unknown
[INFO] ———————————————————————— It is talking about some model file for the site module. The site module is generally the “website” of your project that maven generates just by looking at your pom.xml file. I removed the site module from the module list of the pom file and it started working. But I still wonder why the default project structure doesn’t build. I am sure this is incorrect behavior. If someone has had the same problem, and was able to fix, please let me know. References:
org.apache.maven.reactor.MavenExecutionException: Could not find the model file ‘/home/hardik/projects/ActionBazaar/site’. for project unknown
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: org.apache.maven.project.ProjectBuildingException: Could not find the model file ‘/home/hardik/projects/ActionBazaar/site’. for project unknown
… 12 more
Caused by: java.io.FileNotFoundException: /home/hardik/projects/ActionBazaar/site (No such file or directory)
at java.io.FileInputStream.open(Native Method)
… 18 more
[INFO] Total time: < 1 second [INFO] Finished at: Thu Jul 09 18:44:31 CEST 2009 [INFO] Final Memory: 1M/4M [INFO] ------------------------------------------------------------------------[/sourcecode]
It is talking about some model file for the site module. The site module is generally the “website” of your project that maven generates just by looking at your pom.xml file. I removed the site module from the module list of the pom file and it started working. But I still wonder why the default project structure doesn’t build. I am sure this is incorrect behavior.
If someone has had the same problem, and was able to fix, please let me know.