AuditTrail is not creating Log objects

0
Our App used to use the AuditTrail module back when we were using mendix version 5.18 or 5.20. I can't remember exactly when but we deactivated the module for performance reasons. I think we did so by removing all related event handlers on the entities we were tracking. Now we're on version 6.3.1 and are ready to reactivate the module. I'm assuming we used the events and association method to implement the module before since the AuditTrail.Log entity already has the appropriate relationships to the entities we want to track. I followed the instructions in the readme and added a Before Commit and Before Delete event handler to the BillingSheet entity (the entity I want to track). I noticed the readme mentions an After Create event handler but the AuditTrailSuperClass entity doesn't have an event handler for that. Maybe that's the issue? When I try to change a BillingSheet object, I get the following error and stacktrace: An error has occurred while handling the request. [User 'adrewen' with session id 'f94b21bc-fe77-481e-a56d-939cf1d97eee' and roles 'PAAHAdministrator, PAAHUser'] -------- com.mendix.core.CoreRuntimeException: com.mendix.modules.microflowengine.MicroflowException: requirement failed: Change object 'LogObject' should not be null at AuditTrail.BCo_BillingSheet (Change : 'Change 'LogObject' (BillingSheet_Log)') at {"before":[{},{},{},{},{},{},{},{},{},{},{},{}],"action":{"type":"CommitAction"},"after":[],"type":"EventExtendedAction"} Advanced stacktrace: at com.mendix.core.actionmanagement.ActionManager.executeInTransactionSync(ActionManager.java:143) Caused by: com.mendix.modules.microflowengine.MicroflowException: requirement failed: Change object 'LogObject' should not be null at AuditTrail.BCo_BillingSheet (Change : 'Change 'LogObject' (BillingSheet_Log)') at {"before":[{},{},{},{},{},{},{},{},{},{},{},{}],"action":{"type":"CommitAction"},"after":[],"type":"EventExtendedAction"} Advanced stacktrace: at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:143) Caused by: java.lang.IllegalArgumentException: requirement failed: Change object 'LogObject' should not be null at scala.Predef$.require(Predef.scala:219) at com.mendix.modules.microflowengine.actions.mxobject.ChangeAction.execute(ChangeAction.scala:43) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:174) at com.mendix.core.component.InternalCore.executeSync(InternalCore.java:459) at com.mendix.core.actionmanagement.SyncEventExtendedAction.executeBeforeAction(SyncEventExtendedAction.java:78) at com.mendix.core.actionmanagement.SyncEventExtendedAction.executeBeforeActionsSync(SyncEventExtendedAction.java:57) at com.mendix.core.actionmanagement.SyncEventExtendedAction.executeAction(SyncEventExtendedAction.java:28) at com.mendix.core.actionmanagement.EventExtendedAction.execute(EventExtendedAction.java:92) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:171) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:174) at com.mendix.core.actionmanagement.ActionManager.executeInTransactionSync(ActionManager.java:136) at com.mendix.core.component.InternalCore.commit(InternalCore.java:171) at com.mendix.core.component.InternalCore.commit(InternalCore.java:146) at com.mendix.core.component.InternalCore.commit(InternalCore.java:132) at com.mendix.webui.actions.client.CommitAction.execute(CommitAction.scala:19) at com.mendix.webui.actions.client.CommitAction.execute(CommitAction.scala:11) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:324) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:317) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:317) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:144) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:146) at scala.util.Try$.apply(Try.scala:192) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:140) at akka.actor.Actor$class.aroundReceive(Actor.scala:465) at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:136) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) at akka.actor.ActorCell.invoke(ActorCell.scala:487) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) at akka.dispatch.Mailbox.run(Mailbox.scala:220) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) It looks like the error is caused by the change action which creates a relationship between the BillingSheet and the Log objects after the java action. It also looks like the Log object is not being created. We are using version 4.0 of the AuditTrail module. Please advise on how I can fix this.
asked
2 answers
2

The after create is obsolete as it will give the same result as doing a before commit. We'll remove this from the documentation.

Can you add a check in your microflow to see if there is actually a Log object returned by the java action?

answered
1

We did a lot of troubleshooting and finally figured out the problem.

The entity in question has quite a few Before Commit event handlers on it and we didn't consider looking through them until now. As it turns out, one of the other event handlers was committing the object without events. I'm assuming it was triggering before the AuditTrail event since the CreateLogRecordOfObject action wasn't detecting any changes made to the attributes. The offending event handler was added after we deactivated the AuditTrail module so it wouldn't have been an issue before recently.

Now that I've double checked the other event handlers, the AuditTrail module seems to be working!

answered