IndexOutOfBoundsException during lab sync

I’m seeing the below error in bahmni-lab.log and lab sync is not working.

I already stopped both openmrs and openelis, truncated markers, failed_events and failed_event_retry_log on both sides and restarted them both but the errors keep popping up as soon as I make a lab request for any patient.

Can anyone help me figure out what’s going on here?

Thanks a bunch!

2018-04-04 20:00:30,058 ERROR [ELIS][AtomFeedClient] Failed to process failed event. FailedEvent{failedAt=1522868220114, event=Event{id='tag:atomfeed.ict4h.org:59edd246-2fcd-47fd-a6ae-23a510abdb60', content='/openmrs/ws/rest/v1/bahmnicore/bahmniencounter/08a80620-1524-41e3-9eef-5db38dc26042?includeAll=true'}, errorMessage='Failed processing event in feed [http://localhost:8050/openmrs/ws/atomfeed/encounter/1]
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at org.bahmni.feed.openelis.feed.transaction.support.AtomFeedHibernateTransactionManager.executeWithTransaction(AtomFeedHibernateTransactionManager.java:51)
    at org.ict4h.atomfeed.client.service.AtomFeedClient.processEvents(AtomFeedClient.java:68)
    at org.bahmni.feed.openelis.feed.job.OpenELISFeedReaderJob.processEvents(OpenELISFeedReaderJob.java:73)
    at org.bahmni.feed.openelis.feed.job.OpenELISFeedReaderJob.execute(OpenELISFeedReaderJob.java:57)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:207)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:560)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker$SampleItemTestCache.add(EncounterFeedWorker.java:543)
    at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker.getSampleTestCollections(EncounterFeedWorker.java:393)
    at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker.createSample(EncounterFeedWorker.java:238)
    at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker.process(EncounterFeedWorker.java:181)
    at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker.process(EncounterFeedWorker.java:163)
    at org.ict4h.atomfeed.client.service.AtomFeedClient$EventProcessor.doInTransaction(AtomFeedClient.java:168)
    at org.ict4h.atomfeed.transaction.AFTransactionWorkWithoutResult.execute(AFTransactionWorkWithoutResult.java:6)
    at org.bahmni.feed.openelis.feed.transaction.support.AtomFeedHibernateTransactionManager.executeWithTransaction(AtomFeedHibernateTransactionManager.java:42)
    ... 5 more

', feedUri=‘http://localhost:8050/openmrs/ws/atomfeed/encounter/recent’} java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at org.bahmni.feed.openelis.feed.transaction.support.AtomFeedHibernateTransactionManager.executeWithTransaction(AtomFeedHibernateTransactionManager.java:51) at org.ict4h.atomfeed.client.service.AtomFeedClient.processFailedEvents(AtomFeedClient.java:98) at org.bahmni.feed.openelis.feed.job.OpenELISFeedFailedEventsJob.processFailedEvents(OpenELISFeedFailedEventsJob.java:37) at org.bahmni.feed.openelis.feed.job.OpenELISFeedFailedEventsJob.execute(OpenELISFeedFailedEventsJob.java:30) at org.quartz.core.JobRunShell.run(JobRunShell.java:207) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:560) Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker$SampleItemTestCache.add(EncounterFeedWorker.java:543) at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker.getSampleTestCollections(EncounterFeedWorker.java:393) at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker.createSample(EncounterFeedWorker.java:238) at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker.process(EncounterFeedWorker.java:181) at org.bahmni.feed.openelis.feed.event.EncounterFeedWorker.process(EncounterFeedWorker.java:163) at org.ict4h.atomfeed.client.service.AtomFeedClient$FailedEventProcessor.doInTransaction(AtomFeedClient.java:251) at org.ict4h.atomfeed.transaction.AFTransactionWorkWithoutResult.execute(AFTransactionWorkWithoutResult.java:6) at org.bahmni.feed.openelis.feed.transaction.support.AtomFeedHibernateTransactionManager.executeWithTransaction(AtomFeedHibernateTransactionManager.java:42) … 5 more

@ramses are you certain ,the source you’re fetching from contains data?

I’m not accessing any data source myself, I just installed bahmni with openMrs and openElis…

I see that an empty arraylist is being accessed and that this is a bug, but I’m not doing any development here…

@ramses have you considered the version compatibility,before anything else?

The main reason is the “test” or “panel” mentioned in the order was not found. I would try to dig deeper

  1. Find out for the given lab orders in the specified encounter (’/openmrs/ws/rest/v1/bahmnicore/bahmniencounter/08a80620-1524-41e3-9eef-5db38dc26042?includeAll=true’)
  2. Check in OpenELIS whether the relevant test/panel is present.
  • find out the order relevant test/panel uuid
  • with that check postgres “clinlims” database whether the test is there.

select * from external_reference where external_id = <uuid of identified test/panel>

  1. If you find the test/panel not there, then you need to ensure that the test/panels are resynced first.
  • Maybe the test/panel sync failed before and hence the test/panel was not created.
  • One easy way to fix that is to just to OpenMRS concept dictionary, and save the test/panel again, which will raise an event for the test to be resynced. Ensure that the test is resynced to ELIS.
  • the failed event for the encounter might have stopped retrying. To fix that, identify the event in the clinlims.failed_events table, and reset the “retries” column to zero.

btw, Bahmni Apps has an atomfeed console, you can get some information from there as well, instead of having to login to the machine.