Find Patient by Fingerprint

I have managed to reach the server-side. Am using Ajax and the Controller. However, one small thing is disturbing: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

The client does not seem to receive a response in the success callback method.

Here is my client-side code:

<script type="text/javascript">
function searchFingerPrint(){
	var baseUrl ="http://localhost:8080/openmrs/coreapps/clinicianfacing/patient.page?patientId=";
	jq.ajax({
		url : "${ ui.actionLink('searchForPatientByFingerPrint') }",
		method : "POST",
		data: {"datakey": "fingerPrintInBase64"},
		success : function(returnedPatientUuid) {
		    alert("Data returned: "+returnedPatientUuid);
			window.location = baseUrl.concat(returnedPatientUuid);
		},
		error : function(e) {
		   alert("Ooops: "+e.message);
	    }
	});
}</script>

Server-side-code:

	public @ResponseBody String searchForPatientByFingerPrint(
        @RequestParam(value = "datakey", required = false)String fingerPrintInBase64){
	//String patientSearchPageUrl = "http://localhost:8080/openmrs/coreapps/findpatient/findPatient.page?app=patients.findPatientByFingerprint";
	String fingerPrintPersonAttributeTypeUUID = "0fe8824e-f9f8-42fa-a919-4d2dcd00a5da";
       
     String uuid ="null";
	 System.out.println("Server reached");
	//search patient attribute: leftIndexFingerPrint
	List<Patient> patients = Context.getPatientService().getAllPatients();
	
	System.out.println("Number of Patients: "+patients.size());
	
	if(fingerPrintInBase64!= null){
		for(Patient patientInstance : patients){
			List<PersonAttribute> personAttributes = patientInstance.getActiveAttributes();
			
			for(PersonAttribute personAttribute: personAttributes){
				System.out.println("Person Attribute: "+personAttribute.getValue());
				
					System.out.println("Person Attribute Type UUID: "+personAttribute.getAttributeType().getUuid());
					if(personAttribute.getAttributeType().getUuid().equalsIgnoreCase(fingerPrintPersonAttributeTypeUUID)){
    					System.out.println("Person attributeType passed...");
    					//test if the base64 generated matches our stored base64 text
    					if(personAttribute.getValue() != null ){
    						System.out.println("Patient UUID: "+patientInstance.getUuid());
    						uuid = patientInstance.getUuid();
    						break;
    					}
    				}
				
			}//end person attribute loop

			if(uuid!="null"){
				break;
			}
		}//end patient loop
	}
	
	return uuid;
}

Server logs:

Server reached
Number of Patients: 3
Person Attribute: 0980008888
Person Attribute Type UUID: 14d4f066-15f5-102d-96e4-000c29c2a5d7
Person Attribute: 0789786843
Person Attribute Type UUID: 14d4f066-15f5-102d-96e4-000c29c2a5d7
Person Attribute: MyFingerPrint
Person Attribute Type UUID: 0fe8824e-f9f8-42fa-a919-4d2dcd00a5da
Person attributeType passed...
Patient UUID: 083c2982-ae98-4a29-9e89-322c97ccbb0d

I wonder why there is no success yet the client sends data to the server. I have debugged the server, and all lines in the controller are successfully reached.

Here is a screenshot of the error when debugging with the browser.

@k_joseph @wyclif @darius @dkayiwa @burke