无法让 EclipseLink MOXy 工作
我是 JAXB 新手,我想使用 EclipseLink MOXy 更改默认名称空间前缀。我的 package-info.java 有以下代码行:
@javax.xml.bind.annotation.XmlSchema (
namespace="http://namespace.mysite.com/",
xmlns = {
@javax.xml.bind.annotation.XmlNs(prefix="myns",
namespaceURI="http://namespace.mysite.com/")
},
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED
)
package com.core.mymodel;
我的 jaxb.properties 文件有以下行:
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
我已将 eclipselink.jar 添加到 CLASSPATH,package-info.java 和 jaxb.properties 文件都在同一个包中但是,当我运行该程序时,我的模型类出现以下错误消息:
javax.xml.bind.JAXBException: Provider org.eclipse.persistence.jaxb.JAXBContextFactory not found
- with linked exception:
[java.lang.ClassNotFoundException: org.eclipse.persistence.jaxb.JAXBContextFactory]
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
我已使用 EclipseLink 版本 2.3.0 和 2.0.2 尝试过此操作,但仍然收到相同的错误消息。有谁知道可能是什么问题吗?
预先非常感谢
I'm new to JAXB and I want to change the default namespace prefix using EclipseLink MOXy. My package-info.java has the following code lines:
@javax.xml.bind.annotation.XmlSchema (
namespace="http://namespace.mysite.com/",
xmlns = {
@javax.xml.bind.annotation.XmlNs(prefix="myns",
namespaceURI="http://namespace.mysite.com/")
},
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED
)
package com.core.mymodel;
And my jaxb.properties file has the following line:
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
I have added eclipselink.jar to the CLASSPATH, both package-info.java and jaxb.properties files are in the same package as my model classes, however, when I run the program I get the following error message:
javax.xml.bind.JAXBException: Provider org.eclipse.persistence.jaxb.JAXBContextFactory not found
- with linked exception:
[java.lang.ClassNotFoundException: org.eclipse.persistence.jaxb.JAXBContextFactory]
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
I have tried this with EclipseLink versions 2.3.0 and 2.0.2 and still got the same error message. Does anyone happen to know what could be the problem?
Many thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据异常消息,您的 jaxb.properties 似乎是正确的:
要确认 org.eclipse.persistence.jaxb.JAXBContextFactory 位于您的类路径上,您可以尝试:
要进行更基本的确认,您可以运行:
了解更多信息
You appear to have your
jaxb.properties
file correct based on the exception message:To confirm that
org.eclipse.persistence.jaxb.JAXBContextFactory
is on your classpath can you try:To do a more basic confirmation can you run:
For More Information
只需显式指定 JAXBContext:
Simply specify the JAXBContext explicitly:
将其用作系统属性
Use it as a System property