简体   繁体   English

Maven Jaxb2插件抛出错误“未定义的元素声明's:schema'”

[英]Maven Jaxb2 plugin throwin error “undefined element declaration 's:schema' ”

I am trying to generate the classes using maven jaxb2 plugin . 我正在尝试使用maven jaxb2 plugin生成类。 However I am receiving the below exception : 但是我收到以下异常:

org.xml.sax.SAXParseException; systemId: http://someIP/dummywsdl.asmx?wsdl; lineNumber: 32; columnNumber: 41; undefined element declaration 's:schema'
at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:180)
at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:175)
at com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:110)
at com.sun.xml.xsom.impl.parser.DelayedRef.run(DelayedRef.java:85)
at com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:135)
at com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:214)
at com.sun.tools.xjc.ModelLoader.loadWSDL(ModelLoader.java:412)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:170)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:50)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:40)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:488)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:311)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
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.MojoExecutor.executeForkedExecutions(MojoExecutor.java:352)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:197)
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

After searching , I came to know that below 2 declaration in wsdl is causing the issue : 搜索后,我发现wsdl中的以下2声明引起了该问题:

<s:element ref="s:schema"/>
<s:any/>

In one of the post , I found that If I change the above 2 lines with the below given line , then plugin is generating the files without any issue : 在其中一篇文章中,我发现如果我用下面给定的行来更改上面的两行,那么插件将生成文件而没有任何问题:

<s:any  minOccurs="2" maxOccurs="2" />

Below is the plugin configuration that I am using : 以下是我正在使用的插件配置:

<plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.12.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaLanguage>WSDL</schemaLanguage>
                <generatePackage>com.abc</generatePackage>
                <schemas>
                    <schema>
                        <url>http://someIP/dummywsdl.asmx?wsdl</url>
                    </schema>
                </schemas>
            </configuration>
        </plugin>

Is there any other way to resolve the issue without changing the WSDL , as this is a client WSDL , and I don't want to store it at my local with the above changes. 是否有其他方法可以解决此问题而无需更改WSDL,因为这是客户端WSDL,并且我不希望通过上述更改将其存储在本地。

Your schema seems to be invalid. 您的架构似乎无效。 So no, XJC won't compile it unless you fix the error. 所以不,除非您修复错误,否则XJC不会编译它。

As a workaround you can create a local copy of your schema and fix this copy. 解决方法是,可以创建架构的本地副本并修复此副本。 The you can create a catalog file which would "rewrite" the global URL http://someIP/dummywsdl.asmx?wsdl`` into your local dummywsdl.asmx_wsdl`: 您可以创建一个目录文件,该文件将“全局” URL http://someIP/dummywsdl.asmx?wsdl`` into your local重写” http://someIP/dummywsdl.asmx?wsdl`` into your local dummywsdl.asmx_wsdl`中:

REWRITE_SYSTEM "http://someIP/dummywsdl.asmx?wsdl" "dummywsdl.asmx_wsdl"

See Using catalogs for more info. 有关更多信息,请参见使用目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jaxb2 maven插件,在单独的标签中定义多个模式文件 - jaxb2 maven plugin, define multiple schema files in separate tags 调试jaxb2 maven插件 - debugging jaxb2 maven plugin JAXB2 Maven 插件 xjc 解析错误:org.xml.sax.SAXParseException:意外<xs:element>出现 - JAXB2 Maven Plugin xjc parse error: org.xml.sax.SAXParseException: Unexpected <xs:element> appears 如何在 JAXB2 maven 插件版本 2.4 中定义架构目录? - How do I define schema directory in JAXB2 maven plugin version 2.4? JAXB2基础简化插件引发“找不到元素&#39;simplify:property&#39;的声明”异常 - JAXB2 Basics simplify plugin throws “Cannot find the declaration of element 'simplify:property'” exception 如果没有maven clean,使用JAXB2插件的Maven项目将无法运行 - Maven project with JAXB2 plugin does not work without maven clean 在STS中将jaxb2 maven插件与Spring Boot一起使用时收到错误 - Receiving an error when using jaxb2 maven plugin with spring boot in STS 使用jaxb2 maven插件在Java文件中跳过Generated on ... - Skip the Generated on… in Java files using jaxb2 maven plugin Maven JAXB2插件无法处理绑定文件 - Maven JAXB2 plugin fails to process bindings file SAXParseException: maven jaxb2 插件似乎无法正确导入模式 - SAXParseException: maven jaxb2 plugin seems not to import schemas correctly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM