jaxbjax-wsmaven-jaxb2-plugin

JAXB SAXParseException after migrating from Java8 to Java11


I'm upgrading a Spring Boot 2.7.0 project from Java 8 to Java 11. The project is using maven-jaxb2-plugin to generate classes from wsdl files.

This is the configuration

            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.15.1</version>
            <executions>
                <execution>
                    <id>organisationalStructure</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>

                    <configuration>
                        <schemaLanguage>WSDL</schemaLanguage>
                        <generateDirectory>${project.build.directory}/generated-sources</generateDirectory>
                        <generatePackage>com.test.organisationalStructure</generatePackage>
                        <schemas>
                            <schema>
                                <fileset>
                                    <directory>${basedir}/src/main/resources/wsdl/</directory>
                                    <include>organisationStructure.wsdl</include>
                                </fileset>
                            </schema>
                        </schemas>
                        <readOnly>true</readOnly>
                        <removeOldOutput>false</removeOldOutput>
                        <forceRegenerate>true</forceRegenerate>
                    </configuration>
                </execution>

The configuration stays the same in both versions, only the version of maven-jaxb2-plugin changes from 0.13.3 to 0.15.1. I had to add new maven dependencies jaxwx-api and saaj-impl. They use the default version which comes from Spring Boot.

The output, when running mvn clean install with Java 8, is

[INFO] --- maven-jaxb2-plugin:0.13.3:generate (organisationalStructure) @ redb2b --- [WARNING] You are using forceRegenerate=true in your configuration. This configuration setting is deprecated and not recommended as it causes problems with incremental builds in IDEs. Please refer to the following link for more information: https://github.com/highsource/maven-jaxb2-plugin/wiki/Do-Not-Use-forceRegenerate Consider removing this setting from your plugin configuration. [INFO] The [forceRegenerate] switch is turned on, XJC will be executed. [INFO] Episode file [C:\RPSS\B2B-portal\target\generated-sources\META-INF\sun-jaxb.episode] was augmented with if-exists="true" attributes.

When running mvn clean install with Java 11, the output is identical but it also contains an exception

org.xml.sax.SAXParseException: Are you trying to compile WSDL? Support for WSDL is experimental. You may enable it by using the -wsdl option.

The SAXParseException comes between the last 2 [INFO] lines. The code is generated successfully from the wsdl file and the application behaves fine.

Still, I would like to understand the reason behind the exception. Nothing changes in the wsdl.

Thanks.


Solution

  • Sorry for the long time answer but this is a bug, not in the plugin itself but in JAXB-XJC which was introduced in 2.3.6 version (issue here), used in 0.15.x version of the plugin.

    The good point : it has been resolved in latest release of JAXB runtime (4.0.4 and 2.3.9). We are currently rolling out the next version of the plugin (4.0.1) based on 4.0.4 version of JAXB-XJC, and then look at the 2.0.10 release with 2.3.9 upgrade of JAXB-XJC in order to close the issue in JAXB-Tools.

    You might look at the migration guide in order to use the latest versions of the maven-plugin and related tools since many things changed this year (merging repository into maven-jaxb2-plugin's repository renamed jaxb-tools, support of jakarta JAXB's version, many bugfixes...)