Hi All,
In this post, I will be covering the steps required to set up JBoss Application Server in Linux/Ubuntu and creating multiple instances of JBoss in same machine.
JBoss Application Server (or JBoss AS) is a free software/open-source Java EE-based application server and is usable in any operating system supported by Java. The installation of JBoss is simply extracting the compressed archive into a folder.
Minimum requirements: Install java and define the environment variable JAVA_HOME
1. Download JBoss Application Server 7.1.1
The latest version of JBoss is available in the site 'http://jbossas.jboss.org/downloads/'. Copy the link location as shown in the figure.
$password jboss
mv jboss-as-7.1.1.Final /home/jboss/
mv /home/jboss/jboss-as-7.1.1.Final /home/jboss/jboss-as-7.1.1
Change the owner of the directory on jboss installed.
chown -R jboss.jboss jboss-7.1.1/
chmod -R 775 jboss-7.1.1/
su -l jboss
Open .bashrc file in /home/jboss and add below 2 lines
export JBOSS_HOME=$HOME/jboss-7.1.1
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
Update the changes and verify
echo $JAVA_HOME
echo $JBOSS_HOME
Open standalone.xml present in <JOBSS_HOME>/jboss-7.1.1/standalone/configuration and change the ports (here I am using 7080) in the below location and find <socket-binding-group> and <socket-binding> in it.
<socket-binding name="ajp" port="7009"/>
<socket-binding name="http" port="7080"/> <!-- Changed from 8080 to 7080 -->
<socket-binding name="https" port="7443"/>
<socket-binding name="osgi-http" interface="management" port="7090"/>
JBOSS_HOME/standalone/configuration/standalone.xml to change the "public" and "management" interfaces to point to hostname of your system as shown in above screenshot.
<interface name="management">
<inet-address value="${jboss.bind.address.management:<your hostname/ip address>}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:<your hostname/ip address>}"/>
</interface>
<JBOSS_HOME>/jboss-7.1.1/bin$ ./standalone.sh
The server start up message is shown as '[org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 1901ms - Started 133 of 208 services (74 services are passive or on-demand)'
CTRL+C can be used to stop the server.
cp <JBOSS_HOME>/jboss-7.1.1/bin/init.d/jboss-as-standalone.sh /etc/init.d/jboss7
Give execute permissions to the script.
chmod +x jboss7
Run the JBoss as a service.
service jboss7 start|stop|status|restart|reload
Access the admin console using http://<hostname>:9990
You will see the below error page as no users are added to access the admin console.
Create an internal JBoss management user which is used to access the new JBoss management console. This is done by running 'add-user.sh' script in <JBOSS_HOME>/bin location. We select the default value for the Realm (ManagementRealm), by hitting enter, and select 'jboss1' as our username. By default, we supply 'jboss1pwd' as our password, of course, you can provide any password you prefer here.
After finishing the above steps, start the server again and access the JBoss admin console again.
when your application is deployed. Access your application using
http://<hostname>:7080/test-app/
jboss-7.1.1
Comment the line /etc/init.d/functions and add the below 2 lines in the jboss7 script.
export JBOSS_HOME=$HOME/jboss-7.1.1
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
2. 'let' not found during starting the JBOSS service.
The command 'let' is a bash builtin, so if you're using it in a script that runs /bin/sh, it will fail, since /bin/sh on Ubuntu is dash, not bash.
Change from /bin/sh to /bin/bash in the starting line of the script.
Any feedback or suggestions is always welcome :-)
In this post, I will be covering the steps required to set up JBoss Application Server in Linux/Ubuntu and creating multiple instances of JBoss in same machine.
JBoss Application Server (or JBoss AS) is a free software/open-source Java EE-based application server and is usable in any operating system supported by Java. The installation of JBoss is simply extracting the compressed archive into a folder.
Minimum requirements: Install java and define the environment variable JAVA_HOME
Set up JBoss Application Server 7.1.1
1. Download JBoss Application Server 7.1.1
The latest version of JBoss is available in the site 'http://jbossas.jboss.org/downloads/'. Copy the link location as shown in the figure.
Use 'wget' command to download the ZIP file.
wget "http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip"
Unzip the file using the below command
'unzip jboss-as-7.1.1.Final.zip'
2. Creating new user to run the JBoss server and set the password using the following commands.
$useradd -d /home/jboss -s /bin/bash -m jboss$password jboss
3. Rename the folder to jboss-7.1.1 and change the ownership
Move the unzipped file to /home/jboss (or any other location where you want to setup) and rename it to jboss-7.1.1mv jboss-as-7.1.1.Final /home/jboss/
mv /home/jboss/jboss-as-7.1.1.Final /home/jboss/jboss-as-7.1.1
Change the owner of the directory on jboss installed.
chown -R jboss.jboss jboss-7.1.1/
chmod -R 775 jboss-7.1.1/
4. Set the JBoss and java classpath
Switch user to jboss user so that this new installation can be administered properly. It is not recommended to administer JBoss as rootsu -l jboss
Open .bashrc file in /home/jboss and add below 2 lines
export JBOSS_HOME=$HOME/jboss-7.1.1
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
Update the changes and verify
echo $JAVA_HOME
echo $JBOSS_HOME
5. To Change default port 8080
If you do not want to change the port and continue using the default port 8080, skip this step and move to step 6.Open standalone.xml present in <JOBSS_HOME>/jboss-7.1.1/standalone/configuration and change the ports (here I am using 7080) in the below location and find <socket-binding-group> and <socket-binding> in it.
<socket-binding name="ajp" port="7009"/>
<socket-binding name="http" port="7080"/> <!-- Changed from 8080 to 7080 -->
<socket-binding name="https" port="7443"/>
<socket-binding name="osgi-http" interface="management" port="7090"/>
6. To Access JBoss AS using hostname of IP
By default (due to security reasons) JBoss AS binds only to localhost. If you want to access it via your hostname or IP, then you can edit theJBOSS_HOME/standalone/configuration/standalone.xml to change the "public" and "management" interfaces to point to hostname of your system as shown in above screenshot.
<interface name="management">
<inet-address value="${jboss.bind.address.management:<your hostname/ip address>}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:<your hostname/ip address>}"/>
</interface>
7. Run the JBoss application
JBoss can be started using below command<JBOSS_HOME>/jboss-7.1.1/bin$ ./standalone.sh
The server start up message is shown as '[org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 1901ms - Started 133 of 208 services (74 services are passive or on-demand)'
CTRL+C can be used to stop the server.
8. Install JBoss AS 7 as a service
Create a file at /etc/init.d location.cp <JBOSS_HOME>/jboss-7.1.1/bin/init.d/jboss-as-standalone.sh /etc/init.d/jboss7
Give execute permissions to the script.
chmod +x jboss7
Run the JBoss as a service.
service jboss7 start|stop|status|restart|reload
9. After a successful startup, login to the JBoss admin console.
http://<hostname>:7080Access the admin console using http://<hostname>:9990
You will see the below error page as no users are added to access the admin console.
Create an internal JBoss management user which is used to access the new JBoss management console. This is done by running 'add-user.sh' script in <JBOSS_HOME>/bin location. We select the default value for the Realm (ManagementRealm), by hitting enter, and select 'jboss1' as our username. By default, we supply 'jboss1pwd' as our password, of course, you can provide any password you prefer here.
After finishing the above steps, start the server again and access the JBoss admin console again.
10. Deploying the application
Just copy your war file to <JBOSS_HOME>/standalone/deployments/ folder, it should deploy it automatically. It'll also create your_app_name.deployed file,when your application is deployed. Access your application using
http://<hostname>:7080/test-app/
Create Multiple Instances of JBoss Application Server 7.1.1
Follow the below steps to set up multiple instances of JBoss in the same server.
1. Create multiple directories under deployment folder. Here I am creating two directories named one and two under <JBOSS_HOME>/jboss-7.1.1/standalone/deployments folder.
2. Open standalone.xml file under <JBOSS_HOME>/jboss-7.1.1/standalone/configuration and change the deployment-scanner to point to one folder.
3. Create new standalone-two.xml file (copy of standalone.xml) under <JBOSS_HOME>/jboss-7.1.1/standalone/configuration and change the deployment-scanner to point to two folder. Also change port-offset to 2000 (default value is 0). This indicates that all the sockets will have their port offset by 2000 from the declared value. In the below example, http port is 7080, so the new http port is 9080.
4. Create new standalone-two.conf file under <JBOSS_HOME>/jboss-7.1.1/bin and point server default configuration file to use standalone-two.xml.
5. Create new standalone-two.sh file under <JBOSS_HOME>/jboss-7.1.1/bin and point to use standalone-two.conf file.
6. Now the instances can be started/stopped using their respective sh scripts.
For example, to deploy only the war/jar files under <JBOSS_HOME>/jboss-7.1.1/standalone/deployments/one directory, use ./standalone.sh command. The application can be accessed using http://<hostname>:7080/test-app/. Admin console using http://<hostname>:9990
To deploy only the war/jar files under <JBOSS_HOME>/jboss-7.1.1/standalone/deployments/two directory, use ./standalone-two.sh command. The application can be accessed using http://<hostname>:9080/test-app/ (9080 as our port-offset is 2000 in this case). Admin console can be accessed using http://<hostname>:11990
7. Below given is the structure of JBoss AS configured for multiple instances.
jboss-7.1.1
|-bin
|- standalone.conf
|- standalone.sh
|- standalone-two.conf
|- standalone-two.sh
|-standalone
|- configuration
|- standalone.xml
|- standalone-two.xml
|- deployments
|- one
|- test-app.war
|- two
|- test-app.war
ERRORS Occurred and its solution:
1. /etc/init.d/jboss7: 12: Can't open /etc/init.d/functions during starting the service.Comment the line /etc/init.d/functions and add the below 2 lines in the jboss7 script.
export JBOSS_HOME=$HOME/jboss-7.1.1
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
2. 'let' not found during starting the JBOSS service.
The command 'let' is a bash builtin, so if you're using it in a script that runs /bin/sh, it will fail, since /bin/sh on Ubuntu is dash, not bash.
Change from /bin/sh to /bin/bash in the starting line of the script.
Any feedback or suggestions is always welcome :-)