0

I am having a rough time deciphering what these errors mean, let alone even begin to resolve them. I am trying to use java platform modules (using jdk 14) with a simple "gradle-based, multi-module" project (everything works perfectly fine with jdk 8). The project makes use of spring-boot and spring-data-jdbc. Actually my core dependencies are

implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-freemarker'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.projectlombok:lombok'

While I was adding module-info.java to each project source root, my IDE (intellJ) was very kind to give me hints of what modules to export/require, and all looked good until I tred to compile.

I am including a git repo link here to the project that's th topic of this question - https://github.com/m41na/todo-modules-demo

If you have come across these (or similar) issues, could you please shed some light on how you were able to resolve them?

error: the unnamed module reads package org.springframework.data.jdbc.core.convert from both spring.data.jdbc and spring.data.relational
error: module spring.context reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.starter.data.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.starter.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.data.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.starter reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.tx reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.autoconfigure reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.aop reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.expression reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
the unnamed module reads package org.springframework.data.jdbc.core.convert from both spring.data.jdbc and spring.data.relational

error: module spring.core reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.boot.starter.logging reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module logback.classic reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module org.apache.logging.slf4j reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.context reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc

error: module jul.to.slf4j reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module org.slf4j reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.boot.starter.data.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc

error: module java.annotation reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.boot.starter.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc

error: module org.yaml.snakeyaml reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.jcl reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.data.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc

error: module logback.core reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
error: module spring.beans reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.boot.starter reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc

error: module spring.data.relational reads package org.springframework.data.jdbc.core.convert from both spring.data.jdbc and spring.data.relational
module spring.jdbc reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc

error: module spring.data.commons reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
module spring.tx reads package org.springframework.data.jdbc.core.convert from both spring.data.relational and spring.data.jdbc
Stephen Maina
  • 21
  • 1
  • 3
  • 2
    I don't know anything specific about your situation, but the errors you show suggest that you have two jars in your classpath that are contributing packages with the same names, and so the system (the ClassLoader maybe) doesn't know which one to use. `spring.data.relational` and `spring.data.jdbc` are names associated somehow with these jars. I'd be looking for where these names show up in your setup, and maybe try to eliminate one of them. I don't know the specifics of excluding packages in Gradle...I use Maven. – CryptoFool Sep 26 '20 at 00:21
  • „*…If you have come across these (or similar) issues…*“ – @StephenMaina — I recently solved ([***1***](https://github.com/springfox/springfox/issues/2064#issuecomment-687696036)), ([***2***](https://github.com/grpc/grpc-java/issues/3522#issuecomment-679203133)) and ([***3***](https://github.com/lingocoder/springfox.docketyper.demo/issues/1)) with the [*com.lingocoder.mrjar plugin*](https://plugins.gradle.org/plugin/com.lingocoder.mrjar). ULd a [*MRE*](https://stackoverflow.com/help/minimal-reproducible-example) to git hub and I could help you with applying that plugin to fix your MRE. TIA. – deduper Sep 26 '20 at 11:56
  • I see lingocoder has a big disclaimer in red '**Due to a breaking change in Gradle 5.6.1, current versions of mrJar are confirmed to work only with Gradle versions 5.0.0 to 5.5.1'**. That will not work in my case since I'm using gradle 6.5 – Stephen Maina Sep 27 '20 at 17:25
  • For completeness, I am adding a link to the demo project which is the subject of this question - https://github.com/m41na/todo-modules-demo – Stephen Maina Sep 27 '20 at 18:40
  • „*…a big disclaimer…*“ – @StephenMaina — That's just an old doc is all. Since that was written,***mrJar*** v0.0.16 has been successfully tested with [*Gradle 5.6.2, 6.0.x, 6.1.x and 6.6.1*](https://discuss.gradle.org/t/the-mrjar-plugin-v0-0-16-has-been-released-jpms-modules-made-easy/34022). See projects [***4***](https://github.com/lingocoder/mrJardularity/blob/master/gradle/wrapper/gradle-wrapper.properties#L2), [***5***](https://github.com/lingocoder/mrJarLiSong/blob/master/gradle/wrapper/gradle-wrapper.properties#L3) and [***others***](https://github.com/lingocoder/mrJar.java9.modularity). – deduper Sep 28 '20 at 14:59
  • „*…a link to the demo project…*“ – @StephenMaina — Just to give you a heads-up: I got your demo project compiling successfully now thanks to the ***mrJar*** v0.0.16. A little more work needs to be done though. Then I'll push the working demo to github once I've finished. – deduper Sep 29 '20 at 00:31

1 Answers1

1

TL;DR — I've solved your split packages errors in this clone of your project using the mrJar Gradle plugin1.


The long-winded answer

…I am having a rough time deciphering what these errors mean…

Welcome to the world of split packages

…'Split packages' is an old Java term where two packages having the same name exist in different libraries/applications. Java 9 does not allow split packages in different modules for the reason of the reliable configuration…

That quote's from this blog.

…If you have come across these (or similar) issues…

As several other Stack Overflow questions attest, split packages are an inevitability for anybody structuring their projects as JPMS modules.

…could you please shed some light on how you were able to resolve them?…

Referring back to the TL;DR, I've resolved your project's split packages issue by applying the plugin I proposed. Download and build the demo to examine the results.

As I mention in that demo's documentation, Java 14+ support will be added to that plugin within the next day or two. As soon as it is, I will update the demo and edit this answer. But I figured rather than wait until then, you (and other interested lurkers) could benefit today from version 0.0.16's JDK 13 support.

Another solution I recently proposed is an implementation of Mark Reinhold's suggested „Bridges to the class path“ approach. Numbers 2 and 3 that I mentioned in the comments take that approach. But personally I prefer the plugin approach. It's a lot easier and is way less effort.






1 I have it on good authority that the mrJar plugin is in the process of being upgraded with JDK14+ support. Release of v0.0.17 is expected to be announced within the next 1-2 days.

deduper
  • 1,944
  • 9
  • 22
  • This plugin is fantastic!! Thanks a lot for your answer. This unlocks the next step for what I'm working on. And thanks for those links you provided. The information therein is golden. – Stephen Maina Sep 29 '20 at 18:23
  • „*…This plugin is fantastic!!…*“ – @StephenMaina — It is pretty neat. – „*…Thanks a lot for your answer…*“ — My pleasure! Unblocking others is nice. But my main goal in contributing to SO is my own continuous improvement. To that end, I'm desperate to learn: *In what way could my answer be improved in order for you to have marked it as accepted?* I've asked [*that question before*](https://stackoverflow.com/a/63926746/4465539). To no avail. – „*…The information therein is golden…*“ — Your comment suggests my answer helped you. So please can you help *me* now, by answering *my* question? TIA. – deduper Sep 29 '20 at 18:50