我正在尝试在WildFly Full 9.0.1.Final中使用postgres。不幸的是,对于一个应该简单的任务,我们已经有两个人试图找出如何使这项工作。
我应该补充一点,我正在使用Docker,当我构建docker镜像时,我正在尝试各种方法向WildFly Full 9.0.1.Final添加postgres支持。
我们尝试过以下方法:
批处理文件
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
在Dockerfile中
ADD modules /opt/jboss/wildfly/modules/
此尝试导致:
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
将驱动程序添加到部署目录
我在过去发现可以通过将jar添加到部署目录来将数据库驱动程序添加到jboss。在我看来,这与它所需要的一样复杂。
所以,我也尝试将postgresql-9.3-1101.jdbc41.jar
复制到/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
答案 0 :(得分:0)
解决方案如下: 在cli文件中,我需要有以下内容 - tick是正确的命名:
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)
我需要从独立版中删除此驱动程序,因为它会与上述说明冲突。