I have a modules
folder with a content of
antlr-runtime-3.5.2.jar
antlr4-4.8-1.jar
antlr4-runtime-4.8-1.jar
byte-buddy-1.10.10.jar
classmate-1.5.1.jar
cxf-core-3.4.1.jar
dom4j-2.1.3.jar
FastInfoset-1.2.13.jar
gmbal-4.0.1.jar
ha-api-3.1.12.jar
hibernate-commons-annotations-5.1.0.Final.jar
hibernate-core-6.0.0.Alpha6.jar
icu4j-61.1.jar
istack-commons-runtime-3.0.5.jar
jakarta.activation-1.2.2.jar
jakarta.activation-api-1.2.2.jar
jakarta.annotation-api-1.3.5.jar
jakarta.jws-api-2.1.0.jar
jakarta.transaction-api-1.3.3.jar
jakarta.xml.bind-api-2.3.3.jar
jakarta.xml.soap-api-1.4.2.jar
jakarta.xml.ws-api-2.3.3.jar
jandex-2.1.3.Final.jar
javax.activation-api-1.2.0.jar
javax.json-1.0.4.jar
javax.persistence-api-2.2.jar
jaxb-impl-2.3.3.jar
jaxws-rt-2.3.3.jar
jboss-logging-3.3.2.Final.jar
jboss-rmi-api_1.0_spec-1.0.6.Final.jar
jboss-transaction-api_1.2_spec-1.1.1.Final.jar
log4j-api-2.14.0.jar
log4j-core-2.14.0.jar
log4j-slf4j-impl-2.14.0.jar
management-api-3.2.2.jar
mimepull-1.9.13.jar
org.abego.treelayout.core-1.0.3.jar
pfl-basic-4.1.0.jar
pfl-tf-4.1.0.jar
policy-2.7.10.jar
saaj-impl-1.5.2.jar
slf4j-api-1.7.25.jar
ST4-4.3.jar
stax-ex-1.7.8.jar
stax2-api-4.1.jar
streambuffer-1.5.9.jar
txw2-2.3.0.jar
woodstox-core-6.2.1.jar
xmlschema-core-2.2.5.jar
after executing the command
jlink --module-path="[path_]\target\modules" --compress=2 --add-modules=java.persistence,java.activation,spring.context,spring.beans,org.apache.cxf.core,java.xml,java.xml.bind,slf4j.api --no-header-files --no-man-pages --verbose --output="C:\Users\test\out"
I get an error saying
Error: Two versions of module jakarta.activation found in [path_]\target\modules (jakarta.activation-api-1.2.2.jar and jakarta.activation-1.2.2.jar)
Strange thing is that when I remove jakarta.activation-api-1.2.2.jar
or jakarta.activation-1.2.2.jar
Java then starts complaining
Error: Module java.activation not found
My module-info.java
file
module my.module.test {
requires java.persistence;
requires java.activation;
requires spring.context;
requires spring.beans;
requires org.apache.cxf.core;
requires java.xml;
requires java.xml.bind;
requires slf4j.api;
}
My dependencies
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<jaxb-and-jaxws-lib.version>2.3.3</jaxb-and-jaxws-lib.version>
<logging.version>2.14.0</logging.version>
<junit-jupiter-api.version>5.7.0</junit-jupiter-api.version>
<junit-jupiter-params.version>5.7.0</junit-jupiter-params.version>
<mockito-junit-jupiter.version>3.5.10</mockito-junit-jupiter.version>
<cxf-xjc-plugin.version>3.3.1</cxf-xjc-plugin.version>
<maven.compiler.plugin>3.8.1</maven.compiler.plugin>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
<hibernate-core.version>6.0.0.Alpha6</hibernate-core.version>
<hibernate-commons-annotations.version>5.1.2.Final</hibernate-commons-annotations.version>
<cxf-core.version>3.4.1</cxf-core.version>
<spring-context.version>5.3.1</spring-context.version>
<jakarta.transaction-api.version>1.3.3</jakarta.transaction-api.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-core.version}</version>
</dependency>
<dependency>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
<version>${jakarta.transaction-api.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-context.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>${cxf-core.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${logging.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>${jaxb-and-jaxws-lib.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>${jaxb-and-jaxws-lib.version}</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit-jupiter-params.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${logging.version}</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${logging.version}</version>
</dependency>
</dependencies>
IntelliJ module-info.java
is complaining about java.xml.bind
, but does not fail upon compilation, but for some reasons Jlink is failing. How to resolve this situation, so that I could build a custom JRE with Jlink?
Update no. 1
I'm using
IntelliJ IDEA 2020.3.1 (Community Edition)
Java jdk-11.0.9.1+1
Update no.2
mvn dependency:tree
output
[INFO] +- org.hibernate.orm:hibernate-core:jar:6.0.0.Alpha6:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.10.10:compile
[INFO] | +- org.antlr:antlr4:jar:4.8-1:compile
[INFO] | | +- org.antlr:antlr4-runtime:jar:4.8-1:compile
[INFO] | | +- org.antlr:antlr-runtime:jar:3.5.2:compile
[INFO] | | +- org.antlr:ST4:jar:4.3:compile
[INFO] | | +- org.abego.treelayout:org.abego.treelayout.core:jar:1.0.3:compile
[INFO] | | +- org.glassfish:javax.json:jar:1.0.4:compile
[INFO] | | \- com.ibm.icu:icu4j:jar:61.1:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.1.1.Final:compile
[INFO] | +- org.jboss:jandex:jar:2.1.3.Final:compile
[INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | +- org.dom4j:dom4j:jar:2.1.3:compile
[INFO] | \- org.hibernate.common:hibernate-commons-annotations:jar:5.1.0.Final:compile
[INFO] +- jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile
[INFO] +- org.springframework:spring-context:jar:5.3.1:provided
[INFO] | +- org.springframework:spring-aop:jar:5.3.1:provided
[INFO] | +- org.springframework:spring-beans:jar:5.3.1:provided
[INFO] | +- org.springframework:spring-core:jar:5.3.1:provided
[INFO] | | \- org.springframework:spring-jcl:jar:5.3.1:provided
[INFO] | \- org.springframework:spring-expression:jar:5.3.1:provided
[INFO] +- javax.xml.bind:jaxb-api:jar:2.3.0:compile
[INFO] +- org.apache.cxf:cxf-core:jar:3.4.1:compile
[INFO] | +- com.fasterxml.woodstox:woodstox-core:jar:6.2.1:compile
[INFO] | +- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.5:compile
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | +- jakarta.jws:jakarta.jws-api:jar:2.1.0:compile
[INFO] | +- jakarta.xml.soap:jakarta.xml.soap-api:jar:1.4.2:compile
[INFO] | +- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] | +- com.sun.xml.messaging.saaj:saaj-impl:jar:1.5.2:runtime
[INFO] | \- org.jboss.spec.javax.rmi:jboss-rmi-api_1.0_spec:jar:1.0.6.Final:compile
[INFO] +- org.glassfish.jaxb:jaxb-runtime:jar:2.3.0:runtime
[INFO] | +- org.glassfish.jaxb:jaxb-core:jar:2.3.0:runtime
[INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.0:runtime
[INFO] | | \- com.sun.istack:istack-commons-runtime:jar:3.0.5:runtime
[INFO] | +- org.jvnet.staxex:stax-ex:jar:1.7.8:compile
[INFO] | \- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.13:compile
[INFO] +- jakarta.xml.ws:jakarta.xml.ws-api:jar:2.3.3:compile
[INFO] +- com.sun.xml.ws:jaxws-rt:jar:2.3.3:compile
[INFO] | +- com.sun.xml.ws:policy:jar:2.7.10:compile
[INFO] | +- com.sun.xml.bind:jaxb-impl:jar:2.3.3:compile
[INFO] | +- org.glassfish.ha:ha-api:jar:3.1.12:compile
[INFO] | +- org.glassfish.external:management-api:jar:3.2.2:compile
[INFO] | +- org.glassfish.gmbal:gmbal:jar:4.0.1:compile
[INFO] | +- org.glassfish.pfl:pfl-tf:jar:4.1.0:compile
[INFO] | +- org.glassfish.pfl:pfl-basic:jar:4.1.0:compile
[INFO] | +- com.sun.xml.stream.buffer:streambuffer:jar:1.5.9:compile
[INFO] | +- org.jvnet.mimepull:mimepull:jar:1.9.13:compile
[INFO] | \- org.codehaus.woodstox:stax2-api:jar:4.1:compile
[INFO] +- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.14.0:compile
[INFO] +- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.14.0:compile
[INFO] +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.14.0:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.junit.jupiter:junit-jupiter-params:jar:5.7.0:test
[INFO] | \- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.7.0:test
[INFO] | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | \- org.junit.platform:junit-platform-commons:jar:1.7.0:test
[INFO] \- org.mockito:mockito-junit-jupiter:jar:3.5.10:test
[INFO] \- org.mockito:mockito-core:jar:3.5.10:test
[INFO] +- net.bytebuddy:byte-buddy-agent:jar:1.10.13:test
[INFO] \- org.objenesis:objenesis:jar:3.1:test
Update no.3
modules
folder is created from maven-dependency-plugin
(configuration source: java 10 migration)
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/modules</outputDirectory>
<includeScope>runtime</includeScope>
<excludeArtifactIds>spring-boot-devtools,jaxb-api,jaxb-core,jaxb-runtime</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>