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

xjc with WSDL emits erroneous warning #1701

Closed
dsbecker opened this issue Feb 16, 2023 · 4 comments · Fixed by #1714
Closed

xjc with WSDL emits erroneous warning #1701

dsbecker opened this issue Feb 16, 2023 · 4 comments · Fixed by #1714

Comments

@dsbecker
Copy link

dsbecker commented Feb 16, 2023

I am using the latest version of maven-jaxb2-plugin (which now uses JAXB v2.3.x) to generate code from a wsdl file. It emits the following warning message, but did not used to when it was using JAXB v2.1.x. I believe this would also happen from the cli tooling since the issue is all in the JAXB code.

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

In my plugin configuration, the schemaLanguage is already properly set to WSDL.

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.15.2</version>
    <executions>
        <execution>
            <id>generate-mywsdl</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <schemaLanguage>WSDL</schemaLanguage>
                <schemaDirectory>${basedir}/src/main/resources/schemas</schemaDirectory>
                <generatePackage>my.wsdl</generatePackage>
                <generateDirectory>${project.build.directory}/generated-sources/mywsdl</generateDirectory>
                <schemaIncludes>
                    <include>my.wsdl</include>
                </schemaIncludes>
            </configuration>
        </execution>
    </executions>
</plugin>

After reviewing the source, I believe this warning is erroneous for the following reasons:

  1. The -wsdl switch mentioned is used from cli to set the schemaLanguage, which is already properly set by the plugin.
  2. ModelLoader has a sanityCheck() method which seems intended to guard against someone mistakenly setting (or using the default) schemaLanguage as XMLSCHEMA when they really want a DTD or WSDL. In v2.1.x, it does this by checking opt.getSchemaLanguage()==Language.XMLSCHEMA and then using the file extension to guess if it really should be a DTD or WSDL and return the above messaging if so. See:
    if( opt.getSchemaLanguage()==Language.XMLSCHEMA ) {
  3. Starting in JAXB v2.2.x, however, the following commit changes this logic to opt.getSchemaLanguage()!=Language.XMLSCHEMA which seems wrong. See: https://github.com/eclipse-ee4j/jaxb-ri/pull/1484/files#diff-505738a8042847a9040fdacbd669222bf6748184d054258ee78ba7356dd53e90
  4. With this change, even when the schemaLanguage is already properly set to DTD or WSDL, it will trip into that code and emit the warning.
  5. Even if you pass the switch on the cli, as instructed by the message, all it does is set the schemaLanguage to WSDL which does nothing to silence the warning because you still fail the sanityCheck(). See: https://github.com/eclipse-ee4j/jaxb-ri/blob/master/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/Options.java#L591-L594

Fortunately, this message does not stop the code generation and things still work as expected for me. The issue is purely cosmetic.

It looks to me like all you need to do is revert that one commit to ModelLoader and things will go back to normal.

If my analysis is incorrect, could you please help educate me on why that change was made, what that sanityCheck() is really for, and how to resolve this message (either on the cli, or through the plugin)?

lukasj added a commit to lukasj/jaxb-ri that referenced this issue May 31, 2023
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
lukasj added a commit that referenced this issue May 31, 2023
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
@laurentschoelens
Copy link
Contributor

Hi @lukasj : is any backport of this issue will be done in 3.x branch and 2.3.x branch ? Or is it only for jakarta 4.x ?

@aprevost
Copy link

Hi @lukasj : is any backport of this issue will be done in 3.x branch and 2.3.x branch ? Or is it only for jakarta 4.x ?

I just wanted to +1 @laurentschoelens question here... even though the classes are still generated successfully, having such an error message in our build logs when using the maven-jaxb2-plugin is extremely alarming and is going to raise flags and have to be explained any time a new person joins our team and sees it for the first time. To the point that we're strongly considering reverting to an older version of that plugin just to avoid this message.

Anything that can be done to backport this fix to eliminate the message would be much appreciated.

@laurentschoelens
Copy link
Contributor

Hi @lukasj : is any backport of this issue will be done in 3.x branch and 2.3.x branch ? Or is it only for jakarta 4.x ?

I just wanted to +1 @laurentschoelens question here... even though the classes are still generated successfully, having such an error message in our build logs when using the maven-jaxb2-plugin is extremely alarming and is going to raise flags and have to be explained any time a new person joins our team and sees it for the first time. To the point that we're strongly considering reverting to an older version of that plugin just to avoid this message.

Anything that can be done to backport this fix to eliminate the message would be much appreciated.

Hello @aprevost

We are migrating the plugin to support jaxb3 (and then jaxb4) with Matt (see migration guide page on the wiki).

My point is and was that we should have, if possible, backport to jaxb2 at least, since jaxb3 is only package renaming and getting nothing more in it.
Users are so encouraged to migrate to jaxb4 with jdk11 if wanting to have new features and better support.

@lukasj I know you're pretty busy, could you give us small update on this please 😃

lukasj added a commit to lukasj/jaxb-ri that referenced this issue Oct 9, 2023
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
(cherry picked from commit 5a10fab)
@lukasj
Copy link
Member

lukasj commented Oct 9, 2023

wrt backport, see #1765

lukasj added a commit that referenced this issue Oct 13, 2023
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
(cherry picked from commit 5a10fab)
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 a pull request may close this issue.

4 participants