0

I am trying to use postgres in WildFly Full 9.0.1.Final. Unfortunately, for a task that should be simple, we have had 2 people trying for days to figure out how to make this work.

I should add that I am using Docker, and as I build the docker image I am trying various ways to add postgres support to WildFly Full 9.0.1.Final.

We have tried the following:

batch file

batch
connect
#module add --name=org.postgres --resources=/opt/jboss/wildfly/psql-jdbc.jar --dependencies=javax.api,javax.transaction.api

#module add --name=org.postgres --resources=/opt/jboss/wildfly/postgresql-9.3-1101.jdbc41.jar --dependencies=javax.api,javax.transaction.api    
module add --name=org.postgresql --slot=main --resources=/opt/jboss/wildfly/postgresql-9.3-1101.jdbc41.jar --dependencies=javax.api,javax.transaction.api

#/subsystem=datasources/jdbc-driver=postgresql:add(driver-name="postgresql",driver-module-name="org.postgresql",driver-class-name=org.postgresql.Driver)
#datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)
/subsystem=datasources/jdbc-driver=postgres:add(driver-name="org.postgresql",driver-module-name="org.postgresql",driver-class-name=org.postgresql.Driver)


#The batch failed with the following error (you are remaining in the batch editing mode to have a chance to correct the error): {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that #failed:" => {"Operation step-1" => "WFLYJCA0041: Failed to load module for driver [org.postgresql]"}}


#/subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgresql",driver-class-name=org.postgresql.Driver)




# Add the datasource
#data-source add --jndi-name=java:jboss/datasources/ISDS --name=pu-magick --connection-url=jdbc:postgresql://UI_PG_DATABASE:5432/magick --driver-name=postgresql --user-name=magick --password=magick
run-batch

In a Dockerfile

ADD modules /opt/jboss/wildfly/modules/

This attempt resulted in:

Caused by: java.lang.IllegalStateException: No layers directory found at /opt/jboss/wildfly/modules/system/layers
    at org.jboss.modules.LayeredModulePathFactory.resolveLayeredModulePath(LayeredModulePathFactory.java:65)
    at org.jboss.modules.LocalModuleFinder.getRepoRoots(LocalModuleFinder.java:111)
    at org.jboss.modules.LocalModuleFinder.<init>(LocalModuleFinder.java:107)
    at org.jboss.modules.LocalModuleFinder.<init>(LocalModuleFinder.java:88)
    at org.jboss.modules.LocalModuleLoader.<init>(LocalModuleLoader.java:57)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.jboss.modules.DefaultBootModuleLoaderHolder$1.run(DefaultBootModuleLoaderHolder.java:37)
    at org.jboss.modules.DefaultBootModuleLoaderHolder$1.run(DefaultBootModuleLoaderHolder.java:33)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.modules.DefaultBootModuleLoaderHolder.<clinit>(DefaultBootModuleLoaderHolder.java:33)
    ... 1 more

Adding driver to deployment directory

I have found in the past that a database driver can be added to jboss by adding the jar to the deployment directory. This, in my opinion, is about as complicated as it needs to be.

So, I also tried copying postgresql-9.3-1101.jdbc41.jar to /opt/jboss/wildfly/standalone/deployments/

DockerFile

FROM wildflyext/wildfly-camel
MAINTAINER ah <ah@domain.io>

ENV TMPDIR /tmp/
ENV WFDIR /opt/jboss/wildfly/

RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent






## COPY PG MODULE TO SERVER
#ADD module.xml opt/jboss/wildfly/modules/
#ADD standalone.xml $WFDIR/standalone/configuration/
#ADD system /opt/jboss/wildfly/modules/



## COPY PG DRIVER TO SERVER
#ADD postgresql-9.3-1101.jdbc41.jar /opt/jboss/wildfly/standalone/deployments/
#ADD postgresql-9.3-1101.jdbc41.jar /opt/jboss/wildfly/

#ADD psql-jdbc.jar $WFDIR/standalone/deployments/



## COPY STANDALONE TO SERVER
ADD standalone-camel.xml /opt/jboss/wildfly/standalone/configuration/


ADD config.sh $TMPDIR
ADD batch.cli $TMPDIR
RUN $TMPDIR/config.sh


#CMD ["-c", "standalone-camel.xml"] # loads correct standalone, cannot access mgmt console - connection interupted
#CMD ["-b", "0.0.0.0", "-c", "standalone-camel.xml"] # does not load correct standalone, cannot access mgmt console - connection interupted
#CMD ["-c", "standalone-camel.xml"m "-b", "0.0.0.0"] # WFLYSRV0073: Invalid option '/bin/sh'
#CMD ["-c", "standalone-camel.xml", "-b", "0.0.0.0"] # loads correct standalone, cannot access mgmt console - connection interupted

# attempt with two CMDs = loads incorrect standalone - standalone.xml, not standalone-camel.xml, cannot access mgmt console - connection interupted
#CMD ["-c", "standalone-camel.xml"]
#CMD ["-b", "0.0.0.0"]

# attempt with NO CMDs
Magick
  • 4,603
  • 22
  • 66
  • 103

1 Answers1

1

The solution was the following: In the cli file, I needed to have the following - the tick was correct naming:

module add --name=org.postgresql --slot=main --resources=/opt/jboss/wildfly/postgresql-9.3-1101.jdbc41.jar --dependencies=javax.api,javax.transaction.api


/subsystem=datasources/jdbc-driver=postgresql:add(driver-name="postgresql",driver-module-name="org.postgresql",driver-class-name=org.postgresql.Driver)

And I needed to remove this driver from the standalone, as it would clash with the above instructions.

Magick
  • 4,603
  • 22
  • 66
  • 103