jdeveloperjdeveloper-11g

Cross project dependencies and circular dependencies


The Java EE Web Application wizard creates an application structure with two projects:

The way they're linked is that at ViewController/ Project properties/ Dependencies you can find Model as dependency for ViewController. So far so good: I can invoke EJB model entities from my view services.

However, it doesn't seem possible to use a class defined at ViewController from Model. If you set ViewController as dependency for Model you get a nasty warning about circular dependencies.

Warning: Project Model.jpr has a circular dependency with ViewController.jpr. Check your project dependencies.

As far as I know there's nothing in Java itself that prevents programs from doing so. How can you cross project boundaries in both directions when using JDeveloper?


Solution

  • You are talking about different dependencies. The warning is a result of a build dependency, not a Java warning. From Java's point of view, you would only need to add the jar created by the ViewController to the Model to get what you want. The problem is how to tell the build system the order to create the jars. The view jar might need changes that are currently built in the Model and the other way around. So the built might fail too.

    If you need a class in both Model and View, you can either put it directly into the Model or introduce a third project and the dependency of the Modeland View to the third project.