When using a custom public service with an Auditable annotation in one of its methods and calling this public method from a custom class method (onShutdown) that extends from AbstractLifecycleBean the AuditMethodInterceptor throws an exception on shutdown instead of logging to the database or adding an entry in the logs (log4j.logger.org.alfresco.support=DEBUG)
Steps to Reproduce:
- Create a public service class (see attached project for files MyCustomService.java and MyCustomServiceImpl.java) and implement a method which uses the Auditable annotation.
- Create a custom bootstrap class (as defined in the file bootstrap-context.xml) that extends the class class AbstractLifecycleBean and calls the previously defined public service's annotated method (see file MyBootstrapImpl.java on methods onBootstrap & onShutdown)
- Deploy these files in an alfresco.war (can create an amp with the included maven project)
- Turn on the logger
- Start a connection to the alfresco database and take note to the table "alf_audit_entry" before tomcat starts with the customizations
- Start tomcat and the onBootstrap method is called and the method doSomeWork is also called, when the method is called an entry is created in the database in the table "alf_audit_entry"
- Shut down tomcat
On shutdown an audit entry is created
In the alfresco logs an error is thrown
ERROR [audit.model.AuditModelRegistryImpl] [main] Failed to load audit model: file:/Users/joseportillo/Documents/alfresco/installs/414/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/audit/customservice-audit.xml
org.alfresco.error.AlfrescoRuntimeException: 08180020 Failed to get from EhCache as state invalid:
Analysis to Date:
The same error is reproduced when using a custom class which implements from SmartLifecycle and also when using a custom subsystem (see attached file MyChildApplicationContextFactory.java on the destroy methods) in all cases the same error is thrown on shutdown.