SAXParseException:maven jaxb2 插件似乎没有正确导入模式

发布于 2024-11-17 18:47:07 字数 14455 浏览 2 评论 0原文

在从 XSD 模式生成源代码期间,我收到 SAXParseException(见下文)。模式“gws-ctsa-myapp.xsd”正在导入两个基本组件“gws-services-types.xsd”和“gws-ctsa.xsd”。最后一个还导入相同的基本组件“gws-services-types.xsd”,并且这两个基本组件都可以通过类路径目录解析器找到。

我希望基本组件“gws-ctsa.xsd”中的导入对于模式“gws-ctsa-myapp.xsd”不可见,但不幸的是事实并非如此。

当我在项目“project_root/myapp/myapp-jaxb”上运行“mvn编译”时,它工作正常。当我在项目根目录“project_root/”上运行它时,它不起作用。项目目录如下所示:

...
project_root/
project_root/common/
project_root/common/common-jaxb
...
project_root/myapp/
project_root/myapp/myapp-jaxb
...

这是异常堆栈跟踪:

[INFO] Started execution.
[INFO] JAXB API is loaded from the [jar:file:/C:/Program%20Files/Java/jdk1.6.0_22/jre/lib/rt.jar!].
[INFO] Detected JAXB API version [2.1].
[INFO] pluginArtifacts:[org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-raw:jar:0.7.3:runtime, org.codehaus.plexus:plexus-utils:jar:1.1:runtime, ...
[INFO] schemaLanguage:null
[INFO] schemaDirectory:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\resources
[INFO] schemaIncludes:[Ljava.lang.String;@883540
[INFO] schemaExcludes:null
[INFO] bindingDirectory:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\xjc
[INFO] bindingIncludes:[Ljava.lang.String;@603c9f
[INFO] bindingExcludes:null
[INFO] disableDefaultExcludes:false
[INFO] catalog:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\xjc\catalog.cat
[INFO] catalogResolver:org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver
[INFO] generatePackage:com.company.myapp.xjcctsamyapp
[INFO] generateDirectory:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\target\generated-sources\xjc
[INFO] readOnly:false
[INFO] extension:false
[INFO] strict:true
[INFO] writeCode:true
[INFO] verbose:true
[INFO] debug:false
[INFO] args:[-npa]
[INFO] forceRegenerate:true
[INFO] removeOldOutput:false
[INFO] otherDepends:null
[INFO] episodeFile:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\target\generated-sources\xjc\META-INF\sun-jaxb.episode
[INFO] episode:true
[INFO] classpathElements:[D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\target\classes]
[INFO] plugins:[Lorg.apache.maven.model.Dependency;@2c14f9
[INFO] episodes:null
[INFO] xjcPlugins:[Lorg.apache.maven.model.Dependency;@2c14f9
[INFO] episodes:null
[INFO] specVersion:2.1
[INFO] schemaFiles (calculated):[D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\resources\gws-ctsa-myapp.xsd]
[INFO] bindingFiles (calculated):[D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\xjc\binding.xjb]
[INFO] xjcPluginArtifacts (resolved):[active project artifact:
        artifact = com.company.common:common-jaxb:jar:1.0-SNAPSHOT:runtime;
        project: MavenProject: com.company.common:common-jaxb:1.0-SNAPSHOT @ D:\eclipse\pbona\workspace\tobias-ROOT\common\common-jaxb\pom.xml]
[INFO] xjcPluginFiles (resolved):[D:\eclipse\pbona\workspace\tobias-ROOT\common\common-jaxb\target\classes]
[INFO] xjcPluginURLs (resolved):[file:/D:/eclipse/pbona/workspace/tobias-ROOT/common/common-jaxb/target/classes/]
[INFO] episodeArtifacts (resolved):[]
[INFO] episodeFiles (resolved):[]
[INFO] The schemaLanguage setting was not defined, assuming 'AUTODETECT'.
Using java.util.ServiceLoader
[INFO] Parsing input schema(s)...
[ERROR] Error while parsing schema(s).Location [ file:/D:/eclipse/pbona/workspace/tobias-ROOT/common/common-jaxb/target/classes/gws-service-types.xsd{14,35}].
    org.xml.sax.SAXParseException: 'requiredString' is already defined
            at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:176)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:170)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:173)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.checkDoubleDefError(NGCCRuntimeEx.java:145)
            at com.sun.xml.xsom.impl.parser.state.Schema.action6(Schema.java:92)
            at com.sun.xml.xsom.impl.parser.state.Schema.onChildCompleted(Schema.java:1176)
            at com.sun.xml.xsom.impl.parser.state.NGCCHandler.revertToParentFromEnterElement(NGCCHandler.java:110)
            at com.sun.xml.xsom.impl.parser.state.simpleType.enterElement(simpleType.java:130)
            at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.startElement(NGCCRuntime.java:219)
            at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
            at com.sun.tools.xjc.util.SubtreeCutter.startElement(SubtreeCutter.java:104)
            at com.sun.tools.xjc.reader.ExtensionBindingChecker.startElement(ExtensionBindingChecker.java:144)
            at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
            at com.sun.tools.xjc.reader.xmlschema.parser.IncorrectNamespaceURIChecker.startElement(IncorrectNamespaceURIChecker.java:113)
            at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
            at com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker.startElement(CustomizationContextChecker.java:188)
            at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.startElement(DOMForestScanner.java:141)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:239)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:276)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:245)
            at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:122)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:89)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:97)
            at com.sun.tools.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:99)
            at com.sun.tools.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:262)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:337)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.importSchema(NGCCRuntimeEx.java:243)
            at com.sun.xml.xsom.impl.parser.state.importDecl.action0(importDecl.java:45)
            at com.sun.xml.xsom.impl.parser.state.importDecl.leaveElement(importDecl.java:138)
            at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.endElement(NGCCRuntime.java:275)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.util.SubtreeCutter.endElement(SubtreeCutter.java:108)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker.endElement(CustomizationContextChecker.java:194)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.endElement(DOMForestScanner.java:135)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:276)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:245)
            at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:122)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:89)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:97)
            at com.sun.tools.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:99)
            at com.sun.tools.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:262)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:337)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.importSchema(NGCCRuntimeEx.java:243)
            at com.sun.xml.xsom.impl.parser.state.importDecl.action0(importDecl.java:45)
            at com.sun.xml.xsom.impl.parser.state.importDecl.leaveElement(importDecl.java:138)
            at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.endElement(NGCCRuntime.java:275)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.util.SubtreeCutter.endElement(SubtreeCutter.java:108)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker.endElement(CustomizationContextChecker.java:194)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.endElement(DOMForestScanner.java:135)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:276)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:245)
            at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:122)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:89)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:97)
            at com.sun.tools.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:99)
            at com.sun.tools.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:262)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:337)
            at com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:124)
            at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:183)
            at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:172)
            at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:516)
            at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:375)
            at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)
            at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)
            at org.jvnet.jaxb2.maven2.RawXJC2Mojo.loadModel(RawXJC2Mojo.java:637)
            at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:259)
            at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:135)
            at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
            at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
            at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
            at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
            at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
            ...

我正在使用命令“mvncompile”并在project_root/common/common-jaxb/pom.xml中使用以下插件配置:

<build>

    <!-- *******************************************************************
         * Plugins
         ******************************************************************* -->

    <plugins>

        <!-- Generieren -->
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
              ...
              <!-- CTSA_MYAPP-->
              <execution>
                <id>gws-ctsa-myapp</id>
                <goals>
                  <goal>generate</goal>
                </goals>
                <configuration>
                  <schemaIncludes>
                    <include>gws-ctsa-myapp.xsd</include>
                  </schemaIncludes>
                  <generatePackage>com.company.myapp.xjcctsamyapp</generatePackage>
                </configuration>
              </execution>

            </executions>

            <!-- wir muessen dem Plugin noch sagen, wo die gws-service-types.xsd u.a. herkommt -->
            <configuration>
                <plugins>
                    <plugin>
                        <groupId>com.company.common</groupId>
                        <artifactId>common-jaxb</artifactId>
                    </plugin>
                </plugins>
                <catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver>
                <catalog>${xjc.resources.dir}/catalog.cat</catalog>
            </configuration>

        </plugin>

    </plugins>

</build>

我尝试了很多更改和不同的配置如目录中的绝对路径(避免目录解析器)、不同的命名空间和模式位置,但没有解决问题。有人有什么想法吗?

非常感谢!

佩德罗.

during generation of source from XSD schemas I get a SAXParseException (see below). A schema "gws-ctsa-myapp.xsd" is importing two basic components "gws-services-types.xsd" and "gws-ctsa.xsd". The last one imports as well the same basic component "gws-services-types.xsd" and the both basic components are being found over a classpath catalog resolver.

I would expect that the import in the basic component "gws-ctsa.xsd" would not be visible for the schema "gws-ctsa-myapp.xsd" but this unfortunately not the case.

When I run the "mvn compile" on the project "project_root/myapp/myapp-jaxb" it works fine. When I run it on the project root "project_root/" it doesn't work. The project directories look like this:

...
project_root/
project_root/common/
project_root/common/common-jaxb
...
project_root/myapp/
project_root/myapp/myapp-jaxb
...

And here is the exception stack trace:

[INFO] Started execution.
[INFO] JAXB API is loaded from the [jar:file:/C:/Program%20Files/Java/jdk1.6.0_22/jre/lib/rt.jar!].
[INFO] Detected JAXB API version [2.1].
[INFO] pluginArtifacts:[org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-raw:jar:0.7.3:runtime, org.codehaus.plexus:plexus-utils:jar:1.1:runtime, ...
[INFO] schemaLanguage:null
[INFO] schemaDirectory:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\resources
[INFO] schemaIncludes:[Ljava.lang.String;@883540
[INFO] schemaExcludes:null
[INFO] bindingDirectory:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\xjc
[INFO] bindingIncludes:[Ljava.lang.String;@603c9f
[INFO] bindingExcludes:null
[INFO] disableDefaultExcludes:false
[INFO] catalog:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\xjc\catalog.cat
[INFO] catalogResolver:org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver
[INFO] generatePackage:com.company.myapp.xjcctsamyapp
[INFO] generateDirectory:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\target\generated-sources\xjc
[INFO] readOnly:false
[INFO] extension:false
[INFO] strict:true
[INFO] writeCode:true
[INFO] verbose:true
[INFO] debug:false
[INFO] args:[-npa]
[INFO] forceRegenerate:true
[INFO] removeOldOutput:false
[INFO] otherDepends:null
[INFO] episodeFile:D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\target\generated-sources\xjc\META-INF\sun-jaxb.episode
[INFO] episode:true
[INFO] classpathElements:[D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\target\classes]
[INFO] plugins:[Lorg.apache.maven.model.Dependency;@2c14f9
[INFO] episodes:null
[INFO] xjcPlugins:[Lorg.apache.maven.model.Dependency;@2c14f9
[INFO] episodes:null
[INFO] specVersion:2.1
[INFO] schemaFiles (calculated):[D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\resources\gws-ctsa-myapp.xsd]
[INFO] bindingFiles (calculated):[D:\eclipse\pbona\workspace\tobias-ROOT\myapp\myapp-jaxb\src\main\xjc\binding.xjb]
[INFO] xjcPluginArtifacts (resolved):[active project artifact:
        artifact = com.company.common:common-jaxb:jar:1.0-SNAPSHOT:runtime;
        project: MavenProject: com.company.common:common-jaxb:1.0-SNAPSHOT @ D:\eclipse\pbona\workspace\tobias-ROOT\common\common-jaxb\pom.xml]
[INFO] xjcPluginFiles (resolved):[D:\eclipse\pbona\workspace\tobias-ROOT\common\common-jaxb\target\classes]
[INFO] xjcPluginURLs (resolved):[file:/D:/eclipse/pbona/workspace/tobias-ROOT/common/common-jaxb/target/classes/]
[INFO] episodeArtifacts (resolved):[]
[INFO] episodeFiles (resolved):[]
[INFO] The schemaLanguage setting was not defined, assuming 'AUTODETECT'.
Using java.util.ServiceLoader
[INFO] Parsing input schema(s)...
[ERROR] Error while parsing schema(s).Location [ file:/D:/eclipse/pbona/workspace/tobias-ROOT/common/common-jaxb/target/classes/gws-service-types.xsd{14,35}].
    org.xml.sax.SAXParseException: 'requiredString' is already defined
            at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:176)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:170)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:173)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.checkDoubleDefError(NGCCRuntimeEx.java:145)
            at com.sun.xml.xsom.impl.parser.state.Schema.action6(Schema.java:92)
            at com.sun.xml.xsom.impl.parser.state.Schema.onChildCompleted(Schema.java:1176)
            at com.sun.xml.xsom.impl.parser.state.NGCCHandler.revertToParentFromEnterElement(NGCCHandler.java:110)
            at com.sun.xml.xsom.impl.parser.state.simpleType.enterElement(simpleType.java:130)
            at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.startElement(NGCCRuntime.java:219)
            at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
            at com.sun.tools.xjc.util.SubtreeCutter.startElement(SubtreeCutter.java:104)
            at com.sun.tools.xjc.reader.ExtensionBindingChecker.startElement(ExtensionBindingChecker.java:144)
            at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
            at com.sun.tools.xjc.reader.xmlschema.parser.IncorrectNamespaceURIChecker.startElement(IncorrectNamespaceURIChecker.java:113)
            at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
            at com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker.startElement(CustomizationContextChecker.java:188)
            at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:527)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.startElement(DOMForestScanner.java:141)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:239)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:276)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:245)
            at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:122)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:89)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:97)
            at com.sun.tools.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:99)
            at com.sun.tools.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:262)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:337)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.importSchema(NGCCRuntimeEx.java:243)
            at com.sun.xml.xsom.impl.parser.state.importDecl.action0(importDecl.java:45)
            at com.sun.xml.xsom.impl.parser.state.importDecl.leaveElement(importDecl.java:138)
            at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.endElement(NGCCRuntime.java:275)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.util.SubtreeCutter.endElement(SubtreeCutter.java:108)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker.endElement(CustomizationContextChecker.java:194)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.endElement(DOMForestScanner.java:135)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:276)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:245)
            at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:122)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:89)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:97)
            at com.sun.tools.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:99)
            at com.sun.tools.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:262)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:337)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.importSchema(NGCCRuntimeEx.java:243)
            at com.sun.xml.xsom.impl.parser.state.importDecl.action0(importDecl.java:45)
            at com.sun.xml.xsom.impl.parser.state.importDecl.leaveElement(importDecl.java:138)
            at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.endElement(NGCCRuntime.java:275)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.util.SubtreeCutter.endElement(SubtreeCutter.java:108)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker.endElement(CustomizationContextChecker.java:194)
            at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:546)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.endElement(DOMForestScanner.java:135)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:250)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:276)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:245)
            at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:122)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:89)
            at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:97)
            at com.sun.tools.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:99)
            at com.sun.tools.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:262)
            at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:337)
            at com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:124)
            at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:183)
            at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:172)
            at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:516)
            at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:375)
            at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)
            at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)
            at org.jvnet.jaxb2.maven2.RawXJC2Mojo.loadModel(RawXJC2Mojo.java:637)
            at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:259)
            at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:135)
            at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
            at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
            at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
            at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
            at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
            ...

I am using the command "mvn compile" with following plugin configuration in the project_root/common/common-jaxb/pom.xml:

<build>

    <!-- *******************************************************************
         * Plugins
         ******************************************************************* -->

    <plugins>

        <!-- Generieren -->
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
              ...
              <!-- CTSA_MYAPP-->
              <execution>
                <id>gws-ctsa-myapp</id>
                <goals>
                  <goal>generate</goal>
                </goals>
                <configuration>
                  <schemaIncludes>
                    <include>gws-ctsa-myapp.xsd</include>
                  </schemaIncludes>
                  <generatePackage>com.company.myapp.xjcctsamyapp</generatePackage>
                </configuration>
              </execution>

            </executions>

            <!-- wir muessen dem Plugin noch sagen, wo die gws-service-types.xsd u.a. herkommt -->
            <configuration>
                <plugins>
                    <plugin>
                        <groupId>com.company.common</groupId>
                        <artifactId>common-jaxb</artifactId>
                    </plugin>
                </plugins>
                <catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver>
                <catalog>${xjc.resources.dir}/catalog.cat</catalog>
            </configuration>

        </plugin>

    </plugins>

</build>

I tried a lot of changes and different configurations like absolut paths in the catalog (avoiding the catalog resolver), differents namespaces and schema locations and nothing solved the problem. Has anybody any idea?

Many thanks in advance!

Pedro.

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

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

发布评论

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

评论(1

双马尾 2024-11-24 18:47:07

我认为问题是由于目录解析器的使用造成的。我不认为这是maven插件中的错误,这一定是JAXB-XJC中的问题。
我想请您准备一个演示/示例项目来重现此行为(越小越好)并将其归档到 JIRA
我将在下一个版本中解决这个问题。

I think the problem is due to the usage of the catalog resolver. I don't think it is a bug in the maven plugin, this must be something in JAXB-XJC.
I would like to ask you to prepare a demo/sample project which reproduces this behaviour (the smaller the better) and to file it in JIRA.
I will address the issue in the next release.

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