WildFly 8.2 Installation and First Steps

Installation of Wildfly 8.2

Download Wildfly 8.2 from http://wildfly.org/downloads/

$ cd /home/oracle/WILDFLY
$ unzip  /media/sf_kits/JEE/wildfly-8.2.0.Final.zip

In case you have multiple Wildfly instances runing  you can easily rename top level directory 
$ mv wildfly-8.2.0.Final wildfly-8.2.0.Final_PRODUCITON

Some useful SHELL variables 
export WILDFLY_HOME=/home/oracle/WILDFLY/wildfly-8.2.0.Final_PRODUCITON
alias wf=$WILDFLY_HOME/bin/standalone.sh
alias wfd='cd $WILDFLY_HOME'

Start and stop  Wildfly 
Start WildFly in standalone mode;
[oracle@wls1 local]$ $WILDFLY_HOME/bin/standalone.sh 
=========================================================================

  JBoss Bootstrap Environment
  JBOSS_HOME: /usr/local/wildfly-8.2.0.Final
  JAVA: /usr/java/jdk1.7.0_71/bin/java
  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
...

Now test that we can display the first WEB Page using the default WILDFLY HTTP PORT number:
$ firefox localhost:8080

Stop the Server 
[oracle@wls1 ~]$ $WILDFLY_HOME/bin/jboss-cli.sh --connect command=:shutdown
{"outcome" => "success"} 

Add an Admin User

$ add-user.sh
What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a): 
Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : oracle
....

Changing Ports [in case you need to run as 2.nd WILDFLY instance on your System ]

Edit  $WILDFLY_HOME/standalone/configuration/standalone.xml
Change
   <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
        <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
        <socket-binding name="http" port="${jboss.http.port:8080}"/>
        <socket-binding name="https" port="${jboss.https.port:8443}"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
</socket-binding-group>
to 
    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9980}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9983}"/>
        <socket-binding name="ajp" port="${jboss.ajp.port:8010}"/>
        <socket-binding name="http" port="${jboss.http.port:8081}"/>
        <socket-binding name="https" port="${jboss.https.port:8444}"/>
        <socket-binding name="txn-recovery-environment" port="4702"/>
        <socket-binding name="txn-status-manager" port="4703"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="26"/>
        </outbound-socket-binding>
    </socket-binding-group>

Restart your server and verify the new Ports:  
$ $WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9980 command=:shutdown
{"outcome" => "success"}
$ $WILDFLY_HOME/bin/standalone.sh 

$ firefox localhost:8081  --> Should display the Wildfly default page
$ firefox localhost:9980  --> You should be able to successfully login to the Management Console 

Use jboss.cli to connect to new Management Controller 
$ $WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9980 

Server.log should report the changed PORT numbers:
10:58:40,755 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017519: Undertow HTTP listener default listening on /127.0.0.1:8081
..
10:58:41,737 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9980/management
10:58:41,738 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9980

 

Setup Oracle JDBC driver and a RAC datasource

Step 1: Add Oracle JDBC driver as a module 
[oracle@wls1 WILDFLY]$ cat add_module.cli 
module add --name=com.oracle.ojdbc --resources=/home/oracle/JDBC/Driver/ojdbc7.jar --dependencies=javax.api,javax.transaction.api

$ $WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9980  --file=add_module.cli 

Verify that the proper module.xml was created 
$ ls modules/com/oracle/ojdbc/main/
module.xml  ojdbc7.jar
$ cat  modules/com/oracle/ojdbc/main/module.xml 
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle.ojdbc">
    <resources>
        <resource-root path="ojdbc7.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
<module>

Step 2: Deploy the JDBC driver
$ cat add_jdbc_driver.cli
/subsystem=datasources/jdbc-driver=oracle/:add(driver-name=oracle, driver-module-name=com.oracle.ojdbc, driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource) 
$  $WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9980  --file=add_jdbc_driver.cli
{"outcome" => "success"} 

Verify Driver 
[oracle@wls1 WILDFLY]$   $WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9980   /subsystem=datasources:installed-drivers-list
 {
    "outcome" => "success",
    "result" => [
        {
            "driver-name" => "oracle",
            "deployment-name" => undefined,
            "driver-module-name" => "com.oracle.ojdbc",
            "module-slot" => "main",
            "driver-datasource-class-name" => "",
            "driver-xa-datasource-class-name" => "oracle.jdbc.xa.client.OracleXADataSource",
            "driver-class-name" => "oracle.jdbc.OracleDriver",
            "driver-major-version" => 12,
            "driver-minor-version" => 1,
            "jdbc-compliant" => true
        },
..
Verify Server.log :
11:29:33,533 INFO  [org.jboss.as.connector.subsystems.datasources] (management-handler-thread - 4) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 12.1)
11:29:33,534 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) JBAS010417: Started Driver service with driver-name = oracle

Step 3 : Add and verify a DataSource 
$ cat add_ds.cli
if (outcome != success) of /subsystem=datasources/data-source=myRacDS:read-resource
    data-source add \
        --name=myRacDS \
        --driver-name=oracle \
        --jndi-name=java:jboss/datasources/myRacDS \
        --user-name="scott"\
        --password="tiger"\
        --use-java-context=true \
        --use-ccm=true \
        --min-pool-size=5 \
        --max-pool-size=10 \
        --pool-prefill=true \
        --allocation-retry=1 \
        --prepared-statements-cache-size=32 \
        --share-prepared-statements=true \
        --connection-url="jdbc:oracle:thin:@ract2-scan.grid12c.example.com:1521/banka"
end-if

$ $WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9980  --file=add_ds.cli
$ $WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9980 /subsystem=datasources/data-source=myRacDS:read-resource
{
    "outcome" => "success",
    "result" => {
        "allocation-retry" => 1,
        ...
        "connection-url" => "jdbc:oracle:thin:@ract2-scan.grid12c.example.com:1521/banka",
        "datasource-class" => undefined,
        "driver-class" => undefined,
        "driver-name" => "oracle",
        "enabled" => true,
        ..
        "jndi-name" => "java:jboss/datasources/myRacDS",
        "jta" => true,
        "max-pool-size" => 10,
        "min-pool-size" => 5,
        ...
        }
    }
}

Test the Connection 
-> Ping the SCAN address
[oracle@wls1 WILDFLY]$  ping ract2-scan.grid12c.example.com
PING ract2-scan.grid12c.example.com (192.168.5.221) 56(84) bytes of data.
64 bytes from 192.168.5.221: icmp_seq=1 ttl=64 time=0.534 ms
64 bytes from 192.168.5.221: icmp_seq=2 ttl=64 time=0.298 ms

Test test Connection
$WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9980  /subsystem=datasources/data-source=myRacDS:test-connection-in-pool
{
    "outcome" => "success",
    "result" => [true]
}

Display and change JTA Transaction Timeout

Display JTA Transaction Timeout 
$  $WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9990
      '/subsystem=transactions/:read-attribute(name=default-timeout)'
{
    "outcome" => "success",
    "result" => 30
}
--> JTA Transaction Timeout : 30 seconds

Change JTA Transaction Timeout 
$ $WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9990 
    '/subsystem=transactions/:write-attribute(name=default-timeout,value=60)'
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}

Deploy a compiled Web application project

Assume we have already created and tested WFJPA2EL-1.0.war and want to deploy this to our new Wildfly server :
$ cp WFJPA2EL-1.0.war /home/oracle/WILDFLY/wildfly-8.2.0.Final_PRODUCITON/standalone/deployments 
$ touch /home/oracle/WILDFLY/wildfly-8.2.0.Final_PRODUCITON/standalone/deployments/WFJPA2EL-1.0.war.dodeploy

For Redeployment run: touch /home/oracle/WILDFLY/wildfly-8.2.0.Final_PRODUCITON/standalone/deployments/WFJPA2EL-1.0.war.dodeploy
Server.log should report: 
15:32:08,432 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017534: Registered web context: /WFJPA2EL-1.0
15:32:08,465 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018565: Replaced deployment "WFJPA2EL-1.0.war" with deployment "WFJPA2EL-1.0.war"

Now test the project 
$ firefox http://localhost:8081/WFJPA2EL-1.0

15:30:46.253 Calling  getRacInfo() in progress ... 
15:30:46.254 EclipseLink Version: 2.5.2 - [ EclipseLink 2.5.2 == JPA 2.1] 
15:30:46.255 Driver Name             : Oracle JDBC driver
15:30:46.256 Driver Version          : 12.1.0.2.0
15:30:46.257 Database Product Version: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
15:30:46.439 DB Name:  BANKA
15:30:46.440 1. Instance Name: bankA_3 - Host: hract21.example.com
15:30:46.440 Leaving getRacInfo() without Exceptions !

Remove a single prepared transaction from WildFly LOG Store

Cleanup Wildfly LOG STORE

  • Be careful don’t run thes commands on a production system as you can easily corrupt your system
  • These commands should only used on your test system

Check for prepared transactions 

$ cat prepared_xa.cli
/subsystem=transactions/log-store=log-store/:probe()
ls /subsystem=transactions/log-store=log-store/transactions $WILDFLY_HOME/bin/jboss-cli.sh --connect --file=prepared_xa.cli
{"outcome" => "success"}
0:ffffc0a805c9:-18c2b06f:55fac789:137
0:ffffc0a805c9:-18c2b06f:55fac789:145
0:ffffc0a805c9:-18c2b06f:55fac789:153
0:ffffc0a805c9:-18c2b06f:55fac789:fa
0:ffffc0a805c9:35abdaa8:55fbbb60:11b
0:ffffc0a805c9:35abdaa8:55fbbb60:355
0:ffffc0a805c9:35abdaa8:55fbbb60:49
0:ffffc0a805c9:35abdaa8:55fbbb60:5b
0:ffffc0a805c9:35abdaa8:55fbbb60:f1

Verify TX Object Store at File System Level
$ ls -1 ./standalone/data/tx-object-store/ShadowNoFileLockStore/defaultStore/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/
0_ffffc0a805c9_-18c2b06f_55fac789_137
0_ffffc0a805c9_-18c2b06f_55fac789_145
0_ffffc0a805c9_-18c2b06f_55fac789_153
0_ffffc0a805c9_-18c2b06f_55fac789_fa
0_ffffc0a805c9_35abdaa8_55fbbb60_11b
0_ffffc0a805c9_35abdaa8_55fbbb60_355
0_ffffc0a805c9_35abdaa8_55fbbb60_49
0_ffffc0a805c9_35abdaa8_55fbbb60_5b
0_ffffc0a805c9_35abdaa8_55fbbb60_f1

Shutdown Wildfly and delete all prepared Transactions 
$WILDFLY_HOME/bin/jboss-cli.sh  --connect --controller=localhost:9990 command=:shutdown
$ rm ./standalone/data/tx-object-store/ShadowNoFileLockStore/defaultStore/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/*

Restart Wildfly and verify LOG STORE  $WILDFLY_HOME/bin/jboss-cli.sh --connect --file=prepared_xa.cli
{"outcome" => "success"}

Reference

One thought on “WildFly 8.2 Installation and First Steps”

  1. Why manually change port numbers. use the portoffset and let wildfly handle it for you.
    For example change:
    jboss.socket.binding.port-offset:0
    To:
    jboss.socket.binding.port-offset:100

    Wildfly will automatically add 100 to each port #. All you have to do is reference it that way.

Leave a Reply

Your email address will not be published. Required fields are marked *