简体   繁体   中英

JAXB2 schemagen syntax error when passing from JDK7 to 8

I'm trying to build a Confluence plugin with Java 8. It builds correctly with Java 7. It uses the jaxb2-maven-plugin, where one of the defined executions with goal "schemagen" and phase "generate-resources" is throwing this error:

[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.3.1:schemagen (restTypes) on project bb-team-plugin: 
        Execution restTypes of goal org.codehaus.mojo:jaxb2-maven-plugin:2.3.1:schemagen failed: 
        syntax error @[1,1] in file: MY_WORKDIR/target/generated-sources/jaxb/META-INF/sun-jaxb.episode -> [Help 1]

The bindings file i have:

<jxb:bindings jxb:version="1.0" jxb:extensionBindingPrefixes="xjc"
 xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
 xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
    <jxb:globalBindings>
      <xjc:simple />
    </jxb:globalBindings>
</jxb:bindings>

Using -e or -X in maven doesn't throw any extra useful output, using in the configuration for the execution throws a SAXParseException warning and the same error as mentioned above.

I've compared my sun-jaxb.episode against other examples (as in this site https://github.com/highsource/maven-jaxb2-plugin/wiki/Using-Episodes ) and it has the exact same structure, nothing looks malformed in there.

Any idea what could be happening?

This might be a little too late or not exactly what you are looking for, but this might be helpful for someone.

I've ran into the same syntax error ("syntax error @[1,1] in file:") on my project when trying to generate the XSDs from the annotated classes with JAXB2. I believe the plugin was looking into my xsd files as well, thus throwing a SAXParseException, so i included a exclude filter in the pom.xml like so:

                <schemaSourceExcludeFilters>
                    <myExcludes implementation="org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter">
                        <patterns>
                            <pattern>\.xsd</pattern>
                        </patterns>
                    </myExcludes>
                </schemaSourceExcludeFilters>

more on this: http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/schemagen-mojo.html

This did it for me. Also another thing I tried before was to remove the whitespaces from the file path (My project name had whitespaces), as this seems to generate an old bug that hasn't been fixed yet. About this issue take a look at: https://github.com/mojohaus/jaxb2-maven-plugin/issues/48

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM