RESTful web service not producing or consuming JSON
Solution 1
It appears there is a bug in Eclipse Link. I think you may need to update to EclipseLink 2.6.1 and Jersey 2.19 or later see also this link. Otherwise you may be missing a dependency of org.eclipse.persistence.jaxb.BeanValidationHelper, since that class exists on your classpath but gets an exception trying to load into the JVM.
Solution 2
You need download this file
https://mega.nz/#!Ck0lVSRA!_KIjTl_8scQrak7jNTBepv3oqSKgeYsAVqjlvAarTbU
and replace in the next path:
C:\Program Files\glassfish-4.1.1\glassfish\modules
after open and close the IDE in my case I use Netbeans, test the RESTful.
sqr_hussain
Updated on June 04, 2022Comments
-
sqr_hussain almost 2 years
I have a project where I use RESTful web service on the server side to get and post data. It works fine if I specify the MediaType as XML (in @Consumes and @Produces, but it doesn't when it comes to JSON. Here is an example of a method
@GET @Path("{id}") @Produces({MediaType.APPLICATION_JSON}) public Product find(@PathParam("id") Integer id) { return super.find(id); }
When I try to call the service it throws the following exception:
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper
However, I tried to do what's explained in the answer of this question how correctly produce json by restful web service, but it changed nothing.
-
sqr_hussain over 8 yearsWhen I try to add Jersey library, EntityManager.createCriteriaQuery becomes unknown. I found the reason is that this library contains persistence.xml but I have no idea what to do in order to make my project work along with Jersey.
-
hack_on over 8 yearsI see that it is Jersey and Hibernate incompatibility problem. But before You put the new jar, you must have had a Jersey jar of some type? Cant you just update that?
-
Spielername about 7 yearsJust tried the solution mentioned here stackoverflow.com/questions/33722764/… which describes the necessary steps to have the updated jar mentioned in @Victor Jimenez answer. Works like a charm.