Cannot get EclipseLink MOXy to work

I am new to JAXB and I want to change the default namespace prefix using EclipseLink MOXy. My package -info.java has the following lines of code:

@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 added eclipselink.jar to CLASSPATH, and the package-info.java and jaxb.properties files are in the same package as my model classes, however when I start 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 tried this with EclipseLink versions 2.3.0 and 2.0.2 and got the same error message. Does anyone know what could be the problem?

Thank you very much in advance

+6
source share
1 answer

Your jaxb.properties file jaxb.properties fixed 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) 

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

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

To perform a more basic confirmation, you can run:

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

Additional Information

+4
source

Source: https://habr.com/ru/post/893501/


All Articles