Search code examples
eclipsejakarta-eesetup-projectearglassfish-4

Eclipse EAR project structure in eclipse


For the past years I have been working with Java EE 6 and simpler application structures, where only one ejb and one war project were present.

Now we have a more complex project, where I need to have additional modules: - JPA package - client interfaces for an automated tester application

So I have started creating the following projects in eclipse:

  • Client project
  • JPA project referencing the client project
  • EJB project referencing both client and JPA projects
  • WAR project, that should use services from the EJB project and pojo classes from JPA project
  • EAR project holding all of this

Packing the project together, I am facing different problems:

  • "A cycle was detected in the build path of project..." because multiple projects are referencing the client project, and it is packaged to the EAR
  • Error in annotation processing: {0}. java.lang.NoClassDefFoundError

I was trying to solve these problems. I have come up with solutions, but neither of them works. Ex 1.: I have simplified the packing to only the JPA + Client + EAR, but this also gives me the cycle detected error. When I turn the error off, I get the 2nd error.

Ex 2.: Tried to simplify build path dependencies, but no luck.

I have also been thinking of merging the EJB + JPA projects, maybe that will work.

But my question is: using Eclipse for development, what is the desired (project and dependency) structure for an EAR app containing client interfaces, ejbs, jpa entities and a standalone tester app using only the client interfaces?

Thanks for your help!


Solution

  • First of all, for your components you won't need an EAR file, a WAR file is sufficient for Java EE 6 applications (see Java EE 6 tutorial on that topic).

    Second, my recommendation is not using the project layout created by the eclipse wizard, but use a maven-based archetype (e.g. Knappsack Archetypes), which will give you an easier and standardized layout.