Chameleon with JDBC Driver


#1

I started WildFly 11 managed: using Chameleon configuration, however, I am not able to add JDBC driver (PostgreSQL). Using an older approach such as unpacking WildFly and then modifying modules and standalone.xml I was able to make it work, but what would be a way to do that when using Chameleon? Can I somehow invoke e.i. Jboss-cli?

The only configuration that I found comes from arquillian-extension-persistence but I do not fully understand it.

What would be the best solution when using Chameleon? Or should I just strat without Chameleon?

Error:
ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation (“add”) failed - address: ([(“deployment” => “X_test.war”)]) - failure description: {
“WFLYCTL0412: Required services that are not installed:” => [“jboss.jdbc-driver.postgres”],
“WFLYCTL0180: Services with missing/unavailable dependencies” => [“jboss.data-source.“jboss.naming.context.java.jboss.datasources.XDS” is missing [jboss.jdbc-driver.postgres]”]
}

EDIT
Below I present my current configuration

Wildfly11.class

@Target({ ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@ChameleonTarget("wildfly:11.0.0.Final:managed")
public @interface Wildfly11 { }

arquillian.xml

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="
        http://jboss.org/schema/arquillian
        http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

    <defaultProtocol type="Servlet 3.0"/>
    <extension qualifier="persistence-dbunit">
        <property name="datatypeFactory">org.dbunit.ext.postgresql.PostgresqlDataTypeFactory</property>
        <property name="excludeTablesFromCleanup">hibernate_sequence</property>
        <property name="filterTables">true</property>
    </extension>
</arquillian>

test-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="xp">
        <jta-data-source>java:jboss/datasources/XpDS</jta-data-source>
        <properties>
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.hbm2ddl.auto" value="update"/>
        </properties>
    </persistence-unit>
</persistence>

wildfly-ds.xml

<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="
        http://www.jboss.org/ironjacamar/schema
        http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">

    <datasource jndi-name="java:jboss/datasources/XpDS" pool-name="XpDS" enabled="true"
                use-java-context="true">

        <connection-url>jdbc:postgresql://localhost:5432/xp_test</connection-url>
        <driver>postgres</driver>
        <security>
            <user-name>postgres</user-name>
            <password>postgres</password>
        </security>
    </datasource>
</datasources>

And deployment:

@Wildfly11
@RunWith(ArquillianChameleon.class)
public abstract class AbstractWildflyTestCase {

    @Deployment
    public static Archive<?> createDeployment(){
        System.out.println(AbstractWildflyTestCase.class.getPackage().getName());

        return ShrinkWrap
                .create(WebArchive.class, "Xp_test.war")
                .addPackage(AbstractWildflyTestCase.class.getPackage().getName())
                .addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml")
                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                .addAsWebInfResource("wildfly-ds.xml");
    }
}

#2

@bartoszmajsak any chance for a tip/example project?

Possible approaches and problems:

  1. Upload PostgreSQL driver as a module, but not sure if it’s possible using Chameleon
  2. Use CLI to add datasource and driver
  3. Maven?

#3

Any chance to share some code so I can take a look? That could help me see the context.


#4

I attached some code to my question. Hope it can give you some more context about what I am trying to do.