Michał Warecki [
http://community.jboss.org/people/michal.warecki] created the discussion
"jboss as 5 jbpm 5.1 persistence"
To view the discussion, visit:
http://community.jboss.org/message/594238#594238
--------------------------------------------------------------
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>
<!--
<non-jta-data-source>${pu.jta.data.source}Unmanaged</non-jta-data-source>
-->
<properties>
<property name="hibernate.dialect"
value="${pu.hibernate.dialect}" />
<property name="hibernate.hbm2ddl.auto"
value="${pu.hibernate.hbm2ddl.auto}" />
<property name="hibernate.default_batch_fetch_size"
value="${pu.hibernate.default_batch_fetch_size}" />
<property name="hibernate.show_sql"
value="${pu.hibernate.show_sql}" />
<property name="hibernate.format_sql" value="true"
/>
<!-- Encoding -->
<property name="hibernate.connection.useUnicode"
value="true" />
<property name="hibernate.connection.characterEncoding"
value="UTF-8" />
<!-- These are the default for JBoss EJB3, but not for HEM: -->
<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}" />
<!-- Binds the EntityManagerFactory to JNDI where Seam can look it up.
This is only relevant when the container automatically loads the
persistence
unit, as is the case in JBoss AS 5. -->
<property name="jboss.entity.manager.factory.jndi.name"
value="${pu.jboss.entity.manager.factory.jndi.name}" />
</properties>
<!-- If the persistence.xml file is not under the same root directory or
jar than your domain model then use the <jar-file> element to point to
the
jar containing your domain model.
<jar-file>../../vehicles.jar</jar-file> -->
</persistence-unit>
<persistence-unit name="org.jbpm.persistence.jpa"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jdbc/processInstanceDS</jta-data-source>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<properties>
<property name="hibernate.dialect"
value="${pu.hibernate.dialect}" />
<property name="hibernate.hbm2ddl.auto"
value="${pu.hibernate.hbm2ddl.auto}" />
<property name="hibernate.default_batch_fetch_size"
value="${pu.hibernate.default_batch_fetch_size}" />
<property name="hibernate.show_sql"
value="${pu.hibernate.show_sql}" />
<property name="hibernate.format_sql" value="true"
/>
<!-- Encoding -->
<property name="hibernate.connection.useUnicode"
value="true" />
<property name="hibernate.connection.characterEncoding"
value="UTF-8" />
<!-- These are the default for JBoss EJB3, but not for HEM: -->
<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>
<persistence-unit name="org.drools.task"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jdbc/taskDS</jta-data-source>
<mapping-file>META-INF/taskOrm.xml</mapping-file>
<class>org.jbpm.task.Attachment</class>
<class>org.jbpm.task.Content</class>
<class>org.jbpm.task.BooleanExpression</class>
<class>org.jbpm.task.Comment</class>
<class>org.jbpm.task.Deadline</class>
<class>org.jbpm.task.Comment</class>
<class>org.jbpm.task.Deadline</class>
<class>org.jbpm.task.Delegation</class>
<class>org.jbpm.task.Escalation</class>
<class>org.jbpm.task.Group</class>
<class>org.jbpm.task.I18NText</class>
<class>org.jbpm.task.Notification</class>
<class>org.jbpm.task.EmailNotification</class>
<class>org.jbpm.task.EmailNotificationHeader</class>
<class>org.jbpm.task.PeopleAssignments</class>
<class>org.jbpm.task.Reassignment</class>
<class>org.jbpm.task.Status</class>
<class>org.jbpm.task.Task</class>
<class>org.jbpm.task.TaskData</class>
<class>org.jbpm.task.SubTasksStrategy</class>
<class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
<class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>
<class>org.jbpm.task.User</class>
<properties>
<property name="hibernate.dialect"
value="${pu.hibernate.dialect}" />
<property name="hibernate.hbm2ddl.auto"
value="${pu.hibernate.hbm2ddl.auto}" />
<property name="hibernate.default_batch_fetch_size"
value="${pu.hibernate.default_batch_fetch_size}" />
<property name="hibernate.show_sql"
value="${pu.hibernate.show_sql}" />
<property name="hibernate.format_sql" value="true"
/>
<!-- Encoding -->
<property name="hibernate.connection.useUnicode"
value="true" />
<property name="hibernate.connection.characterEncoding"
value="UTF-8" />
<!-- These are the default for JBoss EJB3, but not for HEM: -->
<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 ?
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/594238#594238]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]