Integrating WildFly, PostgreSQL, and Netbeans

Sometime java can be cumbersome, there are many things to do to make it works even for simple thing like connecting database to application server, it may take a whole day. If you know the proper way, it’s not that time consuming and you can run the java web application without facing unexpected behaviour. Here I try to make the summary, well at least I don’t need to visit many places on the browser when I just want to do set up and start to code rigth away. Hopefully this sumary may help you as well. The following are 7 steps in having Netbeans on your computer integrated with WildFly as the application server and Postgresql as your database.

1. Download and Install Java Development Kit (JDK)

We need JDK, as a software development environment for developing Java applications. Download the latest JDK here:

2. Download and Install Netbeans IDE

Download the latest Netbeans here:

In the installation process, klik Customize then uncheck the GlassFish Server Open Source Edition because we want to use WildFly instead, then continue the process until the installation is complete.



3. Get the Latest  WildFly Application Server

If you don’t have WildFly on your computer, download one which has description Java EE7 Full & Web Distribution here:

After you get the file, you just need to extract and move it into any directory you want, I prefer putting it on C:.

4. Integrate WildFly with Netbeans 

Open the Netbeans application, right click Servers on the Services menu then click the Add Server...


Choose WildFly Application Server then click Next.


For the Server Location, browse to where you put the WildFly folder. Let the Server Configuration as its default (standalone-full) so we can use all its functions. Click Next and let all the fields as its default.


When it brings you back to your Netbeans window, right click again on WildFly Application Server then click Start.


On your browser, go to http://localhost:8080/. When you see the page below, it means your WildFly is running!


5. Integrate Postgresql with WildFly

Get the latest Postgresql here:

Lets assume that you already have Postgresql as your database. Now you need Postgresql JDBC (Java Database Connectivity). Get the JDBC here:, I put the file on the same directory with WildFly.

Run the following command:

 jboss-cli --connect

from c:\wildfly-10.1.0.Final\bin using terminal.

8 Run the following command (red is your JDBC file path).

module add\


Now you need to register JDBC Postgresql as datasource. Input the command bellow on the terminal:



6. Create Datasource

Open your PG Admin application (it’s included in you Postgresql installation) and create your own database. Now go to C:\wildfly-10.1.0.Final\standalone\configuration and open standalone-full.xml file. Copy the following text into datasource part in that file (adjust the red with yours) then save the change.

<datasource jndi-name="java:jboss/datasources/mydb" pool-name="mydb" enabled="true" use-java-context="true">
<connection-property name="ServerName">localhost</connection-property>
<connection-property name="PortNumber">5432</connection-property>
<connection-property name="DatabaseName">mydatabase</connection-property>
<check-valid-connection-sql>select 1</check-valid-connection-sql>


Select 1 is used as query to do connection test. In every 5000 ms the connection will be checked and reconnected.

7. Test Connection

On the terminal, run the following command to test your datasource connection.



The ritual is done! Now you can start to code as you got success from the outcome.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s