Wasif Kirmani
Wasif Kirmani

Reputation: 1331

Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper

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

Upvotes: 3

Views: 11134

Answers (1)

brunocrt
brunocrt

Reputation: 780

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

Upvotes: 1

Related Questions