0

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!

csabee
  • 217
  • 2
  • 12

1 Answers1

0

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.

Alexander Rühl
  • 6,769
  • 9
  • 53
  • 96
  • Hi, WAR isn't enough for me, since we need different war files to access the remote beans packaged in the ear / ejb packets. The other thing: we don't use maven, and currently my development team is too junior one to use it. Also I had some problems with it, and currently we don't have any programmers experienced with maven. – csabee Jul 07 '14 at 09:30
  • Well, Maven requires indeed more knowhow, but I would assume just using it, should be possible for every software engeneer - not to speak of the other advantages you get, such as using it easily with tools like Jenkins. But still, you may create the project from such an archetype and adapt the layout and build artefacts yourself with Ant for example. And for eclipse you can use external tool configurations to start deployment. – Alexander Rühl Jul 07 '14 at 10:34
  • Hi, We have a new programmer, who has just checked these knappsack archetypes. Problem is that they are all packaged as one war file. Since we also need client interface projects to be called by different applications, this structure won't help for us. – csabee Jul 21 '14 at 07:56
  • 1
    @csabee Checkout [this fullblown maven based project layout example](http://www.developerscrappad.com/1177/java/java-ee/maven/building-and-deploying-java-ee-ear-with-maven-to-java-ee-application-server-part-1-project-directory-structure-amp-module-generation-through-archetype-generate/). Or maybe it is sufficient to follow [Adam Bien's modularization example](http://www.adam-bien.com/roller/abien/entry/java_ee_6_ejb_31) and take the jars for client use as well. – Alexander Rühl Jul 21 '14 at 08:23