ClassNotFoundException when trying to unmarshal class from JSON via JAXB (EclipseLink Moxy)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

ClassNotFoundException when trying to unmarshal class from JSON via JAXB (EclipseLink Moxy)

Hi all,
I have a library with a package of classes with JAXB annotations.
The package contains a file with the following content: "javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory".
The library has a compile time dependency (Maven) on EclipseLink.

I use EclipseLink Moxy to unmarshal JSON strings to Java objects.

This library is used by an application with a JAX-WS interface packaged in a war file. (The war contains the EclipseLink jar in its WEB-INF/lib folder.)
For testing purposes the war also contains a servlet which allows to use the functionality via browser.

I have used Tomee 1.7.4 and 1.7.5 both with the same behavior:

When I access the functionality via browser/servlet everything is working fine.
When I send a request  with a JAX-WS client, I get the following error:

javax.xml.bind.JAXBException: Provider org.eclipse.persistence.jaxb.JAXBContextFactory not found

Caused by: java.lang.ClassNotFoundException: org/eclipse/persistence/jaxb/JAXBContextFactory

When I copy the EclipseLink jar file (together with javax.json.jar and javax.json-api.jar) to Tomee/lib folder, the error goes away.

Why does it work with servlet but not with JAX-WS calls?
Is there another solution than copying the jars to Tomee/lib folder?

Kind regards,

Jan Heimburger

Information Systems

Phone: +49 351 88499 - 497   |   Fax: +49 351 88499 - 818   |   Mobile:    |   Email: [hidden email]<mailto:%%5B%5DUser%20email%20address%5B%5D%>

M?hlbauer ID Services GmbH   |   Manfred-von-Ardenne-Ring 15   |   01099 Dresden, Germany

Member of Muehlbauer Group

This email may contain confidential or proprietary information and company or business secrets, may be legally privileged, and is for the intended recipient only. Taking knowledge, disclosure, copying, distribution and reliance or any of it by anyone else is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. Many thanks.

Muehlbauer ID Services GmbH   |   Phone: +49 9461 952-0   |   Fax: +49 9461 952-1101   |   <mailto:[hidden email]>   |   <>
 Headquarters Roding, Josef-Muehlbauer-Platz 1, 93426 Roding, Germany   |   Commercial Register Regensburg, HRB #: 9094   |   Managing Directors: Hubert Forster, Karl Brandl   |   VAT #: DE 813871380