JBoss Community

How to new a StatefulKnowledgeSession instance

created by RuiHua Tang in jBPM - View the full discussion

I have used JBPM5 in Spring Web Application

 

First, I use the following method to create:

 

       StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();

 

But, I found that process data and session have not saved to the database

 

 

When I use the following methods:

         

EntityManagerFactory emf = (EntityManagerFactory) Constants.ctx

                                        .getBean("entityManagerFactory");

                    Environment env = KnowledgeBaseFactory.newEnvironment();

                    env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                    env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                    env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices

                                        .getTransactionManager());

                    // Properties properties = new Properties();

                    // properties

                    // .put("drools.processInstanceManagerFactory",

                    // "org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");

                    // properties.put("drools.processSignalManagerFactory",

                    // "org.jbpm.persistence.processinstance.JPASignalManagerFactory");

                    // KnowledgeSessionConfiguration config = KnowledgeBaseFactory

                    // .newKnowledgeSessionConfiguration(properties);

                    StatefulKnowledgeSession session = JPAKnowledgeService

                                        .newStatefulKnowledgeSession(kbase, null, env);

                    // StatefulKnowledgeSession session =

                    // kbase.newStatefulKnowledgeSession();

                    return session;

Reply to this message by going to Community

Start a new discussion in jBPM at Community