0

I have a Java 9 (or higher) project in which I want to include ORMLite with a H2 database. Therefore I need the two maven dependencies

        <dependency>
            <groupId>com.j256.ormlite</groupId>
            <artifactId>ormlite-core</artifactId>
            <version>5.1</version>
        </dependency>
        <dependency>
            <groupId>com.j256.ormlite</groupId>
            <artifactId>ormlite-jdbc</artifactId>
            <version>5.1</version>
        </dependency>
        ...
        (+ the h2 dependency.)

Since I am using Java 9 I have to add them to my module-info.java:

module my.module {
    exports my.package.to.export;

    requires ormlite.core;
    requires ormlite.jdbc;
    ...

But now I cannot compile the project anymore because both core and jdbc have the same package com.j256.ormlite.db.

[ERROR] module ormlite.core reads package com.j256.ormlite.db from both ormlite.core and ormlite.jdbc

I understand that this is as it should be, because split packages are not allowed. But how do I handle this, since this is not within my power? At least not in a clean way. I want to keep everything in maven and dont want to combine the packages as suggested in another post.

How can I solve this clean?

(I see that this is already an open issue in the orm-lite Github, but I do want to use it now)

Andwari
  • 161
  • 1
  • 12
  • Related: https://stackoverflow.com/questions/42358084/package-conflicts-with-automatic-modules-in-java-9 – Slaw Dec 17 '19 at 20:33
  • I saw that but this doesnt provide a satisfying answer. I dont want to mash around in those jars – Andwari Dec 17 '19 at 21:28
  • 2
    You don't have to use modules; continue using the classpath if necessary. – Slaw Dec 17 '19 at 21:33
  • Oh wow I never thought about that! I thought modules were mandatory to Java 9. Thank you! Still not a nice solution but it saved my project. – Andwari Dec 18 '19 at 06:45
  • The ideal is to eventually always use the modulepath, but they included compatibility with the classpath (i.e. the so-called _unnamed module_) precisely for this reason—libraries which haven't made the necessary changes for migration. Consider reporting the issue to the maintainers of the problematic library if they haven't already been notified. – Slaw Dec 18 '19 at 06:58
  • It is already a known and open issue for over a year. – Andwari Dec 18 '19 at 09:38
  • 1
    Yeah sorry about that. You can certainly download the source and combine the 2 packages and rebuild. I need to restructure but it's going to break backwards compatibility so I've been holding off. – Gray Dec 23 '19 at 14:35

0 Answers0