badera
badera

Reputation: 1545

Using postgresql jdbc driver with wildfly-arquillian-container-managed

We use arquillian with embedded wildfly[1] to run integration tests. Until now, we used H2 in memory DB. Due to some reasons, we need to switch to postgres also in the tests to bether cover real situation (in production, we use postgres). I currently get this error during deployment of my test.war:

13:57:30,981 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("jdbc-driver" => "postgresql")
]) - failure description: "WFLYJCA0041: Failed to load module for driver [org.postgresql.jdbc]"

which is clear, because the driver is not available.

But how do I bring the embedded wildfly to support the postgres jdbc driver? I am used to copy the driver to the module directory of the installed wildfly package... but this is not possible here... And it seems that there is no maven dependancy I could just add, which adds the jdbc driver...

By the way, add the end, my goal is to use an adapted standalone.xml which defines the Datasource (rather than using a xxx-ds.xml file) since I like to setup other settings as well.

[1]

    <dependency>
        <groupId>org.wildfly.arquillian</groupId>
        <artifactId>wildfly-arquillian-container-managed</artifactId>
    </dependency>

Upvotes: 0

Views: 878

Answers (1)

Thorsten Klaus
Thorsten Klaus

Reputation: 36

I manage to solve the problem copying the standalone.xml, the jdbc driver and a module.xml into the extracted wildfly.

Those are my first steps using maven and arquillian with an embedded wildfly. Any suggestions for improvement are welcome.

<build>
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>                    
                <execution>
                    <id>unpack</id>
                    <phase>process-test-classes</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.wildfly</groupId>
                                <artifactId>wildfly-dist</artifactId>
                                <version>10.1.0.Final</version>
                                <type>zip</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>target</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>                    
                <execution>
                    <id>copy-db-driver</id>
                    <phase>process-test-classes</phase>
                    <goals>
                        <goal>copy</goal> 
                   </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.postgresql</groupId>
                                <artifactId>postgresql</artifactId>
                                <version>9.4.1212</version>
                                <outputDirectory>target/wildfly-10.1.0.Final/modules/system/layers/base/org/postgresql/main</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>                    
            </executions>
        </plugin>            
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.0.2</version>
            <executions>
                <execution>
                    <id>copy-standalone-config</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/wildfly-10.1.0.Final/standalone/configuration</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/test/resources</directory>
                                    <includes>
                                        <include>standalone.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                </execution>
                <execution>
                    <id>copy-module-xml</id>
                    <phase>process-test-classes</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/wildfly-10.1.0.Final/modules/system/layers/base/org/postgresql/main</outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/test/resources</directory>
                                <includes>
                                    <include>module.xml</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>            
        ...
    </plugins>
</build>

Upvotes: 1

Related Questions