This is the error I see when I try to deploy to Jboss:
Cannot upload deployment: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./ProblemsDataService" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./ProblemsDataService: java.lang.RuntimeException: java.lang.IllegalArgumentException: Conflicting setter definitions for property \"id\": ca.uhn.fhir.model.api.BaseIdentifiableElement#setId(1 params) vs ca.uhn.fhir.model.api.BaseIdentifiableElement#setId(1 params) Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Conflicting setter definitions for property \"id\": ca.uhn.fhir.model.api.BaseIdentifiableElement#setId(1 params) vs ca.uhn.fhir.model.api.BaseIdentifiableElement#setId(1 params) Caused by: java.lang.IllegalArgumentException: Conflicting setter definitions for property \"id\": ca.uhn.fhir.model.api.BaseIdentifiableElement#setId(1 params) vs ca.uhn.fhir.model.api.BaseIdentifiableElement#setId(1 params)"}}
Select all Open in new window
This is the method call that is giving the issue:
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.primitive.IdDt;
import com.x.fhir.FhirCondition;
import com.x.fhir.FhirOrder;
import com.x.responses.ErrorResponse;
import com.x.service.ProblemsService;
import com.fasterxml.jackson.annotation.JsonIgnore;
@RestController
@RequestMapping("/problems")
@Api(value = "Patients Problems", description = "Endpoint for Patient Problems")
public class ProblemController {
@Autowired
ProblemsService patProblemService;
/**
* Get a Patient information
*
* @param id
* @return
* @throws java.lang.Exception
*/
@SuppressWarnings("rawtypes")
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/bean/{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.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 401, message = "Unauthorized", response = ErrorResponse.class),
@ApiResponse(code = 403, message = "Forbidden", response = ErrorResponse.class),
@ApiResponse(code = 404, message = "Not Found", response = ErrorResponse.class)})
public Bundle searchFhirOrder(@PathVariable("id") long id) throws Exception {
List<FhirOrder> lstFhirOrder = new ArrayList<FhirOrder>();
FhirOrder fo = new FhirOrder();
lstFhirOrder.add(fo);
Iterator i = lstFhirOrder.iterator();
Bundle bundleCondition = new Bundle();
while (i.hasNext())
bundleCondition.addEntry().setResource((FhirOrder)i.next());
return bundleCondition;
}
}
Select all Open in new window
And this is the object it refers to:
package com.x.fhir;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.dstu2.resource.Order;
@ResourceDef(name="Order")
public class FhirOrder extends Order implements java.io.Serializable {
private static final long serialVersionUID = 1L;
}
Select all Open in new window
This is a dependency that had to be included in the pom.xml file:
<!-- HAPI -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>1.6</version>
</dependency>
Select all Open in new window
Can someone explain how to get rid of the error?
Based on this post (
http://stackoverflow.com/questions/6346018/deserializing-json-into-object-with-overloaded-methods-using-jackson ) I tried to add the JsonIgnore annotation to the bean and also to use a MixIn class and but the same error occurred. My attempt in the first case shown below:
package com.x.fhir;
import org.hl7.fhir.instance.model.api.IIdType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.dstu2.resource.BaseResource;
import ca.uhn.fhir.model.dstu2.resource.Order;
import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.IdDt;
@ResourceDef(name="Order")
public class FhirOrder extends Order implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@JsonIgnore
public BaseResource setId(String theId){
return super.setId(theId);
}
@JsonIgnore
public BaseResource setId(IIdType theId){
return super.setId(theId);
}
@JsonIgnore
public void setId(IdDt theId){
super.setId(theId);
}
@JsonIgnore
public Order setDate(DateTimeDt theValue){
return super.setDate(theValue);
}
@JsonIgnore
public IdDt getId(){
return super.getId();
}
}
Select all Open in new window