jaxb-tools icon indicating copy to clipboard operation
jaxb-tools copied to clipboard

Class collision between old jaxb2-basics-runtime and new one

Open laurentschoelens opened this issue 1 year ago • 3 comments

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

laurentschoelens avatar Dec 14 '23 12:12 laurentschoelens

New project to handle this : https://github.com/laurentschoelens/jaxb2-basics-empty

laurentschoelens avatar Feb 12 '24 08:02 laurentschoelens

Include empty like project (same as above) in main branch so we can then include it in v2.x

laurentschoelens avatar Apr 18 '24 16:04 laurentschoelens

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

BeforeAfter
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

laurentschoelens avatar Apr 18 '24 16:04 laurentschoelens

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

BeforeAfter
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

laurentschoelens avatar Jun 10 '24 15:06 laurentschoelens

New project to handle this : https://github.com/laurentschoelens/jaxb2-basics-empty

Does not exist? Was this just a fork?

carlmolemans avatar Jul 22 '24 07:07 carlmolemans

@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).

laurentschoelens avatar Jul 22 '24 07:07 laurentschoelens

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

laurentschoelens avatar Jul 22 '24 07:07 laurentschoelens

Tested OK with last 2.0.13 release

laurentschoelens avatar Jul 25 '24 05:07 laurentschoelens