FORM FILTER MODULE ERROR "HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException:"

am updating the Form Filter Module torun on platform 2+ , it loads succesfuly , but when i click on a form to filter, it returns this error

https://hastebin.com/obukokiheb.swift

how do i go about it.

@dkayiwa @tendomart @darius @wyclif

here is the code https://github.com/mozzy11/openmrs-module-formfilter/tree/PLAT-39

@mozzy are there any new changes to the tables or any new models introduced?

no , i havent yet introduced any changes to to the tables .

here is the commit

If you look at the error message, it says

Connection is read-only. Queries leading to data modification are not allowed

I peeked at the code. In fact it is doing something illegal. The code in FormFilterServiceImpl:75 in fact creates a new form filter object and then returns it. But this line of code declares it should be in a read-only transaction. So the code is incorrect, and Hibernate is correct to throw this error.

It seems this was added in this commit, from 2012, but the commit message does not say why this is done.

@ningosi, can you comment on how eSaude is using this module? E.g. are you purely configuring it via the API or something, thus you don’t hit this bug in the UI?

Version 1.0.0 just run fine of 1.11.5 and after filtering forms via such, I am able to click on it and it loads properly. We just use the module on the patient dashboard. See the attached for reviewfiltering and clicking on one loads without errors

@mozzy I think the correct approach here would be to Branch off at the last known good release, and make a release like 1.0.1 that supports platform 2.x.

I had made a suggestion just from reading Nicholas’s comment, but now that I peek at the code I don’t think it will work.

@ningosi the offending code is present in the 1.0.0 tag also. Can you verify if this works after you create a new form, and click on it the first time?

(@mozzy what are your steps to reproduce this error? between creating a form, installing the module, etc, what order do you do things?)

1 Like

the module installs succesfully, and starts succesfully, but when i click on “manage Form Filtering” and i try to select a form, then it throws the error

it fails at this level

I just created an html form in 1.11.5 running 1.0 version of form filter and clicked on it, filled the observations and saved successfully. Let me try testing @mozzy PR in 2.x and see what happens

1 Like

@ningosi wat could be your test results

Let me test it today. I have been out sick since last week. I will communicate

1 Like

sorry about that bro…

coz i was trying to solve that error, i pushed more than one commit and havent yet squashed them . but u can use the comits here

https://github.com/openmrs/openmrs-module-formfilter/pull/1/commits/c3a327cd6a6151f4b604b7ed62601aa2635217a4 for the test

Testing platform version 2.0.5, form filter module version 1.2(I checked out that tag from master)

The module loaded and started successfully. When I click on Manage Form Filtering, the list of forms appears, When I click on any one of the available form I get error as you reported. When I load the patient dashboard(having patient context) and click on Form Entry tab am able to load the form without errors(That has been our use case)

I think it makes sense for the second results in that every form should be filled for a patient, or before filling a form, one should be in a patient context. I maybe wrong maybe that module intention was to fit in both settings, please correct me @darius. Maybe this module do not need that extension point on the UI, or on clicking on it, one must be forced to select a patient.

so what the way forwad , as per @ningosi results??

@burke @darius @tendomart @dkayiwa

@mozzy there are several possible approaches here (going from worst to best)

  1. Say that “it was already broken in the UI, but it works for @ningosi in their use case, so this is good enough” so just release this as-is
  2. Do the quickest hack to make the code work (remove read-only from here)
  3. Explore the code, understand what it’s currently trying to do, and then refactor it so that (a) getFormFilter(Form) is read-only, (b) but it otherwise behaves as intended. I presume this means moving the “create new FormFilter object for a Form” logic from the service into the web controller.

Even #1 is “good enough” at a basic level; it depends on how much time you have to look into this.

thx @darius ive taken option 2 and it works pretty fine