Activities

September 2013
M T W T F S S
« Aug   Oct »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Install, configure and launch application on Jboss server.

I had an opportunity to setup a Jboss server for client to complete the dev. activities. I had any previous experience with Jboss even though just had hosted Opentaps few years before.

1. Where do I get Jboss installer file.

You may need to open an account with Jboss portal to download the latest jboss. Jboss 7.1.1.Final is the latest when the blog was posted which having 127MB in zip format.

2. JBOSS System requirements.

a. Latest JDK 1.7+ (java 1.7.0.40)
b. System variables and Path ( JAVA_HOME,JBOSS_HOME) and add the binaries in system path.

I have created a file java.sh in system script folder(/etc/profile.d/java.sh) having the following lines.

JAVA_HOME=/usr/java/jdk1.7.0_40
JAVA_FONTS=/usr/share/fonts/truetype
ANT_HOME=/usr/share/ant
JAVACC_HOME=/usr/java/javacc
SPRING_HOME=/usr/local/spring-framework-1.1.4
CLASSPATH=.:$JAVA_HOME/lib
JBOSS_HOME=/usr/local/jboss7
PATH=$JAVA_HOME:$JAVA_HOME/bin:$JAVACC_HOME/bin:$ANT_HOME/bin:$JBOSS_HOME/bin:$JBOSS_HOME/bin:ANT_HOME/bin:/usr/local/godesk/usr/bin:$PATH

Then execute the command,

 source /etc/profile.d/java.sh

Testing the variables was set.

root@dream [/home/installation]# echo $JAVA_HOME $JBOSS_HOME
/usr/local/jdk /usr/local/jboss7

3. Download the Jboss binary, unzip and copy to “/usr/local/jboss7”. We can run the JboSS in two modes either on standalone and domain mode. We can host any no. sites in standalone mode and domain mode is widely used for clustering setup supported by load balancer features.

Ok cool. Now we are ready to start Jboss server,

Starting jboss in a standalone mode,

Starting jboss : /usr/local/jboss7/bin/standalone.sh > /dev/null 2>&1 &

4. How to configure Jboss to listen in all NIC adapters and enabling AJP connectors.

By default, Jboss listen only on loopback ip. So that you can access the default site (http://localhost:8080) and administrative url (:9990). Also AJP connector did not enabled by default jboss settings. I need to enable AJP connector (:8009)in order to run the application over Apache web server on a clean url.

The core configuration file is standalone.xml.

Enabling JBOSS listening to all IP address .

Now you need to take backup of standalone.xml and replace all the string 127.0.0.1 to 0.0.0.0 inside it. That’s it.

How to enable AJP port in Jboss

You just need to add the following line in standalone.xml just before the Virtualhost directive start (/usr/local/jboss7/standalone/configuration/standalone.xml).

  <connector name="AJP" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>

.

Your configuration file will look likes as shown below,

 <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
            <connector name="AJP" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
            <virtual-server name="default-host" default-web-module="myproject">
                <alias name="localhost"/>
                <alias name="domain.com"/>
            </virtual-server>
        </subsystem>

Pls note my project module name is “myproject” which is running as default application for the domain “domain.com”

Now we need to start the JBoss application and verify that AJP connector is enabled.

#/usr/local/jboss7/bin/standalone.sh > /dev/null 2>&1 &

Find out the AJP port and other listening ports,

root@dream [~]# netstat -nlp | grep "java"
tcp        0      0 0.0.0.0:9990                0.0.0.0:*                   LISTEN      25071/java          
tcp        0      0 0.0.0.0:8009                0.0.0.0:*                   LISTEN      25071/java          
tcp        0      0 0.0.0.0:9999                0.0.0.0:*                   LISTEN      25071/java          
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      25071/java          
tcp        0      0 0.0.0.0:4447                0.0.0.0:*                   LISTEN      25071/java          
root@dream [~]#

Ok Perfect !

How do I deploy application in Jboss,

There are 5 ways I found from Google and I used 2 ways. ie

a. Uploading war file directly
to “deployment(/usr/local/jboss7/standalone/)” folder which is automatically deployed and can be accessible at http://serverip:8080/sampleapp/.

B. Use Web administrative url http://serverip:9990/sampleapp/ to upload your war file, Before you trying this option you may need to complete the following steps.

How Do I create JBOSS a admin user.
You can create admin user by add-user.sh command,

root@dream [/usr/local/jboss7/bin]# pwd
/usr/local/jboss7/bin
root@dream [/usr/local/jboss7/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 : jbossadmin
Password :
Re-enter Password :
About to add user 'jbossadmin' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'jbossadmin' to file '/usr/local/jboss7/standalone/configuration/mgmt-users.properties'
Added user 'jbossadmin' to file '/usr/local/jboss7/domain/configuration/mgmt-users.properties'
root@dream [/usr/local/jboss7/bin]

Once you created a Jboss Management userm you access the admin url at http://serverip:9990/console/App.html#deployments.

fina-jboss

You may get the sample war file to test from here[http://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war].Once you able to upload successfully, you can see the application running at http://serverip:8080/sample or http://serverip/sample in AJP environment. If you want to run this application on root space itself, Just change the “context” path to “/” instead of “sample” on the second window after the war upload 🙂

7. How do I add the Jboss in system startup.

Jboss installer itself has shipped with an startup script which will be found in “$JBOS_HOME/bin/init.d” folder. Now you need to copy the file to etc,

root@dream [/usr/local/jboss7/bin/init.d]# pwd
/usr/local/jboss7/bin/init.d
root@dream [/usr/local/jboss7/bin/init.d]# ls
  jboss-as.conf  jboss-as-standalone.sh*
root@dream [/usr/local/jboss7/bin/init.d]# mkdir /etc/jboss-as/
[root@dream]# cp jboss-as.conf /etc/jboss-as/
[root@dream]#cp jboss-as-standalone.sh /etc/init.d/jboss.sh

Now we need to edit,/etc/jboss-as/jboss-as.conf and update the variable “JBOSS_USER to root”

In order to complete the start script, just to set JAVA_HOME and JBOSS_HOME variables inside it. That’s it.

root@dream [/usr/local/jboss7/bin/init.d]#chkconfig jboss on
 root@dream [/usr/local/jboss7/bin/init.d]# service jboss stop
Stopping jboss-as: *** JBossAS process (23943) received TERM signal ***   [  OK  ]
root@dream [/usr/local/jboss7/bin/init.d]# netstat -nlp | grep "java"
root@dream [/usr/local/jboss7/bin/init.d]# service jboss start
Starting jboss-as:                         [  OK  ]
root@dream [/usr/local/jboss7/bin/init.d]#

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>