从java8迁移到java11,jaxb saxparseexception

发布于 2025-02-09 17:32:33 字数 2748 浏览 1 评论 0原文

我正在将Spring Boot 2.7.0项目从Java 8升级到Java 11。 该项目正在使用Maven-Jaxb2-Plugin从WSDL文件生成类。

这是配置

            <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>

在两个版本中保持不变的配置,仅Maven-Jaxb2-Plugin的版本从0.13.3变为0.15.1。我不得不添加新的Maven依赖关系Jaxwx-api和Saaj-impl。他们使用来自Spring Boot的默认版本。

输出使用Java 8运行MVN清洁安装时,输出为

[info] --- maven-jaxb2-plugin:0.13.3:生成(ankyationalStucture) @ redb2b -------- [警告]您在配置中使用forcergenerate = true。 此配置设置被弃用,不推荐,因为它会导致IDE中的增量构建问题。 请参阅以下链接以获取更多信息: https://github.com/github.com/highsource/hhighsource/maven--maven------- jaxb2-plugin/wiki/do-not-not-use-forceregenerate 考虑从插件配置中删除此设置。 [info] [forceregenerate]开关已打开,将执行XJC。 [info]情节文件[c:\ rpss \ b2b-portal \ target \ oferated-sources \ meta-inf \ sun-jaxb.episode]已使用if-exists =“ true”属性增强。

使用Java 11运行MVN CLEAN安装时,输出是相同的,但也包含一个例外

org.xml.sax.saxparseexception:您是否试图编译WSDL?对WSDL的支持是实验性的。您可以使用-WSDL选项启用它。

saxparseexception在最后2 [info] 线之间。 该代码是从WSDL文件成功生成的,并且该应用程序的行为良好。

不过,我想了解例外背后的原因。 WSDL没有任何变化。

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸠书 2025-02-16 17:32:33

很抱歉长期答案,但这是一个错误,不是在插件本身中,而是在jaxb-xjc中,该插件是在2.3.6版本中引入的(问题在此),在插件的0.15.x版本中使用。

好处是:在JAXB运行时(4.0.4和2.3.9)的最新版本中已经解决了它。
我们目前正在基于JAXB-XJC的4.0.4版本的插件(4.0.1)的下一个版本,然后查看Jaxb-XJC的2.3.9升级的2.0.10版本,以关闭问题在Jaxb-tools中。

您可以查看迁移指南自今年发生了许多变化以来,请使用Maven-Plugin和相关工具的最新版本(将存储库合并到Maven-Jaxb2-Plugin的存储库中,重命名为JAXB-Tools,支持Jakarta Jaxb的支持,许多BugFixes ...)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文