Porting Oracle’s “First Cup” Tutorial to Wildfly / JBoss

  JBoss, Tutorial, Wildfly

JBoss Developer Studio and Wildfly Setup

Installation of the JBoss Developer Studio is quite straightforward. Nothing special at all. You should memorize where its workspace is located on your hard drive, just in case.

Even the Wildfly setup is completely standard. In case you already worked with your Wildfly installation and tampered its configuration files, here are the important parts which this tutorial depends on. Please note that these configuration settings are taken from the standard, out-of-the box installation of Wildfly. If you have never modified any of them, just skip this section.

For this project to run properly we need to launch Wildfly in standalone mode, and the corresponding configuration file sits in %WILDFLY_HOME%/standalone/configuration/standalone.xml. For the persistence layer of the ‘Dukes-Age’ application we use the build-in H2 in-memory database. By Wildfly defaults, the H2 database engine is already fully configured. See the corresponding configuration entries, taken from standalone.xml.

        <subsystem xmlns="urn:jboss:domain:datasources:4.0">
            <datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
                    <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>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>

As you can see in above configuration, Wildfly comes with the predefined datasource ‘ExampleDS’. You can easily check whether this datasource is functional by going to Wildfly’s admin page (http://localhost:9990) and go to Configuration -> Datasources -> Non-XA -> ExampleDS -> View -> Connection. There you’ll see the “Test Connection” button. If the test completes successful, the H2 database engine is working fine.

In the next chapter, we will create the parent maven project which will later reference the two maven modules ‘dukes-age’ and ‘firstcup-war’. The parent maven project simplifies a few things, for example we don’t have to repeatedly configure maven dependencies in multiple dependant maven modules. The biggest benefit is that we can add the Wildfly Java EE 7 BOM (Bill-of-material) to it, so we don’t need to worry about most dependency library versions in our modules.

LEAVE A COMMENT