title: Getting 500 internal server error when trying to use the put and post methods on postman to my spring rest app
body: <p>I tried both with xml and json. When using POST it adds null elements to the list and gives java.lang.NoClassDefFoundError exception. When using PUT I receive a Runtime exception. The GET methods are running properly. Can you please help me debug the code? 
  Here are my service and controller classes.</p>
  
  <pre><code>@Consumes("application/xml,application/json")
  @Produces("application/xml,application/json")
  @RestController
  public class PatientController {
  
      @Autowired
      private PatientService patientService;
  
      @GetMapping("patientservice/patients")
      List&lt;Patient&gt; getPatients() {
  
          return patientService.getPatients();
      }
  
      @GetMapping("patientservice/patients/{id}")
      Patient getPatient(@PathVariable("id") Long id ) {
          return patientService.getPatient(id);
      }
  
      @PostMapping("patientservice/patients" )
      Response createPatient(Patient patient) {
          return patientService.createPatient(patient);
      }
  
      @PutMapping("patientservice/patients")
      Response updatePatient(Patient patient) {
          return patientService.updatePatient(patient);
      }
  }
  
  @Service
  public class PatientServiceImpl implements PatientService {
  
      Map&lt;Long, Patient&gt; patients = new HashMap&lt;&gt;();
      Long currentId = new Long(123);
  
      public PatientServiceImpl() {
          init();
      }
  
      void init() {
          Patient patient = new Patient();
          patient.setId(currentId);
          patient.setName("John");
          Patient patient1 = new Patient();
          patient1.setId(new Long(++currentId));
          patient1.setName("Mike");
          Patient patient2 = new Patient();
          patient2.setId(new Long(++currentId));
          patient2.setName("Dave");
          patients.put(patient.getId(), patient);
          patients.put(patient1.getId(), patient1);
          patients.put(patient2.getId(), patient2);
      }
  
      @Override
      public List&lt;Patient&gt; getPatients() {
          Collection&lt;Patient&gt; results = patients.values();
          List&lt;Patient&gt; response = new ArrayList&lt;&gt;(results);
          return response;
      }
  
      @Override
      public Patient getPatient(Long id) {
          if (patients.get(id) == null) {
              throw new NotFoundException();
          }
          return patients.get(id);
      }
  
      @Override
      public Response createPatient(Patient patient) {
          patient.setId(++currentId);
          patients.put(patient.getId(), patient);
          return Response.ok(patient).build();
      }
  
      @Override
      public Response updatePatient(Patient patient) {
  
          Patient currentPatient = patients.get(patient.getId());
  
          Response response;
          if (currentPatient != null) {
              patients.put(patient.getId(), patient);
              response = Response.ok().build();
          } else {
              throw new PatientBusinessException();
          }
          return response;
      }
  
      @Override
      public Response deletePatient(Long id) {
          Patient patient = patients.get(id);
  
          Response response;
  
          if (patient != null) {
              patients.remove(id);
              response = Response.ok().build();
          } else {
              response = Response.notModified().build();
          }
          return response;
      }
  
  }
  </code></pre>
  
  <p>pom.xml</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.bharath.restws&lt;/groupId&gt;
      &lt;artifactId&gt;restws&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;restws&lt;/name&gt;
      &lt;description&gt;Patient REST Services&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.5.9.RELEASE&lt;/version&gt;
          &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-spring-boot-starter-jaxrs&lt;/artifactId&gt;
              &lt;version&gt;3.1.11&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-jaxrs&lt;/artifactId&gt;
              &lt;version&gt;1.9.13&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-xc&lt;/artifactId&gt;
              &lt;version&gt;1.9.13&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-logging&lt;/groupId&gt;
              &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/logutil/logutil --&gt;
          &lt;!-- &lt;dependency&gt;
              &lt;groupId&gt;logutil&lt;/groupId&gt;
              &lt;artifactId&gt;logutil&lt;/artifactId&gt;
              &lt;version&gt;0.2.1&lt;/version&gt;
          &lt;/dependency&gt; --&gt;
          &lt;!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-common-utilities --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-common-utilities&lt;/artifactId&gt;
              &lt;version&gt;2.0.6&lt;/version&gt;
          &lt;/dependency&gt;
  
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  
  &lt;/project&gt;
  </code></pre>