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

Support for jaxb3 #199

Closed
muued opened this issue Dec 21, 2020 · 6 comments
Closed

Support for jaxb3 #199

muued opened this issue Dec 21, 2020 · 6 comments
Assignees
Milestone

Comments

@muued
Copy link

muued commented Dec 21, 2020

Hi,
I love this plugin and have been using it for many years. With the release of JAXB 3.0.0, I'm interested whether there are any plans to support it. I'm willing to support the development and have already toyed around some in my fork.
As a start, I have tried to gather the relevant changes below.
Please let me know if I can support this project in any way, e.g., by saying something about the desired way to integrate jaxb3 into this project. It seems rather hard to make the core and testing projects jaxb-version-agnostic because of the different package names and dependency coordinates.

requirements towards plugin-development

expect bindings to be in a new namespace

<bindings xmlns="https://jakarta.ee/xml/ns/jaxb" version="3.0">...</bindings>
relevant for RawXJC2Mojo.java and addIfExistsToEpisodeSchemaBindings.xslt

packages

use jakarta.xml.bind.annotation instead of javax.xml.bind.annotation
use org.glassfish.jaxb.core.v2.schemagen.episode instead of com.sun.xml.bind.v2.schemagen.episode

libraries

use jakarta.xml.bind:jakarta.xml.bind-api instead of javax.xml.bind:jaxb-api
update all org.glassfish.jaxb artifacts to version 3.0.0

requirements towards plugin users

binding files need to be updated to the new namespace "https://jakarta.ee/xml/ns/jaxb" and have their version set to "3.0"
<bindings xmlns="https://jakarta.ee/xml/ns/jaxb" version="3.0">...</bindings>
as far as I can tell, the xjc subnamespace hasn't changed

use an updated jaxb runtime, e.g.

<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>3.0.0</version>
</dependency>
@grv87
Copy link

grv87 commented Jan 30, 2021

BTW, I've successfully upgraded jaxb-visitor plugin to JAXB v3 (in internal fork), using current maven-jaxb2-plugin-testing v0.14.0.

The only problem I experience is

[warn] Class [com.sun.tools.xjc.reader.xmlschema.bindinfo.package-info] is missing the [javax.xml.bind.annotation.XmlSchema] annotation. Processing bindings will probably fail.

UPD: jaxb2-basics uses current version for JAXB3 too

@dmak
Copy link

dmak commented Jan 9, 2023

UPD: jaxb2-basics uses current version for JAXB3 too

Minor addendum: As for today jax2-basics you point to is still on JAXB 2.3.1, and here is the version which is on JAXB 3.x.

@bsanchezb
Copy link

Just one comment to be not forgotten when upgrading to JAXB 3.x: addIfExistsToEpisodeSchemaBindings.xslt should be also modified, as it currently does not seem to support JAXB 3 with https://jakarta.ee/xml/ns/jaxb namespace bindings.
I tested com.evolvedbinary.maven.jvnet:jaxb30-maven-plugin fork and this options seems to be not working (receive "SCD "x-schema::tns" didnt match any schema component" error).

@johnsgithubaccount
Copy link

Just one comment to be not forgotten when upgrading to JAXB 3.x: addIfExistsToEpisodeSchemaBindings.xslt should be also modified, as it currently does not seem to support JAXB 3 with https://jakarta.ee/xml/ns/jaxb namespace bindings.
I tested com.evolvedbinary.maven.jvnet:jaxb30-maven-plugin fork and this options seems to be not working (receive "SCD "x-schema::tns" didnt match any schema component" error).

The issue appears to be fixed on the main trunk but not yet released in qa build.

maven-jaxb2-plugin is running an XSLT transform on the episode file after the XJC generation.

Here is the (fixed) stylesheet used in the XSLT transformation: https://github.com/phax/maven-jaxb2-plugin/blob/master/plugin-core/src/main/resources/org/jvnet/jaxb2/maven2/addIfExistsToEpisodeSchemaBindings.xslt

You can workaround the problem by invoke the stylesheet transformation from your POM

  1. Add the addIfExistsToEpisodeSchemaBindings.xslt to your project

  2. Invoke the xml-maven-plugin from your pom to run the stylesheet transformation. Something like:

     	<plugin>
     		<groupId>org.codehaus.mojo</groupId>
     		<artifactId>xml-maven-plugin</artifactId>
     		<version>1.0.2</version>
     		<executions>
     			<execution>
     				<goals>
     					<goal>transform</goal>
     				</goals>
     			</execution>
     		</executions>
     		<configuration>
     			<transformationSets>
     				<transformationSet>
     					<dir>${project.build.directory}/generated-sources/xjc/META-INF/</dir>
     					<stylesheet>src/main/xslt/addIfExistsToEpisodeSchemaBindings.xslt</stylesheet>
     					<outputDir>${project.build.directory}/generated-sources/xjc/META-INF/</outputDir>
     				</transformationSet>
     			</transformationSets>
     		</configuration>
     	</plugin>
    

@laurentschoelens
Copy link
Collaborator

Made a pull request for supporting jaxb3 / jaxb4 #255

@mattrpav
Copy link
Collaborator

#389

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

No branches or pull requests

7 participants