Java 9 - modularisation with Jigsaw

Answered

hi there,

we do start a new project. backend with three layers (endpoints, business, persistence). spring boot application with maven, junit 5 tests on each layer and integration tests. we work with java 9. for a rough project setup we ignored the modularisation with module-info.java. now i try to make use of the Jigsaw modularisation and added the module info to each backend layer and let intellij help me to define the requires and exports. so far so good. i do have some failing tests at the moment but maven seems to build it and is OK with it. however, if i build the project in intellij it fails. if i try to start my junit tests out of intellij, it fails to. i am confused, maven seems to have different java parameters than intellij.

Error:java: the unnamed module reads package javax.annotation from both java.annotation and jsr305
Error:java: the unnamed module reads package org.json from both jsonassert and android.json
Error:java: the unnamed module reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: the unnamed module reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module spring.data.jpa reads package javax.annotation from both java.annotation and jsr305
Error:java: module spring.data.jpa reads package org.json from both jsonassert and android.json
Error:java: module spring.data.jpa reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module spring.data.jpa reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module spring.context reads package javax.annotation from both java.annotation and jsr305
Error:java: module spring.context reads package org.json from both jsonassert and android.json
Error:java: module spring.context reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module spring.context reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module spring.beans reads package javax.annotation from both java.annotation and jsr305
Error:java: module spring.beans reads package org.json from both jsonassert and android.json
Error:java: module spring.beans reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module spring.beans reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module spring.boot.starter.data.jpa reads package javax.annotation from both java.annotation and jsr305
Error:java: module spring.boot.starter.data.jpa reads package org.json from both jsonassert and android.json
Error:java: module spring.boot.starter.data.jpa reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module spring.boot.starter.data.jpa reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module spring.boot.starter reads package javax.annotation from both java.annotation and jsr305
Error:java: module spring.boot.starter reads package org.json from both jsonassert and android.json
Error:java: module spring.boot.starter reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module spring.boot.starter reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module spring.boot.starter.logging reads package javax.annotation from both java.annotation and jsr305
Error:java: module spring.boot.starter.logging reads package org.json from both jsonassert and android.json
Error:java: module spring.boot.starter.logging reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module spring.boot.starter.logging reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module logback.classic reads package javax.annotation from both java.annotation and jsr305
Error:java: module logback.classic reads package org.json from both jsonassert and android.json
Error:java: module logback.classic reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module logback.classic reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module logback.core reads package javax.annotation from both java.annotation and jsr305
Error:java: module logback.core reads package org.json from both jsonassert and android.json
Error:java: module logback.core reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module logback.core reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module org.apache.logging.slf4j reads package javax.annotation from both java.annotation and jsr305
Error:java: module org.apache.logging.slf4j reads package org.json from both jsonassert and android.json
Error:java: module org.apache.logging.slf4j reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module org.apache.logging.slf4j reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module jul.to.slf4j reads package javax.annotation from both java.annotation and jsr305
Error:java: module jul.to.slf4j reads package org.json from both jsonassert and android.json
Error:java: module jul.to.slf4j reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module jul.to.slf4j reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module java.annotation reads package javax.annotation from both java.annotation and jsr305
Error:java: module java.annotation reads package org.json from both jsonassert and android.json
Error:java: module java.annotation reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module java.annotation reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module spring.boot.starter.aop reads package javax.annotation from both java.annotation and jsr305
Error:java: module spring.boot.starter.aop reads package org.json from both jsonassert and android.json
Error:java: module spring.boot.starter.aop reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module spring.boot.starter.aop reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module aspectjweaver reads package javax.annotation from both java.annotation and jsr305
Error:java: module aspectjweaver reads package org.json from both jsonassert and android.json
Error:java: module aspectjweaver reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module aspectjweaver reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module spring.boot.starter.jdbc reads package javax.annotation from both java.annotation and jsr305
Error:java: module spring.boot.starter.jdbc reads package org.json from both jsonassert and android.json
Error:java: module spring.boot.starter.jdbc reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module spring.boot.starter.jdbc reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module com.zaxxer.hikari reads package javax.annotation from both java.annotation and jsr305
Error:java: module com.zaxxer.hikari reads package org.json from both jsonassert and android.json
Error:java: module com.zaxxer.hikari reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module com.zaxxer.hikari reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module spring.jdbc reads package javax.annotation from both java.annotation and jsr305
Error:java: module spring.jdbc reads package org.json from both jsonassert and android.json
Error:java: module spring.jdbc reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module spring.jdbc reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module hibernate.core reads package javax.annotation from both java.annotation and jsr305
Error:java: module hibernate.core reads package org.json from both jsonassert and android.json
Error:java: module hibernate.core reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module hibernate.core reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module org.jboss.logging reads package javax.annotation from both java.annotation and jsr305
Error:java: module org.jboss.logging reads package org.json from both jsonassert and android.json
Error:java: module org.jboss.logging reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module org.jboss.logging reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module javassist reads package javax.annotation from both java.annotation and jsr305
Error:java: module javassist reads package org.json from both jsonassert and android.json
Error:java: module javassist reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module javassist reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module antlr reads package javax.annotation from both java.annotation and jsr305
Error:java: module antlr reads package org.json from both jsonassert and android.json
Error:java: module antlr reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module antlr reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module jandex reads package javax.annotation from both java.annotation and jsr305
Error:java: module jandex reads package org.json from both jsonassert and android.json
Error:java: module jandex reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module jandex reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module com.fasterxml.classmate reads package javax.annotation from both java.annotation and jsr305
Error:java: module com.fasterxml.classmate reads package org.json from both jsonassert and android.json
Error:java: module com.fasterxml.classmate reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module com.fasterxml.classmate reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module dom4j reads package javax.annotation from both java.annotation and jsr305
Error:java: module dom4j reads package org.json from both jsonassert and android.json
Error:java: module dom4j reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module dom4j reads package javax.transaction.xa from both java.sql and javax.transaction.api
Error:java: module hibernate.commons.annotations reads package javax.annotation from both java.annotation and jsr305
Error:java: module hibernate.commons.annotations reads package org.json from both jsonassert and android.json
Error:java: module hibernate.commons.annotations reads package org.hamcrest from both hamcrest.core and hamcrest.library
Error:java: module hibernate.commons.annotations reads package javax.transaction.xa from both java.sql and javax.transaction.api

 

some of these problems might have lead to a split package. however, maven seams to be ok whit it and intellij not.

 

What do I have to configure to run my intellij in a similar  way as my shell command "mnv install", "mvn ..."?

 

thanks four your assistance!

0
5 comments

What version of maven-compiler-plugin do you use? Try using the latest version, it may report the issues with Java 9 modules better.

0
Avatar
Permanently deleted user

Hi, I have the same issue - did you manage to resolve it?

0

@Adam, try using --patch-module option, like suggested here: https://blog.codefx.org/java/jsr-305-java-9/

If you see the issue only when compiling in IDE and command line (Maven or Gradle) works fine, please file an issue with the sample project at https://youtrack.jetbrains.com/issues/IDEA.

0
Avatar
Permanently deleted user

I am facing the same issue as well. Is there some more information about this behavior?

0

Please sign in to leave a comment.