无法让EclipseLink MOXy工作 [英] Cannot get EclipseLink MOXy to work

查看:82
本文介绍了无法让EclipseLink MOXy工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JAXB的新手,我想使用EclipseLink MOXy更改默认的名称空间前缀。我的package-info.java包含以下代码行:

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;

我的jaxb.properties文件包含以下行:

And my jaxb.properties file has the following line:

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory

我已将eclipselink.jar添加到CLASSPATH,package-info.java和jaxb.properties文件与我的模型类位于同一个包中,但是,当我运行程序时我收到以下错误消息:

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)

我使用EclipseLink版本2.3.0和2.0.2尝试了这个并且仍然得到相同的错误消息。有没有人碰巧知道可能是什么问题?

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?

非常感谢提前

推荐答案

根据异常消息,您似乎已将 jaxb.properties 文件更正:

You appear to have your jaxb.properties file correct based on the exception 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)

确认 org.eclipse.persistence.jaxb.JAXBContextFactory 在你的类路径上你可以尝试:

To confirm that org.eclipse.persistence.jaxb.JAXBContextFactory is on your classpath can you try:

JAXBContext jc = JAXBContextFactory.createContext("com.core.mymodel", null);

要做更基本的确认,你可以运行:

To do a more basic confirmation can you run:

System.out.println(org.eclipse.persistence.Version.getVersion());

更多信息

  • http://bdoughan.blogspot.com/2011/05/specifying-eclipselink-moxy-as-your.html

这篇关于无法让EclipseLink MOXy工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆