JBoss Community

Re: Service task exception with non-JTA transaction manager persistence and Tomcat

created by navisdrools in jBPM - View the full discussion

I resolved my problem by using all Spring beans.

 

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

        <property name="persistenceUnitName" value="com.navis.control.persistence.jpa" />

    </bean>

 

 

    <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">

        <property name="entityManagerFactory" ref="entityManagerFactory" />

    </bean>

 

ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("ApplicationContext.xml");

        Environmentenv = KnowledgeBaseFactory.newEnvironment();

        env.set(EnvironmentName.ENTITY_MANAGER_FACTORY,applicationContext.getBean("entityManagerFactory"));

        env.set(EnvironmentName.TRANSACTION_MANAGER, applicationContext.getBean("txManager"));

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

kbuilder.add(ResourceFactory.newClassPathResource("aFile"), ResourceType.BPMN2);

kbuilder.add(ResourceFactory.newClassPathResource("aRule"), ResourceType.DRL);

KnowledgeBase kbase = kbuilder.newKnowledgeBase();


StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);

Reply to this message by going to Community

Start a new discussion in jBPM at Community