Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
laurentschoelens opened this issue Dec 14, 2023 · 8 comments · Fixed by #543
Closed

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

laurentschoelens opened this issue Dec 14, 2023 · 8 comments · Fixed by #543
Assignees
Labels
bug xjc-plugins Issue concerns basics plugins
Milestone

Comments

@laurentschoelens
Copy link
Collaborator

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 laurentschoelens added bug xjc-plugins Issue concerns basics plugins labels Dec 14, 2023
@laurentschoelens laurentschoelens added this to the 2.0.10 milestone Dec 14, 2023
@laurentschoelens
Copy link
Collaborator Author

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

@laurentschoelens
Copy link
Collaborator Author

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

@laurentschoelens
Copy link
Collaborator Author

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 added a commit to laurentschoelens/jaxb-tools that referenced this issue Apr 19, 2024
laurentschoelens added a commit to laurentschoelens/jaxb-tools that referenced this issue Jun 10, 2024
laurentschoelens added a commit to laurentschoelens/jaxb-tools that referenced this issue Jun 10, 2024
@laurentschoelens
Copy link
Collaborator Author

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

@carlmolemans
Copy link

carlmolemans commented Jul 22, 2024

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

Does not exist? Was this just a fork?

@laurentschoelens
Copy link
Collaborator Author

@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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

Tested OK with last 2.0.13 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment