Issues with auditing while using Spring Data Neo4j


(Jadengis) #1

Has anyone had success using the @EnableNeo4jAuditing annotation in SDN? I setup the auditing as outlined in the reference documentation here, but the auditing information was not being updated on save.

I did some investigating with the debugger, and it seems like I'm running into some weird issue where even though the Neo4jAuditingRegistrar runs early in the boot procedure, and registers the Neo4jAuditingBeanPostProcessor bean definition before the SessionFactory is created in Neo4jDataAutoConfiguration, the bean post processor doesnt get instantiated from the definition until after the session factory is instantiated and so the session factory does not get post processed.

I really don't know why this is the case, but it has the effect that the SessionFactory never has the auditing event listener attached to it and so the auditing events aren't being processed.

I wonder if it is some kind of configuration race condition.


(Jadengis) #2

Actually I did some more digging and I found out that this issue I'm experiencing was because one of the default configured BeanPostProcessors has a dependency on the methodSecurityConfiguration being, and because I was using my on custom PermissionEvaluator that depends on the underlying database, the session factory was being instantiated while the application is still creating all the BeanPostProcessors, and I guess as a matter of timing, the session factory just happens to miss the required neo4j post processor.

I'm trying to think of a work around at the moment.