How to install jboss application Server in CentOS 6.x

In this post we will learn how to install Wildfly which was earlier known as JBOSS Application Server.
For Wildfly the main dependency is Java. In your system Java must be installed and Java environment variable should also be set.

I have done this practical after doing minimal installation of CentOS 6.4 which is 64 bit O.S
Note: IPTABLES and SELINUX is disabled

To install the Wildfly(JBOSS Application Server),follow the given below steps

Step 1: First we will install wget because it is freshly minimal installed system.If you already have wget in your system you can skip this step

yum -y install wget

Step 2: Download WildFly (JBOSS) and Java. Currently Jboss-AS 7.1.1 is latest hence I selected this version.
Also download the JDK from this link. (http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html ). After downloading the JDK rpm ,scp or ftp it to your system.(I hope you are aware about how to scp and do ftp)

wget download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip

Step 3: I have downloaded the jdk-7u40-linux-i586.rpm which is currently latest available package.You can download and install as per latest available JDK package.
Use the command rpm -ivh package-name.rpm

[root@localhost ~]# rpm -ivh jdk-7u40-linux-i586.rpm 
Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
	rt.jar...
	jsse.jar...
	charsets.jar...
	tools.jar...
	localedata.jar...
	jfxrt.jar...
	plugin.jar...
	javaws.jar...
	deploy.jar...
[root@localhost ~]#

Step 4: Now search the location where Java is installed.
Use the command

find / -name java

On further search in /usr/java I found the latest package name as jdk1.7.0_40


ls -ld /usr/java/jdk1.7.0_40/

Step 5: Now set the Java environment. Because Java package is installed at /usr/java/jdk1.7.0_40. We will use this path.

Edit the /etc/profile and in last line append the JAVA_HOME and PATH variables value

vi /etc/profile

export JAVA_HOME=/usr/java/jdk1.7.0_40
export PATH=/usr/java/jdk1.7.0_40/bin:$PATH

Now activate the recently added java environment variable,use the below given command

source /etc/profile

Step 6: Now we will unzip the downloaded jboss file and extract out in /opt


yum install unzip -y

unzip jboss-as-7.1.1.Final.zip -d /opt

Step 7: Add new user called jboss ,you can choose any other name also.I selected this name because it is easy to remember the user jboss is used for Jboss Application Server.

useradd jboss

Step 8: Change the group and ownership of extracted jboss-as directory recursively.

chown -R jboss:jboss /opt/jboss-as-7.1.1.Final/

Step 9: Now we will add Management User.First login with username called jboss.(No need to logout if you are still login with root user)

su -l jboss

/opt/jboss-as-7.1.1.Final/bin/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): a

Enter the details of the new user to add.
Realm (ManagementRealm) : 
Username : jboss
Password : 
Re-enter Password : 
About to add user 'jboss' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'jboss' to file '/opt/jboss-as-7.1.1.Final/standalone/configuration/mgmt-users.properties'
Added user 'jboss' to file '/opt/jboss-as-7.1.1.Final/domain/configuration/mgmt-users.properties'

Step 9: Now start the JBOSS server bydefault it runs in localhost and allow access only in localhost. (You are still login with username called jboss,it is not good idea to run jboss with user root)

nohup /opt/jboss-as-7.1.1.Final/bin/standalone.sh &

For accessing JBOSS remotely ,use below given command

nohup /opt/jboss-as-7.1.1.Final/bin/standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0 &

To shutdown the JBOSS use below given command


/opt/jboss-as-7.1.1.Final/bin/jboss-cli.sh --connect command=:shutdown

Step 10: To access JBOSS admin console use port no. 9990

Note: Replace ip-address-of-jboss-server with IP address of Server (To get ip address use command ifconfig)

Open the webbrowser and type
http://ip-address-of-jboss-server:9990

Step 11: To access JBOSS Application Server,open the browser and use port no. 8080

http://ip-address-of-jboss-server:8080

6 thoughts on “How to install jboss application Server in CentOS 6.x”

  1. Hello Sharad!
    I followed your guide till the end (skipping step 9B because I want Jboss to run locally). I’m having 2 problems:
    1) I can’t connect to Jboss server via localhost:8080 from Firefox browser. Jboss gets started since ps -ef | grep jboss gives a long output about jboss.
    2) I’m unable to stop Jboss. I get this, when I try to stop it as user “jboss”:

    [jboss@centos jboss-as-7.1.1.Final]$ bin/jboss-cli.sh --connect command=:shutdown
    org.jboss.as.cli.CliInitializationException: Failed to connect to the controller
    at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:229)
    at org.jboss.as.cli.impl.CliLauncher.main(CliLauncher.java:195)
    at org.jboss.as.cli.CommandLineMain.main(CommandLineMain.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.modules.Module.run(Module.java:260)
    at org.jboss.modules.Main.main(Main.java:291)
    Caused by: org.jboss.as.cli.CommandLineException: The controller is not available at localhost:9999
    at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:639)
    at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:613)
    at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:227)
    ... 8 more
    [jboss@centos jboss-as-7.1.1.Final]$

    The controller is not available at localhost:9999“? What does that mean?

    There are no ports 8080 or 9990 open. Is it iptables blocking traffic? Here are netstat and iptables‘ outputs:
    A]
    [jboss@centos jboss-as-7.1.1.Final]$ netstat -napt | grep LISTEN
    (No info could be read for "-p": geteuid()=503 but you should be root.)
    tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
    tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
    tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
    tcp 0 0 0.0.0.0:58074 0.0.0.0:* LISTEN -
    tcp 0 0 :::57773 :::* LISTEN -
    tcp 0 0 :::111 :::* LISTEN -
    tcp 0 0 ::1:631 :::* LISTEN -
    [jboss@centos jboss-as-7.1.1.Final]$

    B]

    [dolly@centos opt]$ sudo iptables -L
    [sudo] password for dolly:
    Chain INPUT (policy ACCEPT)
    target prot opt source destination
    ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
    ACCEPT icmp -- anywhere anywhere
    ACCEPT all -- anywhere anywhere
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
    ACCEPT udp -- anywhere anywhere state NEW udp dpt:ipp
    ACCEPT udp -- anywhere 224.0.0.251 state NEW udp dpt:mdns
    ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ipp
    ACCEPT udp -- anywhere anywhere state NEW udp dpt:ipp
    REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
    ACCEPT all -- anywhere anywhere

    Chain FORWARD (policy ACCEPT)
    target prot opt source destination
    REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination
    [dolly@centos opt]$

    Reply
  2. Thanks for the article. It was really helpful and informative, although I was unable to get it working on my CentOS 6 VPS. I don’t know why the Jboss server was unable to start even though I had working java. Anyway, I combined this article http://www.rosehosting.com/blog/installing-and-setting-up-java-jboss-7-final-on-a-centos-6-linux-vps/ with yours and now I have fully working Jboss on my virtual server.

    the only thing I have to figure out is how to access my deployed application without using the port number? Do you by any chance can help me or point me to the right direction/documentation?

    Reply
    • Hello Brad,

      “how to access my deployed application without using the port number” as per your question, I understand that you want to access the application without port 8080 .

      In this case, you can use reverse proxy in apache server. Here is the post.
      Kindly let me know if stuck with issue. I am eager to help you

      Regards
      Sharad

      Reply
  3. Hello Sharad Sir, I went through this blog to install the java and jboss. when I set the java home directory it was giving me an error. The error was
    /opt/jboss-as-7.1.1.Final/bin/add-user.sh: line 66: /usr/java/jdk1.7.0_51/bin/java/bin/java: Not a directory
    I made some modification on my /etc/profile as follows
    instead of
    export JAVA_HOME=/usr/java/jdk*/bin/java; I did this
    export JAVA_HOME=/usr/java/jdk*/
    and the problem was solved.
    The “/bin/java” portion is implied so you so not need to add it in the JAVA_HOME variable. In other words, if you have installed Java in the following directory on your linux systems:

    Reply
    • Thankyou keshab,

      Appreciate,you reported the issue. Typo is corrected now
      Shame on me, I did this typo mistake. In JAVA_HOME variable , it must be JDK installation directory path that is /usr/java/jdk1.7.0_51 .
      I will also suggest you to use absolute path of JDK installation directory i.e /usr/java/jdk1.7.0_51 (check the path) , do not use *, it means ‘anything matching with’ . In future you may require to install new version of JDK hence use absolute path of JDK

      Regards
      Sharad

      Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.