you need to create persistence session via JPAKnowledgeSession class instead of getting one directly from kbase. That is probably the case as there is no environment with entity manager factory in it. Environment is taken from ksession inside JPAWorkingMemoryDBLogger. Take a look at documentation for details hot to crate persistent session.
HTH