0

我在 Jboss developer studio 10.4 和 JDK 1.8 中从 xml 模式定义文件生成 JaxB 类时遇到 JAXBException。

我是否缺少任何配置?

【com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions com.sun.xml.internal.bind.api.impl.NameConverter是一个接口,JAXB不能处理接口。此问题与以下位置有关:在公共 com.sun.xml.internal.bind.api.impl.NameConverter com.sun.tools.internal 的 com.sun.xml.internal.bind.api.impl.NameConverter。 xjc.reader.xmlschema.bindinfo.BIGlobalBinding.nameConverter at com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGlobalBinding]

完整的堆栈跟踪如下:

parsing a schema...
Exception in thread "main" java.lang.AssertionError: javax.xml.bind.JAXBException
 - with linked exception:
[com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
com.sun.xml.internal.bind.api.impl.NameConverter is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at com.sun.xml.internal.bind.api.impl.NameConverter
        at public com.sun.xml.internal.bind.api.impl.NameConverter com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.nameConverter
        at com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGlobalBinding
]
    at com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationContext(BindInfo.java:341)
    at com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationUnmarshaller(BindInfo.java:347)
    at com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.AnnotationParserFactoryImpl$1.<init>(AnnotationParserFactoryImpl.java:70)
    at com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.AnnotationParserFactoryImpl.create(AnnotationParserFactoryImpl.java:69)
    at com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx.createAnnotationParser(NGCCRuntimeEx.java:350)
    at com.sun.xml.internal.xsom.impl.parser.state.annotation.action0(annotation.java:74)
    at com.sun.xml.internal.xsom.impl.parser.state.annotation.enterElement(annotation.java:99)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCHandler.spawnChildFromEnterElement(NGCCHandler.java:99)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:173)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:271)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:118)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:185)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:165)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:130)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:153)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:283)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:212)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:200)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCHandler.revertToParentFromEnterElement(NGCCHandler.java:136)
    at com.sun.xml.internal.xsom.impl.parser.state.foreignAttributes.enterElement(foreignAttributes.java:76)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCHandler.spawnChildFromEnterElement(NGCCHandler.java:99)
    at com.sun.xml.internal.xsom.impl.parser.state.elementDeclBody.enterElement(elementDeclBody.java:220)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.sendEnterElement(NGCCRuntime.java:403)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCHandler.spawnChildFromEnterElement(NGCCHandler.java:99)
    at com.sun.xml.internal.xsom.impl.parser.state.Schema.enterElement(Schema.java:376)
    at com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime.startElement(NGCCRuntime.java:244)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.internal.xjc.util.SubtreeCutter.startElement(SubtreeCutter.java:93)
    at com.sun.tools.internal.xjc.reader.ExtensionBindingChecker.startElement(ExtensionBindingChecker.java:135)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.internal.xjc.reader.xmlschema.parser.IncorrectNamespaceURIChecker.startElement(IncorrectNamespaceURIChecker.java:113)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.internal.xjc.reader.xmlschema.parser.CustomizationContextChecker.startElement(CustomizationContextChecker.java:178)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.internal.xjc.ModelLoader$SpeculationChecker.startElement(ModelLoader.java:458)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.internal.xjc.reader.internalizer.VersionChecker.startElement(VersionChecker.java:88)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
    at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357)
    at com.sun.xml.internal.xsom.parser.JAXPParser.parse(JAXPParser.java:85)
    at com.sun.tools.internal.xjc.ModelLoader$2.parse(ModelLoader.java:482)
    at com.sun.tools.internal.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:254)
    at com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:332)
    at com.sun.xml.internal.xsom.impl.parser.ParserContext.parse(ParserContext.java:113)
    at com.sun.xml.internal.xsom.parser.XSOMParser.parse(XSOMParser.java:156)
    at com.sun.tools.internal.xjc.ModelLoader.createXSOMSpeculative(ModelLoader.java:499)
    at com.sun.tools.internal.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:354)
    at com.sun.tools.internal.xjc.ModelLoader.load(ModelLoader.java:159)
    at com.sun.tools.internal.xjc.ModelLoader.load(ModelLoader.java:104)
    at com.sun.tools.internal.xjc.Driver.run(Driver.java:318)
    at com.sun.tools.internal.xjc.Driver.run(Driver.java:185)
    at com.sun.tools.internal.xjc.Driver._main(Driver.java:108)
    at com.sun.tools.internal.xjc.Driver.access$000(Driver.java:65)
    at com.sun.tools.internal.xjc.Driver$1.run(Driver.java:88)
Caused by: javax.xml.bind.JAXBException
 - with linked exception:
[com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
com.sun.xml.internal.bind.api.impl.NameConverter is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at com.sun.xml.internal.bind.api.impl.NameConverter
        at public com.sun.xml.internal.bind.api.impl.NameConverter com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.nameConverter
        at com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGlobalBinding
]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:262)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:441)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
    at com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationContext(BindInfo.java:321)
    ... 76 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
com.sun.xml.internal.bind.api.impl.NameConverter is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at com.sun.xml.internal.bind.api.impl.NameConverter
        at public com.sun.xml.internal.bind.api.impl.NameConverter com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.nameConverter
        at com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGlobalBinding

    at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:460)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:292)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:139)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1138)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:162)
    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 javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
    ... 81 more
4

1 回答 1

0

请将 JAXB impl 依赖项添加到我的编译范围,例如

compile 'com.sun.xml.bind:jaxb-impl:2.2.7'
于 2017-12-25T05:32:10.730 回答