Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper
There is probably a missing dependency in your project. Try to adding this dependency to your pom.xml
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.6.0</version>
</dependency>
This is the EclipseLink project for Object-XML binding and JAXB implementation. This also includes JSON binding support.
Reference: http://wiki.eclipse.org/EclipseLink/Maven
Wasif Kirmani
Updated on June 04, 2022Comments
-
Wasif Kirmani almost 2 years
I have been trying to get a dto object in json format as a response from my webservice. Webservice is developed in Spring Framework. But, whenever I try to access my application either from curl or from browser it gives me following exception on server-side.
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper
My dto is something like this:
public class UserDto { @JsonProperty private String id; @JsonProperty private String userRole; //.... Getter & Setters skipped }
My controller method is like:
@GET @Path("getUser") @Produces({"application/xml",MediaType.APPLICATION_JSON_VALUE}) public UserDto GetLoggedinUser() { return new UserDto("wasif kirmani"); }
I don't know where am I going wrong?
Environment: Server: GlassFish 4.1.1 Java: 6EE