wildfly (Jboss AS) installation with Postgresql driver on Mac

Datasource command line 등록

  1. https://wildfly.org/downloads/ 에서 download

  2. unzip 아무 디렉토리나

  3. cd ~

  4. vi .bash_profile

  5. export JBOSS_HOME=<<아무 디렉토리나>>

    만약에 java 가 없다면 JDK를 install하고 JAVA_HOME 을 이와 같이 설정해야 한다.

  6. source .bash_profile

  7. https://jdbc.postgresql.org/download.html 에서 최신 드라이버 다운

  8. <<아무 디렉토리나>>/bin 으로 이동

  9. jdbc driver 등록

stevenucBookPro:bin steven$ ./jboss-cli.sh 
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect

[standalone@localhost:9990 /] module add --name=org.postgres --resources=/<<다운로드받은 디렉토리 Path>>/postgresql-42.2.6.jar --dependencies=javax.api,javax.transaction.api

[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)
{"outcome" => "success"}

[standalone@localhost:9990 /] data-source add --jndi-name=java:jboss/jndiName --name=poolName --connection-url=jdbc:postgresql://url/databaseName --driver-name=postgres --user-name=userId --password=userPassword

[standalone@localhost:9990 /] exit

상위와 같이 작성 완료 후 다음 파일들이 추가 되었는지 확인 한다.

<>/modules/org/postgres/main

> stevenucBookPro:main steven$ ls -al
> total 1656
> drwxr-xr-x 4 steven admin 128 7 19 17:03 .
> drwxr-xr-x 3 steven admin 96 7 19 16:47 ..
> -rw-r--r-- 1 steven admin 317 7 19 16:47 module.xml
> -rw-r--r-- 1 steven admin 842825 7 19 16:47 postgresql-42.2.6.
>

>

<>/standalone/configuration

> ....        
> <subsystem xmlns="urn:jboss:domain:bean-validation:1.0"/>
> <subsystem xmlns="urn:jboss:domain:core-management:1.0"/>
> <subsystem xmlns="urn:jboss:domain:datasources:5.0">
> <datasources>
> <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
> <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
> <driver>h2</driver>
> <security>
> <user-name>sa</user-name>
> <password>sa</password>
> </security>
> </datasource>
> <datasource jndi-name="java:jboss/<<jndiName>>" pool-name="<<poolName>>">
> <connection-url>jdbc:postgresql://url/databaseName</connection-url>
> ....
>

>

Datasource wildfly console

https://jdbc.postgresql.org/download.html?source=post_page---------------------------

여기에서 드라이버 링크 복사

[root@localhost deployments]# pwd
/root/wildfly/wildfly/standalone/deployments

root@localhost deployments]# wget https://jdbc.postgresql.org/download/postgresql-42.2.6.jar
--2019-07-25 18:04:54-- https://jdbc.postgresql.org/download/postgresql-42.2.6.jar
Resolving jdbc.postgresql.org (jdbc.postgresql.org)... 72.32.157.228, 2001:4800:3e1:1::228
Connecting to jdbc.postgresql.org (jdbc.postgresql.org)|72.32.157.228|:443... connected.
HTTP request sent, awaiting responseㅔㅈㅇ... 200 OK
Length: 842825 (823K) [application/java-archive]
Saving to: ‘postgresql-42.2.6.jar’

100%[=================================================================================================>] 842,825 818KB/s in 1.0s

2019-07-25 18:04:56 (818 KB/s) - ‘postgresql-42.2.6.jar’ saved [842825/842825]

[root@localhost deployments]# ls
README.txt postgresql-42.2.6.jar
[root@localhost deployments]# systemctl restart wildfly.service

서비스 재 실행 이후

http://<>/console

접근 이후

Homepage > Configuration > Datasource&Driver > JDBC Driver

를 확인 해보면 해당 드라이버가 존재 하는 것을 확인 가능

이경우는 deployments에서 삭제할 경우 드라이버도 같이 삭제 됨으로 비추