0

使用 maven-jaxb2 插件从 xsd 生成 Java 代码时出现以下错误,使用命令行中的 xjc 一切正常。任何人都知道如何调试 maven-jaxb2 插件?

[INFO] --- maven-jaxb2-plugin:0.8.3:generate (default) @ microsoft-windowsazure-api ---
[ERROR] Error while parsing schema(s).Location [ file:/D:/SRC/gcheng13/azure-sdk-for-java-pr/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd{155,87}].
org.xml.sax.SAXParseException; systemId: file:/D:/SRC/gcheng13/azure-sdk-for-java-pr/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd; lineNumber: 155; columnNumber: 87; src-resolve: Cannot resolve the name 'tnsn:MessageCountDetails' to a(n) 'type definition' component.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4124)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:4107)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getGlobalDecl(XSDHandler.java:1667)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDElementTraverser.traverseNamedElement(XSDElementTraverser.java:405)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDElementTraverser.traverseLocal(XSDElementTraverser.java:194)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.traverseLocalElements(XSDHandler.java:3580)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:622)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:588)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:555)
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:521)
        at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:240)
        at com.sun.tools.xjc.reader.xmlschema.parser.SchemaConstraintChecker.check(SchemaConstraintChecker.java:109)
        at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:360)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174)
        at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:54)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:44)
        at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:29)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:318)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:160)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
4

2 回答 2

2

为了解决手头的问题,您应该像这样更改导入:

<xs:import schemaLocation="schemas.microsoft.com.2003.10.Serialization.xsd" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xs:import schemaLocation="schemas.microsoft.com.netservices.2011.06.servicebus.xsd" namespace="http://schemas.microsoft.com/netservices/2011/06/servicebus"/>  

这不是错误,但 schemas.microsoft.com.netservices.2011.06.servicebus.xsd 中有太多声明。

我个人不会声明/导入任何我不用来保持模式简单的东西。

我将 xjb 文件移动到与 xsd 文件相同的目录中,因此架构位置现在有效。

于 2013-06-03T18:00:26.383 回答
0

您应该检查命名空间 (tnsn) 是否在 xsd.xml 中声明。如果是,那么它可能是一个无法访问的 xsd 导入,可能会出现这样的错误。否则:http://confluence.highsource.org/display/MJIIP/User+Guide 调试和详细选项可用...

于 2013-05-31T10:30:50.323 回答