-
1. Re: persistence for BPM component
dward Jun 8, 2012 10:16 AM (in response to jbride)Hi Jeff,
Welcome to the hell I dealt with WRT jbpm persistence in as7. But don't fret! You're close...
I was able to test the helpdesk-webapp demo in as7 with persistence (against mysql - change for postgresql). There are a few things to note:
The persistence.xml deployed with the app (in WEB-INF/classes/META-INF/) is like so (no, I didn't try with the jtaplatform, I used the old tx lookup class):
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" 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_2_0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"> <persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:jboss/datasources/jbpmDS</jta-data-source> <mapping-file>JBPMorm-JPA2.xml</mapping-file> <class>org.drools.persistence.info.SessionInfo</class> <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class> <class>org.drools.persistence.info.WorkItemInfo</class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/> <property name="hibernate.hbm2ddl.auto" value="create"/> <property name="hibernate.listeners.envers.autoRegister" value="false"/> <property name="hibernate.max_fetch_depth" value="3"/> <property name="hibernate.show_sql" value="false"/> <property name="hibernate.transaction.manager_lookup_class" value="org.switchyard.component.bpm.jta.hibernate.AS7TransactionManagerLookup"/> <!-- <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform"/> --> </properties> </persistence-unit> </persistence>
NOTICE THAT THE mapping-file IS NOT IN META-INF. If you put it in META-INF, it won't be found. Trust me. I wrestled forever with module.xml syntax for imports, exports, services, etc. - all no dice. This is the ONLY way it will be "seen" by the as7 classloader. I guarantee you this is the biggest thing stopping you.
The mapping-file already comes packaged in switchyard (and has a tweaked query thanks to the help of salaboy) so you don't need it in your application (as you do with persistence.xml).
Note: The persistence.xml for the taskserver is in the src/test/resources of that quickstart demo. See the Readme.md for how that gets run. It also has a tweaked Taskorm-JPA2.xml file, but it can be in META-INF, since it doesn't get deployed to the appserver.
Next, you'll need a module.xml for mysql:
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.1" name="com.mysql.jdbc"> <resources> <resource-root path="mysql-connector-java-${version.mysql-connector-java}.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
You then have to add the mysql jdbc driver itself, and change the jbpmDS to use it, in as7/standalone/configuration/configuration.xml:
<subsystem xmlns="urn:jboss:domain:datasources:1.0"> <datasources> <datasource jndi-name="java:jboss/datasources/jbpmDS" pool-name="jbpmDS" enabled="true" use-java-context="true"> <connection-url>jdbc:mysql://localhost:3306/jbpm</connection-url> <driver>mysql</driver> <security> <user-name>jbpm</user-name> <password>jbpm</password> </security> </datasource> <drivers> <driver name="mysql" module="com.mysql.jdbc"> <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class> </driver> </drivers> </datasources> </subsystem>
Finally, persistent="true" needs to be abled in the switchyard.xml file for the application:
<?xml version="1.0" encoding="UTF-8"?> <switchyard xmlns="urn:switchyard-config:switchyard:1.0" name="helpdesk"> ... <implementation.bpm xmlns="urn:switchyard-component-bpm:config:1.0" agent="false" messageContentInName="ticket" messageContentOutName="ticketAck" persistent="true" processDefinition="META-INF/HelpDeskService.bpmn" processDefinitionType="BPMN" processId="HelpDeskService"> <taskHandler class="org.switchyard.component.bpm.task.work.SwitchYardServiceTaskHandler" name="SwitchYard Service"/> <taskHandler class="org.switchyard.component.bpm.task.work.jbpm.JBPMHumanTaskHandler" name="Human Task"/> </implementation.bpm> ... </switchyard>
Hope this helps. I sure wish someone could have given me all this a while back...
David
-
2. Re: persistence for BPM component
dward Jun 8, 2012 10:27 AM (in response to jbride)Forgot to directly answer your questions...
an exception is thrown indicating that META-INF/JBPMorm-JPA2.xml can't be located (which does exist in ${AS7}/modules/org/jbpm/main/jbpm-persistence-jpa-5.3.0.Final.jar )
You can't use $as7/modules/org/jbpm/main/jbpm-persistence-jpa-5.3.0.Final.jar!/META-INF/JBPMorm-JPA2.xml. You will instead be using $as7/modules/org/jbpm/main/jbpm-switchyard-5.3.0.Final.jar!/JBPMorm-JPA2.xml. (There is also a $as7/modules/org/jbpm/main/jbpm-switchyard-5.3.0.Final.jar!/Taskorm-JPA2.xml).
should the org.jbpm.persistence.jpa persistence-unit be defined and included in my application jar archive containing all of my switchyard services and configs ?
Yes, in META-INF/persistence.xml.
any examples of deploying with bpm "persistence=true" in switchyard.xml ?
Yup, the helpdesk-webapp demo as I expounded upon above.
-
3. Re: persistence for BPM component
jbride Jun 8, 2012 10:45 AM (in response to dward)excellent .... thanks for the hints David!
just modified my own persistence.xml by removing the "META-INF" path prior to JBPMorm-JPA2.xml .... and that worked ! ..... interesting
thanks again David,
jeff
-
4. Re: persistence for BPM component
dward Jun 8, 2012 10:47 AM (in response to jbride)Glad to have saved you the pain I went through.