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

Working support for Jakarta version of XJC #129

Closed
wants to merge 1 commit into from

Conversation

sebersole
Copy link

Working support for Jakarta XJC

@sebersole
Copy link
Author

I had to skip tests in order to build this. The tests explicitly use some com.sun references and I am not sure how to address those. But I have verified that the resulting artifacts work in my build (through one of my Gradle plugins)

<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
Copy link

@lukasj lukasj Sep 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for activation v 2.0.x, I'd avoid changing this to an API artifact as it can do more harm than good - com.sun.activation may conflict with jakarta.activation on JPMS. This change is fine with activation-api 2.1.0 (currently RC1); an implementation is ie angus-activation, currently at 1.0.0-M1.

For now, my recommendation is to use com.sun.activation:jakarta.activation:2.0.1 if one needs stable version

Copy link
Author

@sebersole sebersole Sep 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worked with your suggestion. But at least for my build, it worked with what I had also.

Copy link

@lukasj lukasj Sep 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, in "classpath-only" cases it works Try to put the JAXB RI and its dependencies + jakarta.activation-api on the module path. Or simply just the API and Impl (API jar contains references to classes which are not available in the API jar itself, so whoever tries to use it, may get NoClassDefFoundError at some point, and both jars contain same API packages - split package problem) - in general not a big deal for jaxb as such; it's bigger problem for projects built on top of it or using it.

<version>${activation.version}</version>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.0.1</version>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now 2.1.0 already exists.

@JWT007
Copy link

JWT007 commented Sep 18, 2022

Sorry to jump in here as I am not a contributor :/

I am trying to use @sebersole 's fork as a temporary solution to the jakarta problem with the equals/hashcode/toString plugins. It also seems to be working for me - thanks a million for that! :)

I did notice a few things which might be added under "cleanup" :)

  • I switched everything to the "com.sun.activation:jakarta.activation:2.0.1" as recommended above.
  • in the samples there are still references in the POMs to "javax.activation" (project-pom.xml)
  • in the samples the ant compile paths might need to be adjusted (project-build.xml) for jakarta JARs.
  • Update Readme to indicate JAXB 3.* implementation?
  • one UnitTest was not working for me:
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.167 s <<< FAILURE! - in org.jvnet.jaxb2_commons.xjc.model.concrete.tests.alpha.AlphaMInfoFactoryTest
[ERROR] org.jvnet.jaxb2_commons.xjc.model.concrete.tests.alpha.AlphaMInfoFactoryTest  Time elapsed: 0.167 s  <<< ERROR!
java.lang.IllegalArgumentException: can't parse argument number: ''https://jakarta.ee/xml/ns/jaxb''
	at org.jvnet.jaxb2_commons.xjc.model.concrete.tests.alpha.AlphaMInfoFactoryTest.createModel(AlphaMInfoFactoryTest.java:50)
Caused by: java.lang.NumberFormatException: For input string: "''https://jakarta.ee/xml/ns/jaxb''"
	at org.jvnet.jaxb2_commons.xjc.model.concrete.tests.alpha.AlphaMInfoFactoryTest.createModel(AlphaMInfoFactoryTest.java:50)

I managed to fix this unit test by updating the JAXB namespace and version in both the binding.xjb and schema.xsd files:

<jaxb:bindings version="3.0" xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
	jaxb:extensionBindingPrefixes="xjc" xmlns:test="urn:test">
<xsd:schema targetNamespace="urn:test" xmlns:test="urn:test"
						xmlns:xsd="http://www.w3.org/2001/XMLSchema"
						xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
						elementFormDefault="qualified"
						attributeFormDefault="unqualified"
						jaxb:version="3.0"
						xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
						jaxb:extensionBindingPrefixes="xjc">

@laurentschoelens
Copy link
Collaborator

This has been done in jaxb-tools v3 and above
Thanks for the initial PR

@sebersole
Copy link
Author

V3 or v4?

According to https://github.com/highsource/jaxb-tools

The current version 4.X of this plugin supports only JAXB 4.X (Jakarta based).

Versions 2.X and 3.X supports JAXB 2.3 and JAXB 3.0 with JDK8 support and baseline

@laurentschoelens
Copy link
Collaborator

laurentschoelens commented Feb 10, 2024

@sebersole :

  • v2 support JAXB v2.3 (JavaEE8)
  • v3 support JAXB v3 with JDK8 baseline (JakartaEE9)
  • v4 support JAXB v4 with JDK11 baseline (JakartaEE8)

So both v3 and v4 are concerned

Maybe information is clearer on migration guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants