5

I have three modules named core, common and item and each module is a child module to the Maven project. I'm using ServiceLoader to achieve a service approach and Java 11 with fontawesomefx 11 (lastest).

I have not worked with Java's module system, so I have no idea if I'm doing it correct with the module-info files. Nevertheless, the core and item module both requires a module of fontawesomefx and it results with this error:

Error occurred during initialization of boot layer
java.lang.LayerInstantiationException: Package license in both module de.jensd.fx.fontawesomefx.materialicons and module de.jensd.fx.fontawesomefx.materialdesignicons

module-info for all submodules:

module common {
    requires javafx.graphics;
    requires javafx.controls;
    requires de.jensd.fx.fontawesomefx.commons;
    exports common.abstractions;
    exports common.services;
    exports common.sidebar;
    opens common.services;
}

module core {
    requires common;
    requires javafx.controls;
    requires javafx.fxml;
    requires de.jensd.fx.fontawesomefx.materialdesignicons;
    uses common.services.ISidebarPlugin;
    exports core.ui to javafx.graphics;
    exports core.ui.mainpage to javafx.fxml;
    exports core.ui.sidebar to javafx.fxml;
    opens core.ui.mainpage to javafx.fxml;
    opens core.ui.sidebar to javafx.fxml;
}

module item {
    requires common;
    requires de.jensd.fx.fontawesomefx.materialicons;
    provides common.services.ISidebarPlugin with item.sidebar.ItemSidebarPlugin;
}

If I remove the provides common.services.ISidebarPlugin with item.sidebar.ItemSidebarPlugin; the application works, but without the item module because the implementation will not be loaded by the ServiceLoader.

treeden
  • 675
  • 1
  • 6
  • 17
  • What version of `fontawesomefx' are you using? – José Pereda Mar 30 '19 at 21:03
  • @JoséPereda - I am using [version 11](https://bintray.com/jerady/maven/FontAwesomeFX/11.0.0) of fontawesomefx. Updated question. – treeden Mar 30 '19 at 21:08
  • 1
    It looks like a bug to me: the `fontawesomefx-*` jars (except `commons`) contain a `license` folder with the license text file. This is not in the [source code](https://bitbucket.org/Jerady/fontawesomefx/src/6cbf97484669/fontawesomefx/?at=master), so it might have been added when publishing the artifacts. With modules, you can't have two modules having the same package name (see `split packages`), even if it is just an innocent license folder. I don't see a quick fix for this. An issue should be filed [here](https://bitbucket.org/Jerady/fontawesomefx/issues?status=new&status=open). – José Pereda Mar 30 '19 at 22:03
  • I see both folders. Thanks for answer! – treeden Mar 31 '19 at 08:02

1 Answers1

0

Since I faced the same issue, but home made and not from a dependency, I'll write a quick answer:

The cause of this issue is that two modules contain the same package. The important thing is that any folder (except for META-INF) that is found in the JAR is considered a package - even if it's just a license folder. In your case, this seems to be caused by a badly packaged dependency.

In my case, as said earlier, it was homemade. I have a plugin which injects license info into my JAR and it also injected it to the same place everywhere. I thus had to configure the plugin separately for each module of my build such that it's injected into a different package for each module.

vatbub
  • 2,713
  • 18
  • 41