当前位置: 首页 > 知识库问答 >
问题:

Jaxb类在Jboss developer studio中生成错误

曾嘉言
2023-03-14

我在Jboss开发者工作室10.4和JDK 1.8中从xml模式定义文件生成JaxB类时得到了JAXBExc0019。

我是否缺少任何配置

[com.sun.xml.bind.v2.runtime.IllegalAnnotationsExceptions: 1次IllegalAnnotationExceptionscom.sun.xml.internal.bind.api.impl.NameConzer是一个接口,JAXB不能处理接口.这个问题与以下位置有关:在com.sun.xml.internal.bind.api.impl.NameConzer在公共com.sun.xml.internal.bind.api.impl.NameConzercom.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGobalBinding.name转换器在com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIGobal绑定]

完成下面的stackstrace:

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

共有1个答案

卫嘉佑
2023-03-14

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

compile 'com.sun.xml.bind:jaxb-impl:2.2.7'
 类似资料:
  • 问题内容: 我正在使用Java 6,JaxB 2和SpringSource Tool Suite(与Eclipse相同)。我编写了一些Java类,使用JaxB从中生成XML模式。但是,我注意到为了使用JaxB从Java对象生成XML文档的功能,我需要一个ObjectFactory。 如何生成ObjectFactory而不会浪费我现在已有的类? 问题答案: 更新 这个问题可能指的是创建一个角色的作用

  • 我有一个maven模型项目,我通过maven命令-clean install生成jaxb类,jaxb类在目标文件夹下生成,jar文件在目标文件夹下生成。m2存储库文件夹。 现在在我的另一个项目中,将这个jar添加为具有适当组id和artifactId的依赖项。 但我得到的是生成的jaxb类的ClassNotFoundException和编译错误。 我正在更新我的问题以添加更多细节。 模型项目的Po

  • MOXy BeanValide使我能够将验证添加到我的JAXB类中。 使用MOXy的“Bean Validation Plugin”,我可以根据预先存在的模式中的限制/方面在生成的JAXB类中进行Bean验证。 但是,有没有任何方法可以基于JAXB注释的java类的Bean验证注释生成带有限制/facetsb的模式? 在“模式优先”生成java时,XJC有一个方便的插件体系结构,但是是否有任何等效

  • 问题内容: 我正在使用JAXB在Maven中使用JAXB插件从XSD生成bean。一切正常,希望代码包含每个字段的isSetXXXXXX()方法。 例如 对于字段 firstName ,它将产生以下代码: 这是isSetFirstName()方法引起的问题,我不希望JAXB生成这些问题。 有没有办法阻止这种行为? 谢谢。 更新 解决此问题:问题出在xjb文件中,generateIsSetMetho

  • 此程序未编译。有什么问题? 显示以下错误。 错误C2679:二进制' 在尝试匹配参数列表时(std::ostream,std::string)。。。。。\maptest\mapt\mapt\mapt。cpp(16):使用[T=int]编译类模板成员函数“void Data::WriteData(void)”时

  • 问题内容: 我正在尝试使用Java从XSD文件中以编程方式生成JAXB类。我使用以下代码片段实现了这一目的: 生成的类仅包含字段的方法。但是,我想包括,和方法为好。生成代码时该怎么做? 问题答案: 在GitHub网站上,您将找到JAXB2 Basics项目 ,该项目提供了一组通用的实用程序插件,其中包括4个应解决您要实现的目标的插件: 等于插件 HashCode插件 二传手插件 ToString插