Empty MetaModel when using EclipseLink 2.7.4 - eclipselink

My application has a composite persistence unit mainPU which contains 2 members (queryPU and entityPU). When using Criteria API in EclipseLink 2.5, it did not have any problem. However, when upgrading to EclipseLink 2.7, it got error "No [EntityType] was found for the key class [XXX] in the Metamodel" where XXX is the class defined in entityPU
I have some observation regarding the issue:
This problem only occurred when using Criteria API, and there is no
problem when using JPQL.
By default, my application load the mainPU. If I try to get the meta model, it always return empty list. If I explicitly load the
EntityManagerFactory with entityPU in a DAO, then it can load the full list of EntityType, and the problem gone!
EntityManagerFactory factory = Persistence.createEntityManagerFactory("entityPU");
Metamodel m2 = factory.getMetamodel(); //m2 return a list of EntityType!
Is there any wrong configuration in my application for the EclipseLink 2.7?
Below show the persistence.xml
mainPU
<?xml version="1.0" encoding="UTF-8"?>
<persistence
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_2_0.xsd"
version="2.0">
<persistence-unit name="mainPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/appds</jta-data-source>
<jar-file>icms-entity-lib-0.2.9.544.jar</jar-file>
<jar-file>../icmshrnmc-ejb.jar</jar-file>
<properties>
<property name="jboss.entity.manager.jndi.name" value="java:jboss/persistence/mainPU" />
<property name="eclipselink.target-database"
value="org.eclipse.persistence.platform.database.oracle.Oracle11Platform" />
<property name="eclipselink.target-server" value="JBoss" />
<property name="eclipselink.composite-unit" value="true" />
<property name="eclipselink.session.customizer"
value="x.y.ejb.dao.entity.DefaultEntityInterceptor" />
<property name="eclipselink.logging.level" value="ALL" />
<property name="eclipselink.deploy-on-startup" value="true"/>
</properties>
</persistence-unit>
queryPU
<?xml version="1.0" encoding="UTF-8"?>
<persistence
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_2_0.xsd"
version="2.0">
<persistence-unit name="queryPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/appds</jta-data-source>
<mapping-file>x/y/icmshrnmc/model/common/dao/namedquery/HrnNat.orm.xml</mapping-file>
...
...
...
<properties>
<property name="eclipselink.composite-unit-member" value="true" />
</properties>
</persistence-unit>
entityPU
<?xml version="1.0" encoding="UTF-8"?>
<persistence
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_2_0.xsd"
version="2.0">
<persistence-unit name="entityPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/appds</jta-data-source>
<non-jta-data-source>java:jboss/datasources/appds</non-jta-data-source>
<mapping-file>x/y/fmk/model/application/dao/entity/AuditEntity.orm.xml</mapping-file>
...
...
...
<shared-cache-mode>NONE</shared-cache-mode>
<properties>
<property name="eclipselink.jdbc.sequence-connection-pool" value="true" />
<property name="eclipselink.jdbc.sequence-connection-pool.non-jta-data-source" value="java:jboss/datasources/fmkseqds" />
</properties>

Related

Exception:Error loading metadata for index file: segments_2j|M|field... while running infinispan in 2 machines

I tried running infinispan in two machines and persisted the index data in one machine. When i try to run simultaneously in 2 machines with indexing and persisting(cache-store) into the database, i am getting the following exception,
Caused by: java.io.FileNotFoundException: Error loading metadata for index file: segments_2j|M|Course
at org.infinispan.lucene.impl.DirectoryImplementor.openInput(DirectoryImplementor.java:134)
at org.infinispan.lucene.impl.DirectoryLuceneV4.openInput(DirectoryLuceneV4.java:101)
at org.apache.lucene.store.Directory.openChecksumInput(Directory.java:113)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:341)
at org.apache.lucene.index.StandardDirectoryReader$1.doBody(StandardDirectoryReader.java:57)
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:923)
at org.apache.lucene.index.StandardDirectoryReader.open(StandardDirectoryReader.java:53)
at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:67)
at org.hibernate.search.indexes.impl.SharingBufferReaderProvider.readerFactory(SharingBufferReaderProvider.java:131)
at org.hibernate.search.indexes.impl.SharingBufferReaderProvider$PerDirectoryLatestReader.<init>(SharingBufferReaderProvider.java:206)
at org.hibernate.search.indexes.impl.SharingBufferReaderProvider.createReader(SharingBufferReaderProvider.java:108)
... 24 more
My infinispan config file is:
infinispan-config.xml
<?xml version="1.0" encoding="UTF-8"?> <infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:7.2 http://www.infinispan.org/schemas/infinispan-config-7.2.xsd
urn:infinispan:config:store:jdbc:7.2 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-7.2.xsd"
xmlns="urn:infinispan:config:7.2"
xmlns:jdbc="urn:infinispan:config:store:jdbc:7.2">
<!-- *************************** -->
<!-- System-wide global settings -->
<!-- *************************** -->
<jgroups>
<!-- Note that the JGroups transport uses sensible defaults if no configuration
property is defined. See the JGroupsTransport javadocs for more flags.
jgroups-udp.xml is the default stack bundled in the Infinispan core jar: integration
and tuning are tested by Infinispan. -->
<stack-file name="default-jgroups-tcp" path="my-jgroupstcp.xml"/>
</jgroups>
<cache-container name="HibernateSearch" default-cache="default" statistics="false" shutdown-hook="DONT_REGISTER">
<transport stack="default-jgroups-tcp"/>
<!-- Duplicate domains are allowed so that multiple deployments with default configuration
of Hibernate Search applications work - if possible it would be better to use JNDI to share
the CacheManager across applications -->
<jmx duplicate-domains="true"/>
<!-- *************************************** -->
<!-- Cache to store Lucene's file metadata -->
<!-- *************************************** -->
<replicated-cache name="LuceneIndexesMetadata" mode="ASYNC" async-marshalling="true">
<locking striping="false" acquire-timeout="10000" concurrency-level="500" write-skew="false"/>
<transaction mode="NONE" />
<eviction max-entries="-1" strategy="NONE"/>
<expiration max-idle="-1"/>
<persistence passivation="false">
<jdbc:string-keyed-jdbc-store preload="true" fetch-state="true" read-only="false" purge="false">
<write-behind />
<property name="key2StringMapper">org.infinispan.lucene.LuceneKey2StringMapper</property>
<jdbc:connection-pool connection-url="jdbc:mysql://localhost:3306/hsearch"
driver="com.mysql.jdbc.Driver" username="my-username"
password="my-password"></jdbc:connection-pool>
<jdbc:string-keyed-table drop-on-exit="false" create-on-start="true" prefix="ISPN_STRING_TABLE">
<jdbc:id-column name="ID" type="VARCHAR(255)"/>
<jdbc:data-column name="DATA" type="MEDIUMBLOB"/>
<jdbc:timestamp-column name="TIMESTAMP" type="BIGINT"/>
</jdbc:string-keyed-table>
</jdbc:string-keyed-jdbc-store>
</persistence>
<indexing index="ALL"/>
<state-transfer enabled="true" timeout="480000" await-initial-transfer="true"/>
</replicated-cache>
<!-- **************************** -->
<!-- Cache to store Lucene data -->
<!-- **************************** -->
<distributed-cache name="LuceneIndexesData" mode="ASYNC" async-marshalling="true">
<locking striping="false" acquire-timeout="10000" concurrency-level="500" write-skew="false"/>
<transaction mode="NONE"/>
<eviction max-entries="-1" strategy="NONE"/>
<expiration max-idle="-1"/>
<persistence passivation="false">
<jdbc:string-keyed-jdbc-store preload="true" fetch-state="true" read-only="false" purge="false">
<write-behind />
<property name="key2StringMapper">org.infinispan.lucene.LuceneKey2StringMapper</property>
<jdbc:connection-pool connection-url="jdbc:mysql://localhost:3306/hsearch"
driver="com.mysql.jdbc.Driver" username="my-username"
password="my-password"></jdbc:connection-pool>
<jdbc:string-keyed-table drop-on-exit="false" create-on-start="true" prefix="ISPN_STRING_TABLE">
<jdbc:id-column name="ID" type="VARCHAR(255)"/>
<jdbc:data-column name="DATA" type="MEDIUMBLOB"/>
<jdbc:timestamp-column name="TIMESTAMP" type="BIGINT"/>
</jdbc:string-keyed-table>
</jdbc:string-keyed-jdbc-store>
</persistence>
<indexing index="NONE"/>
<state-transfer enabled="true" timeout="480000" await-initial-transfer="true"/>
</distributed-cache>
<!-- ***************************** -->
<!-- Cache to store Lucene locks -->
<!-- ***************************** -->
<replicated-cache name="LuceneIndexesLocking" mode="ASYNC" async-marshalling="true">
<locking striping="false" acquire-timeout="10000" concurrency-level="500" write-skew="false"/>
<transaction mode="NONE"/>
<eviction max-entries="-1" strategy="NONE"/>
<expiration max-idle="-1"/>
<indexing index="NONE"/>
<state-transfer enabled="true" timeout="480000" await-initial-transfer="true"/>
</replicated-cache>
</cache-container>
</infinispan>
My jgroup configuration file is,
my-jgroup.xml
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.6.xsd">
<TCP bind_addr="${jgroups.tcp.address:192.168.1.48}"
bind_port="${jgroups.tcp.port:7800}"
enable_diagnostics="false"
thread_naming_pattern="pl"
send_buf_size="640k"
sock_conn_timeout="300"
thread_pool.min_threads="${jgroups.thread_pool.min_threads:2}"
thread_pool.max_threads="${jgroups.thread_pool.max_threads:30}"
thread_pool.keep_alive_time="60000"
thread_pool.queue_enabled="false"
internal_thread_pool.min_threads="${jgroups.internal_thread_pool.min_threads:5}"
internal_thread_pool.max_threads="${jgroups.internal_thread_pool.max_threads:20}"
internal_thread_pool.keep_alive_time="60000"
internal_thread_pool.queue_enabled="true"
internal_thread_pool.queue_max_size="500"
oob_thread_pool.min_threads="${jgroups.oob_thread_pool.min_threads:20}"
oob_thread_pool.max_threads="${jgroups.oob_thread_pool.max_threads:200}"
oob_thread_pool.keep_alive_time="60000"
oob_thread_pool.queue_enabled="false"
/>
<MPING bind_addr="${jgroups.tcp.address:192.168.1.48}"
mcast_addr="${jgroups.mping.mcast_addr:228.2.4.6}"
mcast_port="${jgroups.mping.mcast_port:43366}"
ip_ttl="${jgroups.udp.ip_ttl:2}"
/>
<MERGE3 min_interval="10000"
max_interval="30000"
/>
<FD_SOCK />
<FD_ALL timeout="60000"
interval="15000"
timeout_check_interval="5000"
/>
<VERIFY_SUSPECT timeout="5000" />
<pbcast.NAKACK2 use_mcast_xmit="false"
xmit_interval="1000"
xmit_table_num_rows="50"
xmit_table_msgs_per_row="1024"
xmit_table_max_compaction_time="30000"
max_msg_batch_size="100"
resend_last_seqno="true"
/>
<UNICAST3 xmit_interval="500"
xmit_table_num_rows="50"
xmit_table_msgs_per_row="1024"
xmit_table_max_compaction_time="30000"
max_msg_batch_size="100"
conn_expiry_timeout="0"
/>
<pbcast.STABLE stability_delay="500"
desired_avg_gossip="5000"
max_bytes="1M"
/>
<pbcast.GMS print_local_addr="false"
join_timeout="15000"
/>
<MFC max_credits="2m"
min_threshold="0.40"
/>
<FRAG2 />
My persistence.xml is,
<?xml version="1.0" encoding="UTF-8" ?>
<persistence-unit name="IC" transaction-type="RESOURCE_LOCAL">
<class>com.csgsol.model.Course</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://192.168.1.99:3306/sampleDb"/>
<property name="javax.persistence.jdbc.user" value="my-username"/>
<property name="javax.persistence.jdbc.password" value="my-password"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.search.default.directory_provider" value="infinispan"/>
<property name="hibernate.search.default.indexmanager" value="org.infinispan.query.indexmanager.InfinispanIndexManager"/>
<property name="hibernate.search.default.indexmanager" value="near-real-time"/>
<property name="hibernate.search.default.exclusive_index_use" value="false"/>
<property name="hibernate.search.default.worker.execution" value = "async"/>
<property name="hibernate.search.lucene_version" value="LUCENE_4_10_4"/>
<property name="hibernate.search.infinispan.configuration_resourcename" value="infinispan-config.xml"/>
</properties>
</persistence-unit>
</persistence>
The versions i am using are
Infinispan - 7.2.0.Final
Lucene - 4.10.4
You should not use mode="ASYNC" for index caches. Since Infinispan 8.2.x (https://issues.jboss.org/browse/ISPN-4065) this configuration is forbidden

How to call many databases without hard-coding?

I have following scenario:
There are many sites/departments and every site has it's own ServiceMix and different number of databases. Those databases are grouped, for example there are two groups: production_one and production_two.
On every site I deployed bundles as a datasource, one datasource for every database.
Datasource: blueprint.xml
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<!-- Properties -->
<!-- blueprint property placeholders, that will use etc/datasources.cfg as the properties file -->
<cm:property-placeholder id="db.placeholder" persistent-id="datasources">
</cm:property-placeholder>
<!-- Datasource -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url"
value="jdbc:sqlserver://${bundle_ds_1_db_host}:${bundle_ds_1_db_port};databaseName=${bundle_ds_1_db_database};" />
<property name="username" value="${bundle_ds_1_db_username}" />
<property name="password" value="${bundle_ds_1_db_password}" />
</bean>
<!-- Init database-->
<bean id="initDatabase"
class="com.xyz.mssql.ds.DatabaseInitBean"
init-method="create" destroy-method="destroy">
<property name="ds" ref="dataSource" />
</bean>
<service ref="dataSource" interface="javax.sql.DataSource">
<service-properties>
<entry key="datasource.name" value="${bundle_ds_1_ds_name}" />
<entry key="datasource.type" value="${bundle_ds_1_ds_type}" />
<entry key="datasource.id" value="${bundle_ds_1_ds_id}" />
<entry key="datasource.group_id" value="${bundle_ds_1_ds_group_id}" />
</service-properties>
</service>
There is also bundle, which receives a SOAP message via cxf and process it by calling database:
CXF: blueprint.xml
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cxf:cxfEndpoint id="processXEndpoint" address="/mssql-soap1/"
serviceClass="com.xyz.mssql.soap1.ProcessXService" />
<bean id="saveDataProcessor"
class="com.xyz.mssql.soap1.SaveDataProcessor">
<property name="ds" ref="dataSource" />
</bean>
<bean id="getDataProcessor"
class="com.xyz.mssql.soap1.GetDataProcessor">
<property name="ds" ref="dataSource" />
</bean>
<!-- DataSource -->
<reference id="dataSource" interface="javax.sql.DataSource"
filter="(datasource.name=mssql-ds-1)">
<reference-listener bind-method="onBind"
unbind-method="onUnbind">
<bean class="com.xyz.mssql.soap1.ListenerBean" />
</reference-listener>
</reference>
<!-- Camel Context -->
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="cxf">
<from uri="cxf:bean:processXEndpoint" />
<recipientList>
<simple>direct:${header.operationName}</simple>
</recipientList>
</route>
<route id="saveRoute">
<from uri="direct:saveData" />
<log message="Calling saveData" />
<process ref="saveDataProcessor" />
</route>
<route id="getRoute">
<from uri="direct:getData" />
<log message="Call getData" />
<process ref="getDataProcessor" />
</route>
</camelContext>
</blueprint>
The problem is, that following code inject to bean (ex: SaveDataProcessor) only one datasource resolved by it's name "datasource.name=mssql-ds-1", but I need to call many databases and on every servicemix installation there will be different number of them.
I need to call all databases (datasources) which have same type, for example "datasource.type=production_one".
Is it possible? How to do it?
How to pass to bean an array of datasources, or call this bean against every datasource which meet same conditions (name, type and so on).

Wildfly 8.2.0.Final: Misconfiguration because of example datasource or persistence.xml?

I have three datasources configured in my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
version="2.1">
<persistence-unit name="MyPersistenceUnit" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/myDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.connection.useUnicode" value="true" />
<property name="hibernate.connection.characterEncoding" value="UTF-8" />
<property name="hibernate.connection.charSet" value="UTF-8" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
</properties>
</persistence-unit>
<persistence-unit name="MyPersistenceTestUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.connection.useUnicode" value="true" />
<property name="hibernate.connection.characterEncoding" value="UTF-8" />
<property name="hibernate.connection.charSet" value="UTF-8" />
<property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/mydb" />
<property name="hibernate.connection.username" value="myuser" />
<property name="hibernate.connection.password" value="mypass" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
</properties>
</persistence-unit>
<persistence-unit name="MyLoggingUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.connection.useUnicode" value="true" />
<property name="hibernate.connection.characterEncoding" value="UTF-8" />
<property name="hibernate.connection.charSet" value="UTF-8" />
<property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/mydb" />
<property name="hibernate.connection.username" value="myuser" />
<property name="hibernate.connection.password" value="mypass" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
</properties>
</persistence-unit>
</persistence>
The first is the 'default' unit. It's used by the standard entity manager. The second is needed for running JUnit tests outside of a Java EE environment. The third one is used for logging to be independent from JTA transactions.
This works. But when I start Wildfly, I even get some of these errors (although I don't use H2 in my application):
21:32:33,748 ERROR [org.hibernate.tool.hbm2ddl.SchemaValidator] (ServerService Thread Pool -- 51) HHH000319: Could not get database metadata: org.h2.jdbc.JdbcSQLException: Table "PG_CLASS" not found; SQL statement:
select relname from pg_class where relkind='S' [42102-173]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)
It only happens when the application is deployed.
The idea was to disable or remove the ExampleDS by admin console or in standalone.xml, but when I do that, I get a startup with errors:
21:36:20,992 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "com.zonacroft.mycuisine.webserver-TRUNK.war")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.persistenceunit.\"com.mydomain.myapp.webserver-TRUNK.war#MyLoggingUnit\".__FIRST_PHASE__ is missing [jboss.data-source.java:jboss/datasources/ExampleDS]",
"jboss.persistenceunit.\"com.mydomain.myapp.webserver-TRUNK.war#MyPersistenceTestUnit\".__FIRST_PHASE__ is missing [jboss.data-source.java:jboss/datasources/ExampleDS]"
What on earth is going on here? Why does this persistence.xml need the exampleDS? Are the RESOURCE_LOCAL persistence units maybe wrong configured? (But if so, why do they work then). So what's the problem here?
[UPDATE]
I figured out that I don't get startup errors (with exampleDS enabled) when I remove the hibernate.hbm2ddl.auto properties from the RESOURCE_LOCAL persistence units. But it annoys me that I have to let the exampleDS of Wildfly enabled. Otherwise Wildfly would not start with the application as described above. Why is this so. What's wrong here?
You only define a datasource for the first persistence unit:
<jta-data-source>java:jboss/datasources/myDS</jta-data-source>
That means WildFly uses the default datasource exampleDS for your other persistence units.
This causes the exception, since the configured PostgreSQL dialect does not work for the default H2 datasource.

Error on persistence.xml configuring HSQLDB with Hibernate

I am configuring one HSQLDB database inside the application folder, follow below the persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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="crmUnity" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>br.com.crm.model.entities.Cliente</class>
<class>br.com.crm.model.entities.Contato</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
<property name="hibernate.connection.url" value="jdbc:hsqldb:file://database/crm;shutdown=true" />
<property name="hibernate.connection.user" value="sa" />
<property name="hibernate.flushMode" value="FLUSH_AUTO" />
</properties>
</persistence-unit>
</persistence>
The JBOSS 7.1.3 while starting show the error on log:
18:40:10,477 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 170) HHH000319: Could not get database metadata: java.sql.SQLException: No suitable driver found for jdbc:hsqldb:file://database/crm;shutdown=true
Can anybody help me about configure the jdbc url to resolve this error?
Thank's, TarcĂ­sio.

How can I use derby in memory with jpa2?

Regardless of the following persistence.xml configuration the database is persisted on disk.
<persistence-unit name="com.mysimpatico_inmemory_persistence_nbm_1.0-SNAPSHOTPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.mysimpatico.memoplatform.persistence.entities.Expression</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:tempDb;create=true"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="javax.persistence.jdbc.user" value=""/>
</properties>
http://wiki.apache.org/db-derby/InMemoryBackEndPrimer
I'm using Derby in memory for testing and my configuration is very close to yours.
Here is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_2_0.xsd" version="2.0">
<persistence-unit name="TestPu" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.acme.Foo</class>
<class>com.acme.Bar</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- Common properties -->
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:test-jpa;create=true"/>
<property name="javax.persistence.jdbc.user" value="APP"/>
<property name="javax.persistence.jdbc.password" value="APP"/>
<!-- EclipseLink specific properties -->
<property name="eclipselink.target-database" value="Derby"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.debug" value="ALL"/>
<property name="eclipselink.weaving" value="static"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<property name="eclipselink.logging.level.sql" value="FINEST"/>
<property name="eclipselink.logging.level.cache" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>
Where org.apache.derby:derby:jar:10.6.2.1 is on the classpath.
Now two questions/suggestions:
How do you know the database is persisted on disk?
If it really does, make sure you're using the persistence.xml you think you are.
Add the following to your maven configuration
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.3.2.GA</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.5.3.0</version>
<scope>test</scope>
</dependency>
The following persistance.xml works pretty well with hibernate.
<persistence-unit name="testPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>myapp.model.entities.Group</class>
<class>myapp.model.entities.User</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.connection.url" value="jdbc:derby:memory:jpa"/>
<property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.connection.username" value=""/>
<property name="hibernate.connection.password" value=""/>
</properties>
</persistence-unit>