Error message when deleting the trainee in 8.6.1 Delete Objects with Cascading Delete

0
Hi. I am doing “Become rapid developer (Analyst)” and I am in step “8.6.1 Delete Objects with Cascading Delete”. It seems I did everything as it was written in this paragraph but when trying to delete participant I get error message.   Below there is a copy of the message from console. An error has occurred while handling the request. [User 'Anonymous_9726da3a-6ecf-4009-ba1e-b2840fa0e5e1' with session id '49496ece-XXXX-XXXX-XXXX-XXXXXXXX8d02' and roles 'Administrator'] -------- com.mendix.core.CoreRuntimeException: com.mendix.modules.microflowengine.MicroflowException: requirement failed: Change object 'NewTrainingEvent' should not be null     at MyFirstModule.ACO_ADE_Registration_SetTotalNumberOfRegistrations (Change : 'Change 'NewTrainingEvent' (TotalNumberOfRegistrations)')     at {"before":[],"action":{"type":"DeleteAction"},"after":[{}],"type":"EventExtendedAction"}     at {"type":"DeleteAction"} Advanced stacktrace:     at com.mendix.basis.actionmanagement.ActionManagerBase.executeInTransactionSync(ActionManagerBase.java:122) Caused by: com.mendix.modules.microflowengine.MicroflowException: requirement failed: Change object 'NewTrainingEvent' should not be null     at MyFirstModule.ACO_ADE_Registration_SetTotalNumberOfRegistrations (Change : 'Change 'NewTrainingEvent' (TotalNumberOfRegistrations)')     at {"before":[],"action":{"type":"DeleteAction"},"after":[{}],"type":"EventExtendedAction"}     at {"type":"DeleteAction"} Advanced stacktrace:     at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:146) Caused by: java.lang.IllegalArgumentException: requirement failed: Change object 'NewTrainingEvent' should not be null     at scala.Predef$.require(Predef.scala:281)     at com.mendix.modules.microflowengine.actions.mxobject.ChangeAction.execute(ChangeAction.scala:48)     at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47)     at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:201)     at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:157)     at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:46)     at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:71)     at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:49)     at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:54)     at com.mendix.basis.actionmanagement.ActionManagerBase$1.execute(ActionManagerBase.java:146)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.basis.actionmanagement.ActionManagerBase.executeSync(ActionManagerBase.java:151)     at com.mendix.basis.component.InternalCoreBase.executeSync(InternalCoreBase.java:437)     at com.mendix.basis.actionmanagement.SyncEventExtendedAction.executeAfterActionsSync(SyncEventExtendedAction.java:91)     at com.mendix.basis.actionmanagement.SyncEventExtendedAction.executeAction(SyncEventExtendedAction.java:45)     at com.mendix.basis.actionmanagement.EventExtendedAction.execute(EventExtendedAction.java:102)     at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:71)     at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:49)     at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:54)     at com.mendix.basis.actionmanagement.ActionManagerBase$1.execute(ActionManagerBase.java:149)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.basis.actionmanagement.ActionManagerBase.executeSync(ActionManagerBase.java:151)     at com.mendix.basis.action.user.DeleteAction.$anonfun$processDeleteBehaviour$2(DeleteAction.scala:64)     at com.mendix.basis.action.user.DeleteAction.$anonfun$processDeleteBehaviour$2$adapted(DeleteAction.scala:64)     at scala.collection.immutable.List.foreach(List.scala:392)     at com.mendix.basis.action.user.DeleteAction.$anonfun$processDeleteBehaviour$1(DeleteAction.scala:64)     at com.mendix.basis.action.user.DeleteAction.$anonfun$processDeleteBehaviour$1$adapted(DeleteAction.scala:61)     at scala.collection.Iterator.foreach(Iterator.scala:941)     at scala.collection.Iterator.foreach$(Iterator.scala:941)     at scala.collection.AbstractIterator.foreach(Iterator.scala:1429)     at scala.collection.IterableLike.foreach(IterableLike.scala:74)     at scala.collection.IterableLike.foreach$(IterableLike.scala:73)     at scala.collection.AbstractIterable.foreach(Iterable.scala:56)     at com.mendix.basis.action.user.DeleteAction.processDeleteBehaviour(DeleteAction.scala:61)     at com.mendix.basis.action.user.DeleteAction.$anonfun$executeAction$1(DeleteAction.scala:45)     at com.mendix.basis.action.user.DeleteAction.$anonfun$executeAction$1$adapted(DeleteAction.scala:45)     at scala.collection.immutable.List.foreach(List.scala:392)     at com.mendix.basis.action.user.DeleteAction.executeAction(DeleteAction.scala:45)     at com.mendix.basis.action.user.DeleteAction.executeAction(DeleteAction.scala:23)     at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:46)     at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:71)     at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:49)     at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:54)     at com.mendix.basis.actionmanagement.ActionManagerBase$1.execute(ActionManagerBase.java:146)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.basis.actionmanagement.ActionManagerBase.executeSync(ActionManagerBase.java:151)     at com.mendix.basis.actionmanagement.ActionManagerBase.executeInTransactionSync(ActionManagerBase.java:115)     at com.mendix.basis.component.InternalCoreBase.delete(InternalCoreBase.java:284)     at com.mendix.basis.component.InternalCoreBase.delete(InternalCoreBase.java:263)     at com.mendix.basis.component.InternalCoreBase.delete(InternalCoreBase.java:295)     at com.mendix.webui.actions.client.RegularClientActions$.delete(RegularClientActions.scala:55)     at com.mendix.webui.requesthandling.ClientRequestHandler.$anonfun$clientActions2$4(ClientRequestHandler.scala:53)     at com.mendix.webui.actions.client.RegularClientAction$.$anonfun$alwaysSuccess$1(RegularClientAction.scala:14)     at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$4(RegularClientAction.scala:45)     at com.mendix.webui.requesthandling.helpers.StateHandling.withState(StateHandling.scala:32)     at com.mendix.webui.requesthandling.helpers.StateHandling.withState$(StateHandling.scala:20)     at com.mendix.webui.actions.client.RegularClientAction.withState(RegularClientAction.scala:20)     at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$3(RegularClientAction.scala:43)     at scala.util.Try$.apply(Try.scala:213)     at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$2(RegularClientAction.scala:43)     at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$2$adapted(RegularClientAction.scala:41)     at com.mendix.webui.requesthandling.helpers.ContextHandling.$anonfun$inContext$3(ContextHandling.scala:41)     at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)     at com.mendix.basis.actionmanagement.IMonitoredAction$$anon$1.execute(IMonitoredAction.scala:47)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.basis.actionmanagement.IMonitoredAction.monitor(IMonitoredAction.scala:49)     at com.mendix.basis.actionmanagement.IMonitoredAction.monitor$(IMonitoredAction.scala:25)     at com.mendix.webui.requesthandling.helpers.ContextHandling$ClientMonitoredAction.monitor(ContextHandling.scala:49)     at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext(ContextHandling.scala:41)     at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext$(ContextHandling.scala:27)     at com.mendix.webui.actions.client.RegularClientAction.inContext(RegularClientAction.scala:20)     at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext(ContextHandling.scala:24)     at com.mendix.webui.requesthandling.helpers.ContextHandling.inContext$(ContextHandling.scala:19)     at com.mendix.webui.actions.client.RegularClientAction.inContext(RegularClientAction.scala:20)     at com.mendix.webui.actions.client.RegularClientAction.$anonfun$execute$1(RegularClientAction.scala:41)     at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)     at com.mendix.webui.requesthandling.helpers.ProfileHandling.profileRequest(ProfileHandling.scala:14)     at com.mendix.webui.requesthandling.helpers.ProfileHandling.profileRequest$(ProfileHandling.scala:10)     at com.mendix.webui.actions.client.RegularClientAction.profileRequest(RegularClientAction.scala:20)     at com.mendix.webui.actions.client.RegularClientAction.execute(RegularClientAction.scala:38)     at com.mendix.webui.requesthandling.ClientRequestHandler.handleAction(ClientRequestHandler.scala:124)     at com.mendix.webui.requesthandling.ClientRequestHandler.processRequest(ClientRequestHandler.scala:101)     at com.mendix.externalinterface.connector.RequestHandler.doProcessRequest(RequestHandler.java:40)     at com.mendix.external.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:74)     at com.mendix.external.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:71)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.external.connector.MxRuntimeConnector.processRequest(MxRuntimeConnector.java:77)     at com.mendix.basis.impl.MxRuntimeImpl.processRequest(MxRuntimeImpl.java:950)     at com.mendix.m2ee.appcontainer.server.handler.RuntimeHandler.service(RuntimeHandler.java:42)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)     at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:867)     at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542)     at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)     at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1588)     at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)     at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)     at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)     at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)     at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1557)     at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)     at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)     at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)     at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)     at org.eclipse.jetty.server.Server.handle(Server.java:502)     at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)     at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)     at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)     at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)     at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)     at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)     at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)     at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)     at java.base/java.lang.Thread.run(Thread.java:834)  
asked
5 answers
1

The after delete event on the registration Entity is triggered. Caused by the cascading delete of registrations.

My guess is that you retrieve the training event from database in your first activity of the after delete event Microflow.

This should be a by association retrieve. Otherwise the event won't be accessed and thus fail in the fourth activity.

answered
1

I encountered the same issue and reached out to a dev on the Mendix team. He suggested a cause of the problem and it was definitely the issue. Here is what it was:

  1. Module 8.5.1 – Makes us add a delete button to TrainingEvents
    1. If you test this button right away, you delete a trainingevent
    2. We have not yet implemented the “Prevent Delete” logic, so this will delete an event and any Registrations to this event now has an EMPTY TraingingEvent.
  2. Module 8.6.1 – Implements the delete cascade logic
    1. Testing this Deletes Trainee → Deletes Registrations → Triggers ACO_ADE_Registration_SetTotalNumberOfRegistrations
    2. If any of these Registrations were one of the Registrations to a TrainingEvents that was deleted, that is what causes this issue!

TLDR; If you delete a TraingingEvent before adding the Prevent Delete logic, you can orphan Registrations. When you trigger a Cascade Delete, this will attempt to delete the orphan Registrations and that is where you get an Empty TrainingEvent.

 

Solution:

My solution:

  1.  Short circuit ACO_ADE_Registration_SetTotalNumberOfRegistrations. If TrainingEvent was empty, I short circuit the microflow to an end point.
  2. Delete all your users to cascade delete all their registrations. (This will mess up your registration counts for some TrainingEvents temporarily)
  3. This will have deleted all the orphan Registrations, now revert ACO_ADE_Registration_SetTotalNumberOfRegistrations back to the original implementations.
  4. Your DB is now in a consistent state
answered
0

So the error you’re getting is “Change object 'NewTrainingEvent' should not be null”. Do you delete the entity with a microflow? If so is it perhaps possible that you try to change the NewTrainingsEvent while it does not exist? 

If you do not use a microflow then this error seems very weird: a participant seems like something quite different from a ‘NewTrainingsEvent’.

answered
0

I am not so fluent in Mendix programming yet. I just follow the lessons and I edited the behavior of newly created “Delete” button.

and the domain model.

I have not created my own microflow for this action.

What I also found is that I get this error message and I cannot delete participants that were created, before I did the changes within this paragraph.

If now I create a new participant and assign it to the trainings, I can delete such a new participant without any problem.

answered
0

Hello, 

I get exactly the same error, although the code looks like the one in the instructions. (checked multiple times) I am not sure what is going wrong,. 

Can anybody lend a hand here? 

Thanks.

answered