[Coldbox 6.0.0] [CBORM 2.5.0] ConcurrentModificationException

Hi all,

The last mention of the error above was 5 years ago, so I thought I’d give it a comeback! My aim is to save an entity and then return a list which includes this new entity - in the same request.

I save a new entity from a standard AJAX POST request:

var bookingSimple = populateModel(
model = bookingSimpleService.new(),
composeRelationships = true
This saves successfully.

In the same request, I trigger an event that runs a newCriteria() which should return a list containing the previously saved entity: [I have removed a number of other “joinTo”, “eq” and “isTrue” 's for simplicity. [A MapObject can have many BookingSimples]]:

prc.BookedMapObjects = mapObjectService.newCriteria()
.joinTo( “BookingSimples”, “BookingSimple” )

It gives me the ConcurrentModificationException.

I can successfully run this event independently from the save.

The only workaround I can think of is to make 2 AJAX requests…any other suggestions?

After another strong coffee, I think I have resolved this - but I don’t know why a ConcurrentModificationException was being triggered.

The rc contains an element “BookingDate” which is in dd/mm/yyyy format. I convert this to a ‘proper date’ before populateModel and saving (otherwise the month and day get switched in the database). However the list event also requires a rc.BookingDate in dd/mm/yyyy format (in order to prepare a list of bookings). The first part of this function is again, to convert rc.BookingDate to a proper date - even though it is now (due to the save event) already in the correct format.

Converting the date back to dd/mm/yyyy format after the save has resolved the error. Why the second event was triggering a ConcurrentModificationException and not some sort of array error (i.e. not finding a ‘/’ to split my formatted date into it’s parts), I don’t know.

I’ll have to chalk this one up to experience.

Firstly, without you providing the full stack trace, it’s really impossible to tell what’s happening. Secondly, this is 99.9% chance a bug in Lucee or possibly the incredibly old version of Hibernate that Lucee ships. I would post to the Lucee ticket system with repro code and a stack trace

Hi Brad,

Understood. I am now getting an increasing number of ConcurrentModificationException’s for errors that have nothing to do with database interactions. So I am trying to delve a bit deeper…

I have attached a stack trace for the following example.

function index( event, rc, prc )
prc.test1 = checkinService.newCriteria().list();
prc.test2 = bookingSimpleService.newCriteria().list();
event.setView( “test/index” ).noLayou();

This gives ConcurrentModificationException - but when I add the “t” (making “noLayout”), everything is fine. One thing to note: bookingSimple can have many checkin’s.

Individually, prc.test1 and prc.test2 throw the correct exception.

Correcting noLayout, and putting an incorrect variable name in the view, also results in ConcurrentModificationException rather than a unknown variable error.

I have tried a variety of other ‘services’ and but it looks like something specific to bookingSimple and checkin, so I have also attached these.

However, once the error has been triggered once, it does not matter which service I replace for test1 and test2. Any 2 x calls to any 2 x services will fail with ConcurrentModificationException (unless the noLayout corrrection is applied). There’s no difference in the symptoms with a fwreinit, so a server restart is required to allow non-related services to throw the correct error.

stacktrace.txt (11.5 KB)

BookingSimple.cfc and Checkin.cfc

models.zip (1.75 KB)