EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
emf );
env.set( EnvironmentName.GLOBALS, new MapGlobalResolver() );
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
ksession.getWorkItemManager().registerWorkItemHandler("MyWork", new SystemOutWorkItemHandler());
ProcessInstance processInstance = ksession.startProcess( "org.drools.test.TestProcess" );
ksession.insert( "TestString" );