At first I thought that it would work with Payara. The method needs only an EntityManager after all.
The method AuditReaderFactory.get(EntityManager entityManager)
should throw AuditException, not StackOverflowError. I surrounded the method with a try-catch AuditException but this obviously doesn’t work.
Well, it does so for convenience because the Hibernate contracts implement the EntityManager interface and we don’t want to force you having to call entityManager.unwrap(Session.class) for retriving the Hibernate related subtype. Either way, it just won’t work with EclipseLink, so why do you care about the exact exception?
I once switched to Payara for testing purposes. It helps to check if everything works. So I would like to desactive properly AuditReaderFactory.get(EntityManager) by catching the AuditException.
So catch the StackOverflowError or check yourself if this is Hibernate that is running by checking if a well known class like e.g. org.hibernate.Hibernate can be loaded.