title: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper while trying to get JSON response
body: <p>I am making application using JAVA EE,JAX-RS,JPA,GLASSFISH. Response is working properly in case of <strong>MediaType.APPLICATION_XML</strong>. It's not working in <strong>MediaType.APPLICATION_JSON</strong>.</p>
  
  <p>Here is my pojo class </p>
  
  <pre><code>@Entity
  @XmlRootElement
  public class Book {
      private int id;
      private String name;
      private String publication;
      private String price;
  
      @Id
      @Column(name = "id")
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      @Basic
      @Column(name = "name")
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @Basic
      @Column(name = "publication")
      public String getPublication() {
          return publication;
      }
  
      public void setPublication(String publication) {
          this.publication = publication;
      }
  
      @Basic
      @Column(name = "price")
      public String getPrice() {
          return price;
      }
  
      public void setPrice(String price) {
          this.price = price;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
  
          Book book = (Book) o;
  
          if (id != book.id) return false;
          if (name != null ? !name.equals(book.name) : book.name != null) return false;
          if (publication != null ? !publication.equals(book.publication) : book.publication != null) return false;
          if (price != null ? !price.equals(book.price) : book.price != null) return false;
  
          return true;
      }
  
      @Override
      public int hashCode() {
          int result = id;
          result = 31 * result + (name != null ? name.hashCode() : 0);
          result = 31 * result + (publication != null ? publication.hashCode() : 0);
          result = 31 * result + (price != null ? price.hashCode() : 0);
          return result;
      }
  }
  </code></pre>
  
  <p>Here is the pom.xml file.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.rajesh&lt;/groupId&gt;
      &lt;artifactId&gt;Library&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax&lt;/groupId&gt;
              &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
              &lt;version&gt;7.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.6&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.6&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Resource class for endpoint</p>
  
  <pre><code>@Path("books")
  public class BookResource {
      @GET
      @Path("{bookId}")
      @Produces({MediaType.APPLICATION_JSON})
      public Response getBookById(@PathParam("bookId") int id) {
          EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("abc");
          EntityManager entityManager = entityManagerFactory.createEntityManager();
          Book book = entityManager.find(Book.class, id);
          if (book == null) {
              return Response.status(Response.Status.NOT_FOUND).build();
          }
          return Response.status(Response.Status.OK).entity(book).build();
      }
  }
  </code></pre>