简体   繁体   English

JAXB moxy错误:通过属性映射处理外部元数据时遇到无效的参数类型

[英]JAXB moxy Error: Invalid parameter type encountered while processing external metadata via properties Map

I followed this example to implement moxy in my project. 我按照此示例在项目中实现了moxy。 However I am getting the following error and have not been able to find a solution yet. 但是,我收到以下错误,尚未能够找到解决方案。

   Exception in thread "main" Local Exception Stack: 
   Exception [EclipseLink-50019] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.JAXBException
   Exception Description: Invalid parameter type encountered while processing external metadata via properties Map.  The Value associated with Key [eclipselink-oxm-xml] is required to be one of [Map<String, Source>], where String = package, Source = handle to metadata file.
    at org.eclipse.persistence.exceptions.JAXBException.incorrectValueParameterTypeForOxmXmlKey(JAXBException.java:245)
    at org.eclipse.persistence.jaxb.JAXBContextFactory.getXmlBindingsFromProperties(JAXBContextFactory.java:330)
    at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:115)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:128)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:249)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
    at blog.bindingfile.Demo.main(Demo.java:13)

I am new to jaxb and moxy, any help towards getting my moxy setup is appreciated. 我是jaxb和moxy的新手,对获得我的moxy设置的任何帮助均表示赞赏。

Use instance of Source, it is in the error message: 使用Source的实例,它在错误消息中:

 Value associated with Key [eclipselink-oxm-xml] is required to be one of [Map<String, Source>], where String = package, Source = handle to metadata file.

example: 例:

 ... 
 javax.xml.transform.Source source = 
   new javax.xml.transform.stream.StreamSource("mypackage-metadata.xml") 
 map.put("example.mypackage", source);
 ...

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM