1

At the very beginning of artifact deploy, Wildfly validates all persistence unit described in persistence.xml. One on the responsible classes is org.jboss.as.jpa.processor.PersistenceUnitServiceHandler from wildfly-jpa library.

The main question: is it possible to disable this validation somehow? Or just mark persistence unit as ignored?

Details an root cause:

We are going to build environment-free artifacts. So the configuration inside persistence.xml will be overridden in java code at the very beginning. Default configuration is dummy and looks like this:

<persistence-unit name="cassandra_unit" transaction-type="RESOURCE_LOCAL">
    <provider>com.impetus.kundera.KunderaPersistence</provider>
    <class>sample.model.Manager</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="kundera.nodes" value="localhost"/>
        <property name="kundera.port" value="9165"/>
        <property name="kundera.username" value="test"/>
        <property name="kundera.password" value="test"/>
        <property name="kundera.keyspace" value="keyspace"/>
        <property name="kundera.dialect" value="cassandra"/>
        <property name="kundera.client.lookup.class" value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory"/>
    </properties>
</persistence-unit>

But wildfly validates persistence units and calls KunderaPersistence.createContainerEntityManagerFactory. Kundera in it's turn checks connection against localhost:9165 and fails. So deployment fails too.

Any workaround is acceptable.

1 Answers1

6

Hopefully, I found solution. Need to add

<property name="jboss.as.jpa.managed" value="false"/>

into persistence.xml. Wildfly will ignore persistence unit on startup.

And it will possible to initialize it manually via

Persistence.createEntityManagerFactory("cassandra_unit", kunderaProperties)

and apply all required override logic.

Hope this will save someone's life )

Seed more wildfly-specific properties at org.jboss.as.jpa.config.Configuration class inside wildfly-jpa jar