I wanted to split the ProcessEngine data source and my application datasource (which uses JPA / Hibernate). Therefor I made two entries in the persistence.xml.
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="MyCustom_PU" transaction-type="JTA">
<!-- If you are running in a production environment, add a managed data
source, this example data source is just for development and testing! -->
<!-- The datasource is deployed as WEB-INF/PCMS-ds.xml, you can find it
in the source at src/main/webapp/WEB-INF/PCMS-ds.xml -->
<jta-data-source>java:/myCustomDb</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/ProcessEngine</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
But I get this error: “Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment deployment”
As Camunda does not use JPA (Hibernate) for persistence, this is not the right place.
You have to do this in your JBoss configuration (standalone.xml).
In the camunda subsystem use <datasource>java:jboss/datasources/ProcessEngine</datasource>.
I guess that you mean that I should change the Database Server Type from H2 to preferred one. I just did that and changed to MySQL. My question was how to split the process engine database and the application database? I just entered two persistence units in persistence.xml but it didn’t work.
As langfr said, you need to create a second datasource in settings.xml of jboss. (No matter which database type you use …).
There should be already the definition for “java:jboss/datasources/ProcessEngine”. You have to add a second database definition for you own application (e.g. “java:/myCustomDb”).
For both datasources you should change the parameters to use another database type for production use, e.g. MySql.
As ExampleDS is a weird name (as it says it’s just an example) you might add a third datasource for your custom DB (java:/myCustomDb). In case you’re thinking about removing ExampleDS or changing the jndi-name of ExampleDS be aware that this is referenced later in standalone.xml. You’ll have to change this reference too.
As Patrick said, you should definitely think about changing those datasources to xa-datasources to be able to have transactions spanning both databases.
And as I already said, there is absolutely no need to change the persistence.xml of your deployment unit.
Camunda does not use JPA entities / Hibernate for persistence.
As you saw, this breaks your application, because the injected EntityManager does not know which persistence-unit to choose.
As Bayqush I want to use a other datasourse for storage persistent data for my application.
If in persistence.xml specify two < persistence-unit > I have error "Persistence unitName was not specified and there are 2 persistence unit definitions in application deployment deployment"
Now i specify one < persistence-unit > and my persistence.xml looks this:
Yes, now is one database, but various schemes
Then, perhaps, there will be different databases.
I do not want to the application tables were in the scheme camunda