Fix for potential NPE on wildfly. Added tests but could not reproduce.