Hi,

I'm trying to implemente a simple jBPM use case in JBoss AS, so using JEE.

First i made two ear for my tests:
- One with an EJB which just launch a jbpm process and use DB "JbpmDS", which 
is an XA datasource.
- A second with an EJB which update data (with entity beans - persistence.xml) 
using DB "JbpmDSClient", which is an XA datasource.
That worked fine separatly.
But, i wanted to make them work together in only one ear, to call an EJB-remote 
method which launches a simple process BUT with an update in database.

And i don't know why but:

1 - If i use the same db in persistence.xml that in jbpm config (=> "JbpmDS"), 
i have sometime an error when i try to only launch a process (without update in 
DB), (it's not always the same):

anonymous wrote :               ORA-00001: violation de contrainte unique 
(JBPM.SYS_C005943)
  |             ..
  |             or ORA-00001: violation de contrainte unique (JBPM.SYS_C005904) 
for example

        It's like there was a conflict between jbpm config and my 
persistence.xml config for my entity beans.
        
2 - If i try to use a different DB in persistence.xml, i have this error when i 
try to only launch a process (without update in DB):

anonymous wrote :       12:31:43,629 WARN  [JDBCExceptionReporter] SQL Error: 
2289, SQLState: 42000
  |     12:31:43,629 ERROR [JDBCExceptionReporter] ORA-02289: la 
s????????????????????????????????quence n'existe pas (the sequence doesn't 
exist)
        
So.... I would like to know if somebody got an idea? What is the best practice 
to work with jBPM and to update DB in the same time? What about transactions?
What about the context.close?
I found this paper: http://www.jboss.org/community/docs/DOC-11090 which 
explains how use CMT with jBPM....
I would like to know how to properly inject my hibernate session from 
persistence.xml in jBPM context... and what is really the good config?

In the wiki for example they said to have this conf:

        <jbpm-context>
  |             <service name="persistence" 
factory="org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory" />
  |     </jbpm-context>

But sometime i read to put (here for example 
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=111429&postdays=0&postorder=asc&start=10):

        <service name="persistence">
  |             <factory>
  |                     <bean name="persistence.factory"
  |                             
class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
  |                             <field name="isTransactionEnabled">
  |                                     <false />
  |                             </field>
  |                     </bean>
  |             </factory>
  |     </service>

And in the doc, chapter 7.4 
http://docs.jboss.com/jbpm/v3.2/userguide/html_single/ this is 2nd choice 
whereas in 9.2, this is the first.

That's why i'm a bit lost... I have read too much different things..... I just 
want to do this in the same ejb method:

1- launch a process.
2- update in db.
3- rollback the 2 actions if i have a problem.

Here is the code of my ejb "ManagementJBPM":

package **package** ;
  | 
  | import javax.ejb.EJB;
  | import javax.ejb.Stateless;
  | 
  | import org.jbpm.JbpmConfiguration;
  | import org.jbpm.JbpmContext;
  | import org.jbpm.db.GraphSession;
  | import org.jbpm.graph.exe.ExecutionContext;
  | import org.jbpm.graph.exe.ProcessInstance;
  | import org.jbpm.persistence.db.DbPersistenceService;
  | import org.jbpm.persistence.jta.JtaDbPersistenceService;
  | 
  | import **package**.ManagementClientLocal;
  | import **package**.CreationProcessException;
  | import **package**.LaunchProcessException;
  | import **package**.NoClientDefinedException;
  | 
  | @Stateless
  | public class ManagementJBPM implements ManagementJBPMRemote
  | {
  |     private static JbpmConfiguration jBPMConfiguration = null;
  |     
  |     
@EJB(mappedName="JBPMBusiness-ear/ManagementClient/local-**package**.ManagementClientLocal")
  |     private ManagementClientLocal managementClient;
  |     
  |     public void launchSimpleProcess(String processName, String clientId) 
throws LaunchProcessException
  |     {       
  |             long processId;
  |             
  |             try
  |             {
  |                     processId = createProcess(processName); // Creation of 
the process.
  |             }
  |             catch(CreationProcessException exc) { throw new 
LaunchProcessException(exc.getMessage()); }
  | 
  |             try
  |             {
  |                     managementClient.updateClient(clientId, processId); // 
Update of client infos.
  |             }
  |             catch(NoClientDefinedException exc) { throw new 
LaunchProcessException(exc.getMessage()); }
  |     }
  |     
  |     private long createProcess(String processName) throws 
CreationProcessException
  |     {
  |             JbpmContext jbpmContext = initJBPMContext(); // Creation of the 
context.
  | 
  |             Long processId = null;
  | 
  |             try
  |             {
  |                     ProcessInstance processInstance = 
jbpmContext.newProcessInstance(processName); // Process created.
  |                     processId = processInstance.getId();
  |             }
  |             catch(Exception exc)
  |             {
  |                     throw new CreationProcessException("Error during the 
creation of the process ");
  |             }
  |             finally 
  |             {
  |                     jbpmContext.close(); // It's necessary to close the 
context.
  |             }
  | 
  |             return processId;
  |     }
  |     
  |     private JbpmContext initJBPMContext()
  |     {
  |             if(jBPMConfiguration==null) // If jBPMConfiguration doesn't 
exist.
  |             {
  |                     jBPMConfiguration = JbpmConfiguration.getInstance(); // 
We get it.
  |             }
  |             JbpmContext jbpmContext = 
jBPMConfiguration.createJbpmContext(); // Creation of the context.
  | //        
jbpmContext.setSession(persServ.getSessionFactory().getCurrentSession());
  |             return jbpmContext;
  |     }
  | }
(All the exceptions have ApplicationException(rollback=true))

Here is my persistence.xml conf for my entity beans:

<?xml version="1.0" encoding="UTF-8"?>
  | <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  |   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd";>
  |   <persistence-unit name="clientdb" transaction-type="JTA">
  |     <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |     <jta-data-source>java:JbpmDS</jta-data-source>
  |     <properties>
  |       <!-- Dialect and schema check -->
  |       <property name="hibernate.dialect" 
value="org.hibernate.dialect.Oracle9Dialect" />
  |       <property name="hibernate.hbm2ddl.auto" value="create-drop" />
  |       
  |       <!-- logging properties --> 
  |       <property name="hibernate.show_sql" value="true" />
  |       <property name="hibernate.format_sql" value="true" />
  |       <property name="hibernate.use_sql_comments" value="true" />
  |       <property name="hibernate.generate_statistics" value="true" />        
  |     </properties>
  |   </persistence-unit>
  | </persistence>

Here is my jbpm.cfg.xml:

<jbpm-configuration>
  | 
  |   <jbpm-context>
  |     <service name="persistence" 
factory="org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory" />
  |     <service name="message" 
factory="org.jbpm.msg.jms.JmsMessageServiceFactory" />
  |     <service name="scheduler" 
factory="org.jbpm.scheduler.ejbtimer.EntitySchedulerServiceFactory" />
  |     <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
  |     <service name="authentication" 
factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" 
/>
  |   </jbpm-context>
  | 
  |   <string name="jbpm.classLoader" value="context" />
  | 
  |   <null name="jbpm.job.executor" />
  | 
  | </jbpm-configuration>

Here is my JbpmDS:

<?xml version="1.0" encoding="UTF-8"?>
  | 
  | <datasources>
  |   <xa-datasource>
  |   
  |     <jndi-name>JbpmDS</jndi-name>
  |     
  |     
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
  |     <xa-datasource-property 
name="URL">jdbc:oracle:thin:@localhost:1521</xa-datasource-property>
  |     <xa-datasource-property name="User">jBPM</xa-datasource-property>
  |     <xa-datasource-property 
name="Password">adminadmin</xa-datasource-property>
  | 
  |     <isSameRM-override-value>false</isSameRM-override-value>
  |     
  |     <!--
  |             <min-pool-size>10</min-pool-size>
  |             <max-pool-size>100</max-pool-size>
  |     -->
  |     
  |     <!--
  |             <background-validation>true</background-validation>
  |             
<background-validation-millis>60000</background-validation-millis>
  |     -->
  | 
  |     <!--
  |             <idle-timeout-minutes>15</idle-timeout-minutes>
  |      -->
  |     
  |     <no-tx-separate-pools/>
  |  
  |     
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
  |     
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
  |     
<stale-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleStaleConnectionChecker</stale-connection-checker-class-name>
  | 
  |     <!--     
  |             <use-fast-fail>true</use-fast-fail>
  |     -->
  |          
  |     <prepared-statement-cache-size>200</prepared-statement-cache-size>
  |     <share-prepared-statements/>
  | 
  |       <metadata>
  |          <type-mapping>Oracle9i</type-mapping>
  |       </metadata>
  |   </xa-datasource>
  | 
  |   <mbean 
code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter" 
  |          name="jboss.jca:service=OracleXAExceptionFormatter">
  |     <depends 
optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
  |   </mbean>
  | 
  | </datasources>

My 2nd DS is the same with an other name.

And here is my hibernate.cfg.xml:

<hibernate-configuration>
  |   <session-factory>
  | 
  |     <!-- hibernate dialect -->
  |     <property 
name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
  | 
  |     <!-- DataSource properties -->
  |     <property name="hibernate.connection.datasource">java:JbpmDS</property>
  | 
  |     <!-- JTA transaction properties -->
  |     <property 
name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
  |     <property 
name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
  | 
  |     <!-- Simple memory-only cache -->
  |     <property 
name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
  |     
If somebody have an answer, i take it :p
Thx.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4224629#4224629

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4224629
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to