java - Maven cxf-xjc-plugin xpath not working as expected inside bindings file
问题描述
Ok here we go. I have simple example here with just couple of lines for simplicity but it still does not work. XPath testing in web browser finds the element as expected.
plugin in pom.xml:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<fork>true</fork>
<additionalJvmArgs>-Djdk.xml.maxOccurLimit=99999999</additionalJvmArgs>
<additionalJvmArgs>-verbose</additionalJvmArgs>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
<xsdOptions>
<xsdOption>
<extension>true</extension>
<xsd>${basedir}/src/main/resources/xsds/CC015C.xsd</xsd>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/xsds/CC015C_bindings.xjb</bindingFile>
</bindingFiles>
<packagename>generated.messages</packagename>
</xsdOption>
</xsdOptions>
</configuration>
<goals>
<goal>xsdtojava</goal>
</goals>
</execution>
</executions>
<configuration>
<extensions>
<extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:3.3.1</extension>
</extensions>
</configuration>
</plugin>
CC015C.xsd content:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
targetNamespace="http://example.eu"
elementFormDefault="unqualified"
attributeFormDefault="unqualified"
version="51.40"
vc:minVersion="1.1">
<complexType name="CC015CType">
</complexType>
</schema>
CC015C_bindings.xjb (CCType is just some class that I have and should be extended by CC015CType):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:version="2.1"
>
<annotation>
<appinfo>
<jaxb:bindings schemaLocation="*">
<jaxb:bindings node="//complexType[@name='CC015CType']">
<xjc:superClass name="com.example.demo.model.CCType" />
</jaxb:bindings>
</jaxb:bindings>
</appinfo>
</annotation>
</schema>
When I run this, I get this exception:
com.sun.istack.SAXParseException2; Failed to create model
at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:64)
at org.apache.cxf.maven_plugin.XSDToJavaRunner.loadModel(XSDToJavaRunner.java:226)
at org.apache.cxf.maven_plugin.XSDToJavaRunner.run(XSDToJavaRunner.java:174)
at org.apache.cxf.maven_plugin.XSDToJavaRunner.main(XSDToJavaRunner.java:360)
Caused by: java.lang.reflect.InvocationTargetException
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.apache.cxf.maven_plugin.XSDToJavaRunner.loadModel(XSDToJavaRunner.java:224)
... 2 more
Caused by: java.lang.IllegalArgumentException: can't parse argument number: ''http://java.sun.com/xml/ns/jaxb''
at java.text.MessageFormat.makeFormat(MessageFormat.java:1429)
at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
at java.text.MessageFormat.<init>(MessageFormat.java:362)
at java.text.MessageFormat.format(MessageFormat.java:840)
at com.sun.tools.xjc.Messages.format(Messages.java:24)
at com.sun.tools.xjc.ModelLoader.buildDOMForest(ModelLoader.java:278)
at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:318)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:121)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:76)
... 7 more
Caused by: java.lang.NumberFormatException: For input string: "''http://java.sun.com/xml/ns/jaxb''"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:569)
at java.lang.Integer.parseInt(Integer.java:615)
at java.text.MessageFormat.makeFormat(MessageFormat.java:1427)
... 15 more
[ERROR] C:\example\prototype\src\main\resources\xsds\CC015C.xsd [0:0]: Failed to create model
解决方案
推荐阅读
- python-3.x - plotly:3D 绘图返回一个没有数据点的图形
- c# - 从 SQL 获取数据以及在 C# 中读取 excel
- mysql - 将 WHERE 和 AND 分组为一个语句
- python - 使用 SciPy 拟合 Levy 稳定分布
- javascript - 如何获取复选框索引/行号?
- javascript - 如何在 javascript 文件中绘制图表并将其传递给 html 以便它可以显示
- php - 尝试使用军用时钟格式制作 if、elseif、else 时间和何时吃饭的声明
- javascript - 如何使用 css 内容显示图像?
- reactjs - React 事件处理程序上的控制台日志语句导致合成事件警告
- mysql - 来自 PLpgsql 的 PLsql 等效查询