Hi,
I have problem creating stateful knowledge session using jpa, jboss as 5.1 and jbpm 5.1. I'm trying to create session in statefull EJB.
While creating session thread just suspends and after 3-4 minutes in console I've got xa transaction timeout's.
Am I missing something while creating Environment ? Should I set conteiner transaction manager into Environment ?
Maybe jbpm 5.1 doesn't work with XA datasources ? Help me please. There is a code :
datasources:
<datasources>
<xa-datasource>
<jndi-name>jdbc/dbDS</jndi-name>
<use-java-context>true</use-java-context>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">${ds.connection.url}</xa-datasource-property>
<xa-datasource-property name="User">${ds.user.name}</xa-datasource-property>
<xa-datasource-property name="Password">${ds.password}</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<no-tx-separate-pools/>
</xa-datasource>
<xa-datasource>
<jndi-name>jdbc/processInstanceDS</jndi-name>
<use-java-context>true</use-java-context>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">${ds.connection.url}</xa-datasource-property>
<xa-datasource-property name="User">${ds.user.name}</xa-datasource-property>
<xa-datasource-property name="Password">${ds.password}</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<no-tx-separate-pools/>
</xa-datasource>
<xa-datasource>
<jndi-name>jdbc/taskDS</jndi-name>
<use-java-context>true</use-java-context>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">${ds.connection.url}</xa-datasource-property>
<xa-datasource-property name="User">${ds.user.name}</xa-datasource-property>
<xa-datasource-property name="Password">${ds.password}</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<no-tx-separate-pools/>
</xa-datasource>
</datasources>
persistence.xml:
<persistence-unit name="${pu.name}" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>${pu.jta.data.source}</jta-data-source>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
<property name="hibernate.transaction.manager_lookup_class"
value="${pu.hibernate.transaction.manager_lookup_class}" />
</properties>
</persistence-unit>
Bean:
@Stateful
@Name("register")
public class RegistationBean implements Registration {
@Out(scope = ScopeType.CONVERSATION)
private User registerUser;
@In(value="userRepository", create=true)
private UserRepository userRepository;
@Logger
private Log log;
private KnowledgeBase knowledgeBase;
private Environment environment;
@PersistenceUnit(unitName = "org.jbpm.persistence.jpa")
private EntityManagerFactory emf;
@Factory(value = "registerUser")
public void createRegisterUser() {
registerUser = new User();
}
public String register() {
sendRegistrationEmail();
userRepository.persist(registerUser);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("process/registration.bpmn"), ResourceType.BPMN2);
knowledgeBase = kbuilder.newKnowledgeBase();
environment = KnowledgeBaseFactory.newEnvironment();
environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
//AT THIS LINE THREAD HANGS AND SUSPENDS.
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(knowledgeBase, null, environment );
log.info("#{registerUser.username} has been registered.");
return "registred";
}
}
I'm trying to run this very simple code for over one week and I'm frystated at this moment :-)
Anyone know how to solve my problem ?
Maybe someone has some example how to configure jbpm 5.1 persistence using CMT ?