Introduction
Wildfly is an application server authored by Red Hat. It is written in Java, and implements the Java Platform, Enterprise Edition (Java EE) specification. It runs on multiple platforms.
Wildfly versions earlier than 8.0.0 are available under the name of JBoss Application Server. Indeed in November 2014, JBoss Application Server was renamed WildFly.
WildFly is free and open-source software, subject to the requirements of the GNU Lesser General Public License (LGPL), version 2.1.
Installing Wildfly
In this page you can download all wildfly versions. Unzip (or untar) in a folder (that show you how to WILDFLY_HOME).
Wildfly requires the Java SE 8 or later. Now add in $WILDFLY_HOME/bin/standalone.conf your java settings, for example:
export JAVA_HOME=/opt/jdk/1.8.0_91
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/lib
cd $WILDFLY_FOLDER/bin
./standalone.sh
nohup $WILDFLY_HOME/bin/standalone.sh > $WILDFLY_HOME/standalone/log/nohup.out &
Wildfly Configuration
Memory Configuration
If the wildfly shows the following error during starting:
you increase the memory according your needs, for example:
Unrecognized VM option 'MetaspaceSize=96M'
Could not create the Java virtual machine.
so it's needs an update of memory size, in $WILDFLY_HOME/bin/standalone.conf the default memory size is:
JAVA_OPTS="-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="-Xms2048m -Xmx2048m -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=512m -Djava.net.preferIPv4Stack=true"
Enable the remote Access
The Wildfly default configuration in $WILDFLY_HOME/standalone/configuration/standalone.xml file about the interfaces is the following:
If you want provides the remote access of your Wildfly you need the following replace the configuration in standalone.xml as below:
After the Wildfly restart, it will be accessible from remote hosts.
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
</interfaces>
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:0.0.0.0}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:0.0.0.0}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:0.0.0.0}"/>
</interface>
</interfaces>
Oracle Data Source
Follow the steps below to install the oracle data source:
- Download the ojdbc driver from Oracle.
- Create a subfolder $WILDFLY_HOME/modules/system/layers/base/com/oracle/db/main.
- Copy the driver (downloaded in step 1) in folder created in step 2.
- Always in this folder, create a file with name module.xml.
- Edit module.xml as the example below. Note: replace <version> according the driver downloaded in step 1.
- Add the oracle driver editing $WILDFLY_HOME/standalone/configuration/standalone.xml, xml tag with name <drivers>.
- Always in this file, add the datasource in <datasources>. Replace the highlighted params:
<datasource jndi-name="java:/[name]" pool-name="[pool-name]" enabled="true" use-java-context="true"> <connection-url>jdbc:oracle:thin:@[hostname]:1521:[sid]</connection-url> <driver>oracle</driver> <security> <user-name>[your_user]</user-name> <password>[password]</password> </security> </datasource>
<global-modules> <module name="com.oracle.db" slot="main"/> </global-modules>
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle.db">
<resources>
<resource-root path="ojdbc<version>.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
<driver name="oracle" module="com.oracle.db">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
Enable the CXF logger
Add in $WILDFLY_HOME/standalone/configuration/standalone.xml file (in system-properties xml tag, if the tag is not exist, you can add it as child node of server xml tag) the following system property:
<system-properties>
....
<property name="org.apache.cxf.logging.enabled" value="true"/>
....
</system-properties>
Also in this case it is necessary to restart.<system-properties> .... <property name="org.apache.cxf.logging.enabled" value="
pretty
"/> .... </system-properties>
GZip
gzip (GNU zip) is a compression utility designed to be a
replacement for compress. To improve the performance of a web application you can take advantage of gzip to compress web contents as js, css, etc ...
Add in $WILDFLY_HOME/standalone/configuration/standalone.xml file (in system-properties xml tag, if the tag is not exist, you can add it as child node of server xml tag) the following system properties:
Add in $WILDFLY_HOME/standalone/configuration/standalone.xml file (in system-properties xml tag, if the tag is not exist, you can add it as child node of server xml tag) the following system properties:
<system-properties>
.......
<property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION" value="on"/>
<property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES" value="text/javascript,text/css,text/html"/>
.......
</system-properties>
Deployment Scanner configuration
The deployment scanner is only used in standalone mode. To enable the hot deploy the deployment-scanner subsystem must be to set the auto-deploy-exploded to "true" in $WILDFLY_HOME/standalone/configuration/standalone.xml.
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0">
<deployment-scanner
scan-interval="5000"
relative-to="jboss.server.base.dir"
path="deployments"
auto-deploy-exploded="true" />
</subsystem>
Now copy
the package (war, ear, rar, etc..) in $WILDFLY_HOME/standalone/deployments
folder and create an empty file with <package_name>.dodeploy:
cp my-app.war $WILDFLY_HOME/standalone/deployments
touch my-app.war.dodeploy
my-app.war.deployed
Instead for undeploy, remove the file with suffix ".deployed" and create the file with suffix .skipdeploy, if we want undeploy the package of previus example:
rm my-app.war.deployed
touch my-app.war.skipdeploy
When the undeployment is done with success, Wildfly will automatically create the following file: my-app.war.undeployed
rm my-app.war.deployed
touch my-app.war.undeploy
When the undeployment is done with success, JBoss AS will automatically create the following file: my-app.war.undeployed