0

I have three maven modules:

Client

Server

RMIInterface

My problem is, that the Client and Server needs the RMIInterface, but the RMIInterface also needs some classes from the server project.

Now I get an error because the Server and the RMIInterface generate a dependency cycle.

RMIInterface pom

<parent>
    <artifactId>BibliothekWS2017</artifactId>
    <groupId>at.fhv.team05</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>RMIInterface</artifactId>
<!--RMI Interface Dependency-->
<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>BibliothekWS2017Server</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

Dependency in Server and Client

   <!--RMI Interface Dependency-->
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>RMIInterface</artifactId>
        <version>${project.version}</version>
    </dependency>
Prokyon
  • 128
  • 7
  • Possible Duplicate: https://stackoverflow.com/questions/16468525/how-to-resolve-maven-cyclic-dependency – DragonAssassin Oct 30 '17 at 14:39
  • 2
    If your `RMIInterface` module and `Server` module need each other, it means this should be one module or you have a conception issue. IMO, it looks like conception issue because `RMIInterface` shouldn't be aware of your implementation `Server`. – Mickael Oct 30 '17 at 14:39
  • @MickaëlB both client and server need the RMIInterface, but I think the problem is, that I want to use the domain objects in the RMIInterface, so I should make new interfaces which are implemented by the domain object and use those new interfaces instead of the domain object? – Prokyon Oct 30 '17 at 14:46
  • @Prokyon That sounds like a good approach. – J Fabian Meier Oct 30 '17 at 15:27
  • 2
    You should have all common code from the interface in the same repository. Think like this, each dependency consists of a jar file. So the dependencies are actually which jar files you want to add to your project. The advantage of having a clean interface is that it can be implemented quite freely. The disadvantage is that you will have to expose a larger part of the interface. This does however make sense from a practical point of view. The more general interface, the more the implementing libraries have to customize (high level or low level interfaces). – patrik Oct 30 '17 at 15:41

1 Answers1

0

the RMIInterface also needs some classes from the server project.

So those classes should be in the RMIInterface project, not the server project. The remote interface and everything it depends on, recursively until closure, should be in the common project.

And surely the client will need those classes too?

user207421
  • 305,947
  • 44
  • 307
  • 483