Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Conflicting setter definitions for property Exception

Posted on 2016-07-18
5
Medium Priority
?
332 Views
Last Modified: 2016-08-17
I get the following error whenever I attempt to return an object from my controller

 Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Conflicting setter definitions for property \"active\": ca.uhn.fhir.model.dstu2.resource.Patient#setActive(1 params) vs ca.uhn.fhir.model.dstu2.resource.Patient#setActive(1 params)
    Caused by: java.lang.IllegalArgumentException: Conflicting setter definitions for property \"active\": ca.uhn.fhir.model.dstu2.resource.Patient#setActive(1 params) vs ca.uhn.fhir.model.dstu2.resource.Patient#setActive(1 params)"}}
DEBUG: org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver - Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver
DEBUG: org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver - Instantiated JPA aware TraversableResolver of type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
DEBUG: org.hibernate.validator.internal.xml.ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.

Open in new window


The Controller code is as shown below:
	@ResponseStatus(HttpStatus.OK)
	@RequestMapping(value = "/fhir/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	@ApiOperation(tags = "Fhir Patients Information", httpMethod = "GET", value = "Get Fhir Patient Information", notes = "Get Fhir Patient Information.")
	public FhirPatient getFhirPatientInfo(@PathVariable("id") long id) throws Exception {
		
		Patient patient = patientDAO.findPatientById(123708L);
		FhirPatient fhirPatient = FhirConverter.transformPatientToFhirPatient(patient);
		return fhirPatient;

	}

Open in new window


The FhirConverter code is as shown below
    public static FhirPatient getFhirPatientFromPatient(Patient patient){
        FhirPatient fhirPatient = new FhirPatient();
        
        // Add an MRN (a patient identifier)
        IdentifierDt id = fhirPatient.addIdentifier();
        id.setValue(patient.getPatientId().toString());
        id.setUse(IdentifierUseEnum.OFFICIAL);
        
        // Add a name
        HumanNameDt name = fhirPatient.addName();
        name.setUse(NameUseEnum.OFFICIAL);
        name.addFamily(patient.getLastName());
        name.addGiven(patient.getFirstName()).addGiven(patient.getMiddleName());
}

Open in new window



The Fhir object is created as follows:

package com.entity.fhir;


import java.util.Date;

import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.primitive.BooleanDt;



public class FhirPatient extends Patient implements java.io.Serializable{


              /**
               * 
               */
	      private static final long serialVersionUID = 1L;
	
	
	      private Integer pcpId;
              private Date dateOfBirth;
              private Integer maritialStatus;
              private Integer officeId;
              private Integer practiceId;



              
              public Integer getPcpId() {
                             return this.pcpId;
              }

              public void setPcpId(Integer pcpId) {
                             this.pcpId = pcpId;
              }

              
              public Date getDateOfBirth() {
                             return this.dateOfBirth;
              }
              
              public void setDateOfBirth(Date dateOfBirth) {
                             this.dateOfBirth = dateOfBirth;
              }
              
              public Integer getMaritialStatus() {
                             return this.maritialStatus;
              }

              public void setMaritialStatus(Integer maritialStatus) {
                             this.maritialStatus = maritialStatus;
              }
              
              public Integer getOfficeId() {
                             return officeId;
              }
              public void setOfficeId(Integer officeId) {
                             this.officeId = officeId;
              }
              
              public Integer getPracticeId() {
                             return practiceId;
              }
              public void setPracticeId(Integer practiceId) {
                             this.practiceId = practiceId;
              }
              

              
}

Open in new window



Can you see any reason why when the controller method, when accessed via Swagger, throws this error
0
Comment
Question by:onaled777
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:gurpsbassi
ID: 41717829
Please also post the patient class.
0
 

Author Comment

by:onaled777
ID: 41717875
The Patient Class can be found here:

http://hapifhir.io/apidocs-dstu2/ca/uhn/fhir/model/dstu2/resource/Patient.html

I have tried putting @JsonIgnore around some of the inherited methods, but that only leads to another field with a similar error.  I am not sure if that is the right approach.
0
 
LVL 16

Expert Comment

by:gurpsbassi
ID: 41718216
can you supply the source?
0
 

Author Comment

by:onaled777
ID: 41719133
@JsonIgnore
              public Boolean getActive(){
            	  return this.active;
              }
              
              @JsonIgnore
              public void setActive(Boolean active){
            	  this.active = active;
              }
              
              @JsonIgnore
              public String getGender(){
            	  return this.gender;
              }
  
              @JsonIgnore
              public Patient setGender(String gender){
            	  return null;
              }

Open in new window

0
 
LVL 16

Accepted Solution

by:
gurpsbassi earned 2000 total points
ID: 41719142
the whole source please for the class. right from the public class...{ until the last brace }
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question