Correcting cyclical dependencies after an EAR is imported

You can resolve cyclical dependencies after an EAR is imported.

A cyclical dependency between two or more modules in an enterprise application most commonly occurs when projects are imported from outside the workbench. When a cycle exists between two or more modules in an enterprise application, the Java™ builder cannot accurately compute the build order of the projects. Full builds fail under these conditions, or require several invocations.

Therefore, the best practice is to organize your projects or modules into components. This allows your module dependencies to function as a tree instead of a cycle diagram. This practice has the added benefit of producing a better factored and layered application.

To reorganize your project to correct cyclical dependencies, complete the following steps:

  1. Identify all the classes within the JAR files that have cyclical dependencies and move those classes into a common Java project or JAR file.
  2. Use the enterprise application editor to map utility JAR files to the common projects.
  3. For each module of the JAR in the application, use the JAR dependency editor or properties page to set dependencies only to the JAR files that are truly required.

Related concepts
Cyclical dependencies between Java EE modules
Related tasks
Importing an enterprise application EAR file