IntershopCommunicationsAG / jaxb-gradle-plugin

Gradle JAXB code generation plugin
Apache License 2.0
32 stars 15 forks source link

xjc failed - but no way to debug #52

Closed newcron closed 1 year ago

newcron commented 2 years ago

Hi There,

I am trying to migrate a maven project to gradle. I've got an existing (working) setup for xjc class generation (using the jaxb2 maven plugin).

When I pass the schemas and the xjc file to the jaxb-gradle-plugin however, I get an exception with the message xjc failed. XJC is quite good with helpful error messages, but unfortunately the output of xjc seems to be not coming.

From the log output I can see that the plugin intends to make the output verbose - but it seems as if it is just not happening.

using version 5.2.1

the info output looks like the one below. I can see that the -verbose switch is set - it just does not do anything.. Any idea what I could do to get to the actual error message?

[ant:jaxb] Command invoked: xjc /usr/lib/jvm/java-17-openjdk-amd64/bin/java -DenableExternalEntityProcessing=true -classpath /home/matthias/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-xjc/4.0.0/926dde084d326903f6564b905ba513fd99f65db1/jaxb-xjc-4.0.0.jar:/home/matthias/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-jxc/4.0.0/b380b05294adf2ffda5babaebfcabd71e9d45abe/jaxb-jxc-4.0.0.jar:/home/matthias/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-impl/4.0.0/925ceb2df66ff333f4264b0d4856e300195bc78c/jaxb-impl-4.0.0.jar:/home/matthias/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-core/4.0.0/f560f2e580d67950e1462cf3a3a21be51a281b42/jaxb-core-4.0.0.jar:/home/matthias/.gradle/caches/modules-2/files-2.1/org.glassfish.jaxb/jaxb-runtime/4.0.0/1f672b28726bc355cbbde7aed7001fe024fc6f13/jaxb-runtime-4.0.0.jar:/home/matthias/.gradle/caches/modules-2/files-2.1/jakarta.xml.bind/jakarta.xml.bind-api/4.0.0/bbb399208d288b15ec101fa4fcfc4bd77cedc97a/jakarta.xml.bind-api-4.0.0.jar:/home/matthias/.gradle/caches/modules-2/files-2.1/jakarta.activation/jakarta.activation-api/2.1.0/a58861b5deac5e151140511cf57d6b80a83f2d20/jakarta.activation-api-2.1.0.jar com.sun.tools.xjc.XJCFacade -d /home/matthias/dev/platform/kraken/libs/edi-data-models/build/generated/jaxb/java/name -p de.platform.kraken.edidatamodels -encoding UTF-8 -disableXmlSecurity -verbose /home/matthias/dev/platform/kraken/libs/edi-data-models/src/main/resources/schemas/ORDERS05.xsd -b /home/matthias/dev/platform/kraken/libs/edi-data-models/src/main/resources/global-comsun.xjb
[ant:jaxb] failure in the XJC task. Use the Ant -verbose switch for more details
kristianperkins commented 1 year ago

If you use gradle --info it passes -verbose down to the ant command. See SchemaToJavaTask.java.

povisenko commented 1 year ago

something is wrong with your binding run the command: java -DenableExternalEntityProcessing=true ....

it should show in the console relevant error e.g.

parsing a schema...
[ERROR] XPath evaluation {YOUR ERROR}

in my case, the issue was that I had two XSD schemas and one binding file for both e.g.

<jaxb:bindings xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               version="3.0">

    <!-- REQUESTS -->

    <jaxb:bindings schemaLocation="./request/GetRecord v1.0.xsd" node="//xsd:element[@name='ClientIntegrationRequest']">
        <jaxb:class name="GetRecordRequest"/>
    </jaxb:bindings>

    <jaxb:bindings schemaLocation="./request/UpdateRecord v1.0.xsd" node="//xsd:element[@name='ClientIntegrationRequest']">
        <jaxb:class name="UpdateRecordRequest"/>
    </jaxb:bindings>

</jaxb:bindings>

as soon as I separated these - all worked