views:

22

answers:

1

Hi,

I've just started using Maven2 after using Ant for the last 3 years. So far I like what I'm seeing but I'm still getting to grips with the structure of the tool and its integration with IntelliJ and whats going on in the background.

One of the biggest draws to Maven was its ability to resolve dependencies transitively as part of the build process, but I am having problems with this feature at the moment through lack of understanding I believe.

Consider my very simple Java EE project (simple web services) consisting of the following modules: core (persistence entities, and a generic DAO with JPA implementation), ejb-component(ejb3 web service - dependent on core), and a webapp (spring web service - dependent on core).

I've installed the core module and its available in the repository, and I've added it as a dependency of both my ejb module and my webapp module with a scope of compile. However, if I dont have the javaee api dependency in my webapp module it won't compile. At the moment my source code is POJO with no metadata.

Any help would be much appreciated!

A: 

However, if I dont have the javaee api dependency in my webapp module it won't compile. At the moment my source code is POJO with no metadata.

Web Apps (and Java EE modules in general) most of time need a compile time dependency on Java EE APIs like the Servlet API, etc that will be provided at runtime by the container. When using Maven, such dependencies are declared with a provided scope. For example:

<dependency>
  <groupId>javax</groupId>
  <artifactId>javaee-api</artifactId>
  <version>6.0</version>
  <scope>provided</scope>
</dependency>

In your case, since you mention a compilation problem, I'm tempted to say that your webapp module is really missing a dependency on some API that should be declared as mentioned above.

What is unclear is how this relates to the question title. Maybe providing the relevant part of your POMs and the exact error would help to get a more precise answer.

Reference

Pascal Thivent