Hubert Leszczyński
Hubert Leszczyński

Reputation: 79

Maven war project with jars

Hey I am writting a project which includes 2 other maven project:

  1. JPA with EJB project (DAO layer) packaging .jar

  2. Rest Services Project packaging .war

I found help with setting dependency with eclipse. In my war project I've added local project with DAOs. Compiling, building(mvn clean install on two pom.xml) went succesfull. But I can't deploy it on wildfly server. I get NoClassDef of class from my jar package.

On the other hand I saw a lot of projects with DAO packing in jar. But there are EJB3 annotations. Will they work with JEE Server in that configuration?(They don't need web.xml so maybe it is correct). Which scope i have to set of my dependent DAO project? If i have NoClassDef error it seems there is no compiled classes at runtime, or there is 2 or more definitions of classes from this package. I've tried few configurations, but I can't get solution.

Could someone write best practice to setting maven projects? For example

  1. DAO layer type: jar

  2. Rest Services layer type: war, dependence: DAO { scope: default, type:jar}

Upvotes: 0

Views: 162

Answers (1)

Carlos Laspina
Carlos Laspina

Reputation: 2231

I think a good practice would be to define a project parent (Parent POM), which must define the module involved:

<modules>
    <module>application-dao</module>
    <module>application-rest</module>
</modules>

and define as a dependency, your application ".jar"

<dependency>
    <groupId>com.test</groupId>
    <artifactId>application-dao</artifactId>
    <version>${project.version}</version>
    <scope>compile</scope>
</dependency>

A recommendation you could add an extra layer of management, then you would

  • application-dao
  • application-core
  • application-rest

Upvotes: 1

Related Questions