Class collision between old jaxb2-basics-runtime and new one
We have same classes in same packages in both jaxb2-basics-runtime (the one with previous groupId and the one with the current one).
Since groupId differs, having the new one does not override the older one and it can leads to ClassCastException if all the classes are not loaded from the same jar.
We should provide a way to override the older one with maybe like an empty jar with older groupId to make sure all classes are defined only once
New project to handle this : https://github.com/laurentschoelens/jaxb2-basics-empty
Include empty like project (same as above) in main branch so we can then include it in v2.x
Adding the following in org.jvnet.jaxb:jaxb2-basics-runtime
:
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>[4.0.0,9999.0)</version>
</dependency>
and having a project including 2 projects, one with old runtime and one with new runtime as dependencies, result in the following mvn dependencies:tree
| Before | After |
maven |
[INFO] --- dependency:3.6.0:tree (default-cli) @ jaxb2-basics-test-po-mixed-runtime ---
[INFO] org.jvnet.jaxb:jaxb2-basics-test-po-mixed-runtime:jar:2.0.10-SNAPSHOT
[INFO] +- org.jvnet.jaxb:jaxb2-basics-test-po:jar:2.0.10-SNAPSHOT:compile
[INFO] | +- org.jvnet.jaxb:jaxb2-basics-runtime:jar:2.0.10-SNAPSHOT:compile
[INFO] | +- org.glassfish.jaxb:jaxb-runtime:jar:2.3.9:compile
[INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.9:compile
[INFO] | | \- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
[INFO] | \- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] +- org.jvnet.jaxb:jaxb2-basics-test-po-old-runtime:jar:2.0.10-SNAPSHOT:compile
[INFO] | \- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.13.1:compile
[INFO] \- junit:junit:jar:4.13.2:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test
|
[INFO] --- dependency:3.6.0:tree (default-cli) @ jaxb2-basics-test-po-mixed-runtime ---
[INFO] org.jvnet.jaxb:jaxb2-basics-test-po-mixed-runtime:jar:2.0.10-SNAPSHOT
[INFO] +- org.jvnet.jaxb:jaxb2-basics-test-po:jar:2.0.10-SNAPSHOT:compile
[INFO] | +- org.jvnet.jaxb:jaxb2-basics-runtime:jar:2.0.10-SNAPSHOT:compile
[INFO] | | \- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:4.0.7-SNAPSHOT:compile
[INFO] | +- org.glassfish.jaxb:jaxb-runtime:jar:2.3.9:compile
[INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.9:compile
[INFO] | | \- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
[INFO] | \- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] +- org.jvnet.jaxb:jaxb2-basics-test-po-old-runtime:jar:2.0.10-SNAPSHOT:compile
[INFO] \- junit:junit:jar:4.13.2:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test
|
gradle |
compileClasspath - Compile classpath for source set 'main'.
+--- org.jvnet.jaxb:jaxb2-basics-test-po:2.0.10-SNAPSHOT
| +--- org.jvnet.jaxb:jaxb2-basics-runtime:2.0.10-SNAPSHOT
| +--- org.glassfish.jaxb:jaxb-runtime:2.3.9
| | +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.3
| | +--- org.glassfish.jaxb:txw2:2.3.9
| | \--- com.sun.istack:istack-commons-runtime:3.0.12
| \--- com.sun.activation:jakarta.activation:1.2.2
\--- org.jvnet.jaxb:jaxb2-basics-test-po-old-runtime:2.0.10-SNAPSHOT
+--- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:0.13.1
+--- org.glassfish.jaxb:jaxb-runtime:2.3.9 (*)
+--- org.jvnet.jaxb:jaxb2-basics-runtime:2.0.10-SNAPSHOT
\--- com.sun.activation:jakarta.activation:1.2.2
|
compileClasspath - Compile classpath for source set 'main'.
+--- org.jvnet.jaxb:jaxb2-basics-test-po:2.0.10-SNAPSHOT
| +--- org.jvnet.jaxb:jaxb2-basics-runtime:2.0.10-SNAPSHOT
| | \--- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:[4.0.0,9999.0) -> 4.0.7-SNAPSHOT
| +--- org.glassfish.jaxb:jaxb-runtime:2.3.9
| | +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.3
| | +--- org.glassfish.jaxb:txw2:2.3.9
| | \--- com.sun.istack:istack-commons-runtime:3.0.12
| \--- com.sun.activation:jakarta.activation:1.2.2
\--- org.jvnet.jaxb:jaxb2-basics-test-po-old-runtime:2.0.10-SNAPSHOT
+--- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:0.13.1 -> 4.0.7-SNAPSHOT
+--- org.glassfish.jaxb:jaxb-runtime:2.3.9 (*)
+--- org.jvnet.jaxb:jaxb2-basics-runtime:2.0.10-SNAPSHOT (*)
\--- com.sun.activation:jakarta.activation:1.2.2
|
Created new PR (#543) and adding the following in org.jvnet.jaxb:jaxb2-basics-runtime
(which is done in PR) :
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>[2.0.0,9999.0)</version>
</dependency>
and having a project including 2 projects, one with old runtime and one with new runtime as dependencies, result in the following mvn dependencies:tree
| Before | After |
maven |
[INFO] --- dependency:3.6.0:tree (default-cli) @ jaxb2-basics-test-po-mixed-runtime ---
[INFO] org.jvnet.jaxb:jaxb2-basics-test-po-mixed-runtime:jar:2.0.10-SNAPSHOT
[INFO] +- org.jvnet.jaxb:jaxb2-basics-test-po:jar:2.0.10-SNAPSHOT:compile
[INFO] | +- org.jvnet.jaxb:jaxb2-basics-runtime:jar:2.0.10-SNAPSHOT:compile
[INFO] | +- org.glassfish.jaxb:jaxb-runtime:jar:2.3.9:compile
[INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.9:compile
[INFO] | | \- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
[INFO] | \- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] +- org.jvnet.jaxb:jaxb2-basics-test-po-old-runtime:jar:2.0.10-SNAPSHOT:compile
[INFO] | \- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.13.1:compile
[INFO] \- junit:junit:jar:4.13.2:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test
|
[INFO] --- dependency:3.6.0:tree (default-cli) @ jaxb2-basics-test-po-mixed-runtime ---
[INFO] org.jvnet.jaxb:jaxb2-basics-test-po-mixed-runtime:jar:2.0.10-SNAPSHOT
[INFO] +- org.jvnet.jaxb:jaxb2-basics-test-po:jar:2.0.10-SNAPSHOT:compile
[INFO] | +- org.jvnet.jaxb:jaxb2-basics-runtime:jar:2.0.10-SNAPSHOT:compile
[INFO] | | \- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:2.0.10-SNAPSHOT:compile
[INFO] | +- org.glassfish.jaxb:jaxb-runtime:jar:2.3.9:compile
[INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.9:compile
[INFO] | | \- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
[INFO] | \- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] +- org.jvnet.jaxb:jaxb2-basics-test-po-old-runtime:jar:2.0.10-SNAPSHOT:compile
[INFO] \- junit:junit:jar:4.13.2:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test
|
gradle |
compileClasspath - Compile classpath for source set 'main'.
+--- org.jvnet.jaxb:jaxb2-basics-test-po:2.0.10-SNAPSHOT
| +--- org.jvnet.jaxb:jaxb2-basics-runtime:2.0.10-SNAPSHOT
| +--- org.glassfish.jaxb:jaxb-runtime:2.3.9
| | +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.3
| | +--- org.glassfish.jaxb:txw2:2.3.9
| | \--- com.sun.istack:istack-commons-runtime:3.0.12
| \--- com.sun.activation:jakarta.activation:1.2.2
\--- org.jvnet.jaxb:jaxb2-basics-test-po-old-runtime:2.0.10-SNAPSHOT
+--- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:0.13.1
+--- org.glassfish.jaxb:jaxb-runtime:2.3.9 (*)
+--- org.jvnet.jaxb:jaxb2-basics-runtime:2.0.10-SNAPSHOT
\--- com.sun.activation:jakarta.activation:1.2.2
|
compileClasspath - Compile classpath for source set 'main'.
+--- org.jvnet.jaxb:jaxb2-basics-test-po:2.0.10-SNAPSHOT
| +--- org.jvnet.jaxb:jaxb2-basics-runtime:2.0.10-SNAPSHOT
| | \--- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:[2.0.0,9999.0) -> 2.0.10-SNAPSHOT
| +--- org.glassfish.jaxb:jaxb-runtime:2.3.9
| | +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.3
| | +--- org.glassfish.jaxb:txw2:2.3.9
| | \--- com.sun.istack:istack-commons-runtime:3.0.12
| \--- com.sun.activation:jakarta.activation:1.2.2
\--- org.jvnet.jaxb:jaxb2-basics-test-po-old-runtime:2.0.10-SNAPSHOT
+--- org.jvnet.jaxb2_commons:jaxb2-basics-runtime:0.13.1 -> 2.0.10-SNAPSHOT
+--- org.glassfish.jaxb:jaxb-runtime:2.3.9 (*)
+--- org.jvnet.jaxb:jaxb2-basics-runtime:2.0.10-SNAPSHOT (*)
\--- com.sun.activation:jakarta.activation:1.2.2
|
New project to handle this : https://github.com/laurentschoelens/jaxb2-basics-empty
Does not exist? Was this just a fork?
@carlmolemans : this empty project was discontinued and integrated in 2.0.12 release of jaxb-tools.
We need to do a 2.0.13 to restore version's range in jaxb2-basics-runtime
artifact that was replaced during the last release (since both projects where in the same maven build).
If you're facing the same issue as me, you can force the old artifact version to 2.0.12 (which will be empty jar) to solve the class collision issue
Tested OK with last 2.0.13 release