Featured Posts
  • How to download JBoss Server ?

    How to download JBoss Server ?

    Hi, JBoss is worlds one of the most popular and reliable application server which provides you a lots of features including full customization.  It comes in two flavours 1). JBoss Community Release 2). JBoss RedHat Enterprise Release Community Versus Enterprise JBoss Which one is Best? [youtube iNFV0r9v14g] The JBoss Community releases are the base of JBoss ...

    Read More

  • 4 ways to connect JBoss AS 7 using CLI

    4 ways to connect JBoss AS 7 using CLI

    With JBoss AS 7 Command Line Interface (CLI) has been introduced. Using CLI one can connect to the AS7 domain controller as well as to a standalone server and execute management operations like deploy, undeploy applications, create/delete queue, create/delete topics, create/delete data sources etc. In earlier release JBoss used ...

    Read More

  • Allow JBoss AS7 to reflect the changes made in the JSP files

    Allow JBoss AS7 to reflect the changes made in the JSP files

    Hi, Many times in development mode when we work then it is desired that as soon as we make any changes in the JSP based applications the the changes should be immediately reflected in the browser. So in this article we will see what configuration changes we need to make in ...

    Read More

  • Fetching Client IP Address and Header information in JBoss AS7 access log

    Fetching Client IP Address and Header information in JBoss AS7 access log

    Hi, Many times and usually in production environments it is desired to generate the "access.log" file separately for different web applications so that we can monitor how the users are accessing the application, from what all IP Addresses/Hostnames the clients are accessing the application. We also want to monitor sometimes that ...

    Read More

  • EE6 feature @Resource(lookup=”string”)  in JBoss AS7

    EE6 feature @Resource(lookup=string) in JBoss AS7

    Hi, Here we are going to see the usecase of EE6 specific javax.annotation.Resource annotation in JBoss AS7, The Resource annotation marks a resource that is needed by the application. This annotation may be applied to an application component class, or to fields or methods of the component class. When the ...

    Read More

  • Steps to create Windows service for JBoss AS 7

    Steps to create Windows service for JBoss AS 7

    With JBoss AS 7 lot of things have change for good and if you have noticed a lot of previous scripts have been removed due to which creating a Windows service for JBoss AS7 becomes little tricky, hence with this article we would help you create a Windows service for ...

    Read More

  • Enabling security audit logging in JBoss AS7

    Enabling security audit logging in JBoss AS7

    Hi, Most of the time in production environments it is desired to have the audit logging. Which contains the information and activities logged by the logged in user inside the audit.log. Enabling the "audit.log" logging is little different in JBoss AS7 compared to JBoss AS6, as there has been a ...

    Read More

  • How to create a Service Archieve SAR file in JBoss AS7

    How to create a Service Archieve SAR file in JBoss AS7

    Hi, SAR files are called as Service Archives. The extension of SAR files are *.sar which contains a "META-INF/jboss-service.xml" file, this file describes the custom MBeans which has to be exposed at the time of deployment or JBoss Startup. JBoss's service archive architecture is based on the JMX and the SAR ...

    Read More

  • Deploy and undeploy applicaitons using CLI in JBoss AS 7

    Deploy and undeploy applicaitons using CLI in JBoss AS 7

    With JBoss AS 7 Command Line Interface (CLI) has been introduced. Using CLI one can connect to the AS7 domain controller as well as to a standalone server and execute management operations like deploy, undeploy applications, create/delete queue, create/delete topics, create/delete data sources etc. In earlier release JBoss used to have ...

    Read More

  • How to Develop WebService and use @HandlerChain Annotation in JBoss AS7

    How to Develop WebService and use @HandlerChain Annotation in JBoss AS7

    Hi, As JBoss AS7 is very new And most powerful application server with many changes in it. Here we are going to see a very simple demo of how we can develop, build, deploy and test a simple WebService application in JBoss AS7 In this example we will mainly focus on following ...

    Read More

1 2 3 4 5 6 7 8 9 10

JBoss AS 7 Clustering on OpenShift

Hi,

High availability and fail-over are very important feature for any kind of infrastructure. As the name suggests the services should be available at any given point of time and requests should fail over if any component goes down abruptly. You can have several parallel instance of an application and can scale up and down depending on the business requirement, without worrying much about the cost. Load is distributed across different servers, and even if one or more of the servers fails, the application is still accessible via the other application instances. HA is crucial for scalable enterprise applications, as you can improve performance by adding more gears (which will be replica of your current one).

The latest Openshift Online has came up with “JEE Full Profile on JBoss” cartridge which allows you to get benefits of JBoss Clustering. It simply uses HAProxy as a load balancer upfront and creates multiple replicas of you application. The scaling can be based on your choice automatic or manual.

In this article we will see a demo of JBoss Clustering over Openshift. We will deploy a sample application on a two node JBoss Cluster and will try to replicate the user sessions in case of a jvm failure.

Step-1: Create a new application. Please note that we are using “-s” here to enable scaling:

$ rhc app create -a clusterwebapp -t jbossas-7 -s

Above will create a directory “clusterwebapp” at the location from where you ran the command from your terminal.

Download the application from : https://github.com/nikhilmone/ClusteredWebApp and put it inside the deployments directory. Once done simple git add, commit and push your application.

Step-2 : For this example we would be using manual scaling, so that we can quickly check if session replication works.

$ cd clusterwebapp/.openshift/markers/

Step-3 : Create a blank file as “disable_auto_scaling” :

$ touch disable_auto_scaling

Step-4 : Now add the changes to git repository, commit the changes and push them to Openshift server :

..

$ cd ../../

$ git add .openshift/markers/disable_auto_scaling

$ git commit -m "disabling auto-scaling"

$ git push

..

Step-3 : Once the auto-scaling is disabled, lets enable manual scaling :

Create an SSH connection to your application :

$ssh UUID@APPNAME-NAMESPACE.rhcloud.com

for eg :

ssh 123a456c09d12345b123a12345cc1234@clusterwebapp-mydomain.rhcloud.com

Step-4 : Run below command to enable manual scaling :

$ add-gear -a APPNAME -u UUID -n NAMESPACE

for eg :

..

add-gear -a clusterwebapp -u 123a456c09d12345b123a12345cc1234 -n mydomain

..

Now manual scaling is enabled. Let’s check if High Availability works. Try to access the application using the url :

Navigate to the management console now and select how many gears you want to scale your application, select two for now, so we will have a 2 node JBoss Clustering.

Let’s try to hit the application which is currently deployed on a 2 node JBoss Cluster.

http://clusterwebapp-mydomain.rhcloud.com/ClusterWebApp, this gives the welcome page.

You can see the session ID here. Now since we have established a session with the application, let’s bring down the JBoss node abruptly to check if this session fails over.

SSH to your application using :

ssh 123a456c09d12345b123a12345cc1234@clusterwebapp-mydomain.rhcloud.com

Grep for the java process and kill the process id, now our JBoss server is down. If clustering is working, the url should still work.

Hit http://clusterwebapp-mydomain.rhcloud.com/ClusterWebApp again, if this gives the same session ID that means our session has been failed over to the other JBoss node. To make sure this, do check the server logs :)

Note that you can only run TCP clustering on OpenShift as of now. The best part is a developer need not to bother about clustering configuration OpenShift takes care of that. Quite a PaaS huh !! :)

Regards,
Middlewaremagic Team :)


Integrate your Eclipse Juno IDE with Openshift

Hi,

In this article we will discuss how can we integrate our Eclipse IDE to OpenShift and create new applications. In previous articles we discussed about how we can connect to OpenShift and create application through command line and management console ? But of-course it would be really great if we can create, build, test, modify and publish our applications directly from the IDE itself.

I am going to use Eclipse Juno, which is the latest eclipse IDE and will create a sample JBossAS-7 application

Download Eclipse from here.

Download Eclipse Juno depending on your Operating System. I chose Windows-64 bit version. If you are already running an older version of Eclipse, you can always upgrade it or try to follow the same steps with little tweaks :)

Step-1: Start Eclipse and navigate to Help tab. Here select Eclipse Marketplace and search for JBoss Tools, click on install.

Select the OpenShift tools as shown in image :

Once done, click next and accept the License Agreements and then restart Eclipse. It will come up with a welcome page like below :

Step-2 : Lets create an application now. On the welcome page itself click on OpenShift Application. It will ask you to sign-in with your OpenShift account. Saving the password is completely your choice.

Now give a name to your application and select what type of application you want to create from the available options shown in below image. Also select the embedded cartridges, if you want to use any.

I am not using any embedded cartridge for now, now click next.

Here we get an option, whether we want to create a new project or would like to use an existing project. Also it is good to check the option for creating a server, which will help us to easily test and publish our application. Click next.

Now we need to setup clone destination, basically the application created on OpenShift Server will be cloned to this directory. Make sure that directory exists, before this setup :)

Step-3 : Now it is time to configure SSH keys, if you don’t.. you would end up with below.

Click on SSH2 Preferences to configure your keys. Navigate to Key Management and click on Generate RSA Key.

Let’s save the private key and click Ok.

Step-4 : Now you must add this public key to your OpenShift account. For this

login to your OpenShift account. Navigate to My Account page and add your Public Key there.

Let’s carry forward the Step-3 and click on finish. This will prompt you to enter a passphrase for your private key.

Click Ok and you will get a local copy of the application on your machine. You may see an error mark against your application in Package Explorer view, this can be solved by updating you maven configuration. Check below :

Step-5 : Now lets make some changes in to the application. I made a change in “index.html”. once you save this, you might get a popup stating that there has been a change in one of your file, would you like to publish it ? you can click on yes and the change would be pushed to OpenShift server.

Right click on your project and run the application on server.

This will first build your application :

and then it will publish it as well, see the changes that we made :

You can also navigate to the Servers tab, right click on your OpenShift Server and click on Publish.

If you want to tail the log files, check environment variables or try port-forwarding it is all there. See below :

So once the environment has been set, you can make multiple changes and can publish them at your will. :)

Regards,
Middlewaremagic Team :)


How to load jars residing over NFS in JBossAS7 classpath ?

Hi,

In this article we will discuss how can we load jars residing over NFS in JBoss AS-7 classpath. In some development environment, when there are multiple jars and properties files are being used by multiple servers, it is good to put all of them in a central repository, so that if the files (jar/properties files/xmls) are modified, all the servers will pickup the latest version and there will be less overhead related to copying the latest versions to individual servers

NFS allows a user on a client computer to access files over a network in a manner similar to how local storage is accessed. I installed NFS using below link :

Remote_Disk_Access_with_NFS#Installing_NFS

As JBoss AS-7 has introduced a module structure to load your custom jars. One can quickly create a custom module and put the required jars in them, with appropriate entries in module.xml . But in this case we would be needing an additional module directory, which would be residing over NFS server and we would map this to our local (client) server.

Step-1: Modify standalone.sh and add a separate module directory. To do this navigate to $JBOSS_HOME/bin and edit the file.

Search for keyword “module” and it should look like below :

..
if [ "x$JBOSS_MODULEPATH" = "x" ]; then
    JBOSS_MODULEPATH="$JBOSS_HOME/modules"
fi
..

Edit the above section of your “standalone.sh” script and then add the “:” separated path of your module directories as following

..
JBOSS_MODULEPATH=/mnt/nfs:$JBOSS_HOME/modules

#if [ "x$JBOSS_MODULEPATH" = "x" ]; then
  #  JBOSS_MODULEPATH="$JBOSS_HOME/modules"
#fi
..

Here /mnt/nfs/ is the directory, where our new module directory would be residing.

Step-2 : On the shared mount create below directory structure :

..
/mnt/nfs/
├── aaa
   └── bbb
       └── ccc
           └── main
               ├── module.xml
               ├── utility_JAR.jar

..

where

module.xml :

..

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="aaa.bbb.ccc">
   <resources>
       <resource-root path="utility_JAR.jar"/>
   </resources>
</module>

..

Step-3 : Now lets create a simple application which would be using utility_JAR.jar (ClassLoaderTestWAR.war). The war file will have below structure :”

..
ClassLoaderTestWAR.war/
├── index.jsp
├── WEB-INF
   ├── jboss-deployment-structure.xml
   ├── web.xml
..

Where :

index.jsp :

..
<html>
     <head><title>ClassLoader Demo</title></head>
     <body bgcolor="maroon" text="white">
            <center>
                    <h1>Class Loader Demo..</h1>

<%
       aaa.bbb.TestUtility utility=new aaa.bbb.TestUtility();
       String whichClassLoader=utility.sayWhichClassLoader();
       System.out.println("\n\n\t -----> "+whichClassLoader);
       out.println("<h1>"+whichClassLoader+"</h1>");
%>

      </body>
</html>
..

jboss-deployment-structure.xml :

..

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
 <deployment>
   <dependencies>
       <module name="aaa.bbb.ccc" />
   </dependencies>
 </deployment>
</jboss-deployment-structure>

..

web.xml :

..

<web-app>
   <welcome-file-list>
       <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
</web-app>

..

Step-4 : Now deploy the application and start the JBoss AS-7 server.

Step-5 : Access the application using : http://localhost:8080/ClassLoaderTestWAR

You will see something like below :

If the above output comes that means the jar was loaded from our new module directory, which resides over NFS.

Regards,
Middlewaremagic Team :)


How to achieve high availability on Openshift ?

Hi,

High availability is a very important feature for any kind of infrastructure. As the name suggests the services should be available at any given point of time. You can have several parallel instance of an application and can scale up and down depending on the business requirement, without worrying much about the cost. Load is distributed across different servers, and even if one or more of the servers fails, the application is still accessible via the other application instances. HA is crucial for scalable enterprise applications, as you can improve performance by adding more gears (which will be replica of your current one).

Lets create a scaled application and see how High Availability works in Openshift. Follow Below steps :

Step-1: Create a new application. Please note that we are using “-s” here to enable scaling:

$ rhc app create -a myhaproxy -t jbossas-7 -s

Above will create a directory “myhaproxy” at the location from where you ran the command from your terminal.

Now there are two types of scaling : Automatic and Manual. The command mentioned in Step-1 creates an application which is auto-scalable, i.e. the application will be scaled based on the incoming load. However you can also scale your application manually. For eg: if you are anticipating a certain amount of load, or you have limited resources (less number of gears available), or if you want to control the cost manually.

Lets see how can we scale our application manually.

Step-2 : Navigate from the directory “myhaproxy” which got created in Step-1 to :

$ cd myhaproxy/.openshift/markers/

Step-3 : Create a blank file as “disable_auto_scaling” :

$ touch disable_auto_scaling

Step-4 : Now add the changes to git repository, commit the changes and push them to Openshift server :

..

$ cd ../../

$ git add .openshift/markers/disable_auto_scaling

$ git commit -m "disabling auto-scaling"

$ git push

..

Step-3 : Once the auto-scaling is disabled, lets enable manual scaling :

Create an SSH connection to your application :

$ssh UUID@APPNAME-NAMESPACE.rhcloud.com

for eg :

ssh 123a456c09d12345b123a12345cc1234@myhaproxy-mydomain.rhcloud.com

Step-4 : Run below command to enable manual scaling :

$ add gear -a APPNAME -u UUID -n NAMESPACE

for eg :

..

add-gear -a myhaproxy -u 123a456c09d12345b123a12345cc1234 -n mydomain

..

Now manual scaling is enabled. Let’s check if High Availability works. Try to access the application using the url :

myhaproxy-mydomain.rhcloud.com, this gives the welcome page.

Now again ssh to your application using :

ssh 123a456c09d12345b123a12345cc1234@myhaproxy-mydomain.rhcloud.com

Grep for the java process and kill the process id, now our JBoss server is down. If high availability is working, the url should still work.

myhaproxy-mydomain.rhcloud.com, if this gives the welcome page, we are good :) . (Preferably try from a different browser)

You can see high availability statistics from the management console, by logging in to

You can also select minimum or maximum number of gears you want to scale up to.

Regards,
Middlewaremagic Team :)


Scheduling timed jobs using cron on Openshift

Hi,

Cron is UNIX/Linux service or daemon to execute scheduled commands according to instruction in a file. It uses a daemon, crond, which runs constantly in the background and checks every minute/ hour/ day/ week/ month or an year (based on the configuration) to see if any of the scheduled jobs need to be executed; if so, it executes them. These jobs are generally referred to as cron jobs.

You can use the OpenShift Enterprise cron scheduler to set up timed jobs for your applications. This would need a running Openshift application, a cron cartridge (cron-1.4) and a cronjob script.

Follow Below steps to configure a cronjob:

Step-1: Create a new application:

$ rhc app create -a crontestapp -t php-5.3

Above will create a directory “crontestapp” at the location from where you ran the command from your terminal.

Step-2 : Add the cron scheduler cartridge to your new application, to configure the cronjobs :

rhc app cartridge add -a crontestapp -c cron-1.4

Step-3 : Add the cron jobs to your application depending on whether you want to execute them minutely, hourly, daily, weekly or monthly. for this navigate to :

${Your Project dir}/crontestapp/.openshift/cron/{minutely,hourly,weekly,daily,monthly}/

For example try below script:

..
#!/bin/bash
#This is a test cron script
#Author : Nikhil Mone
(echo ========== Hostname ========= ; hostname ; echo ========== Date ========== ; date ; echo ========== Grep PHP procs ========= ; ps -ef | grep php ; echo =========================) > $OPENSHIFT_REPO_DIR/php/foo.txt &
..

Step-4 : Now commit your changes and push them to the remote repository.

$ git add .openshift/cron/

$ git commit -m “configuring my test cron jobs”

$ git push

The script will write the output to the file foo.txt every minute. Now try to access your application from the browser and append “/foo.txt”

for eg :

http://crontestapp-mydomain.rhcloud.com/foo.txt

You can also use curl to verify the operation of this script:

..
$ curl http://crontestapp-mydomain.rhcloud.com/foo.txt

========== Hostname =========
ex-std-node69.prod.rhcloud.com
========== Date ==========
Sat Jan 12 13:55:04 EST 2013
========== Grep PHP procs =========
1269     27627     1  0 11:53 ?        00:00:02 /usr/sbin/httpd -C Include /var/lib/openshift/642c790205d04d7db91a368c5cbf04c2//php-5.3/conf.d/*.conf -f /usr/libexec/openshift/cartridges/php-5.3/info/configuration/etc/conf/httpd_nolog.conf -k start
1269     27629 27627  0 11:53 ?        00:00:00 /usr/sbin/rotatelogs /var/lib/openshift/642c790205d04d7db91a368c5cbf04c2/php-5.3/logs/error_log-%Y%m%d-%H%M%S-%Z 86400
1269     27630 27627  0 11:53 ?        00:00:00 /usr/sbin/rotatelogs /var/lib/openshift/642c790205d04d7db91a368c5cbf04c2/php-5.3/logs/access_log-%Y%m%d-%H%M%S-%Z 86400
1269     27652 27627  0 11:53 ?        00:00:00 /usr/sbin/httpd -C Include /var/lib/openshift/642c790205d04d7db91a368c5cbf04c2//php-5.3/conf.d/*.conf -f /usr/libexec/openshift/cartridges/php-5.3/info/configuration/etc/conf/httpd_nolog.conf -k start
1269     28774 28765  0 13:55 ?        00:00:00 HTTP/1.1 200 OK
Date: Mon, 01 Sep 2014 07:28:37 GMT
P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
X-Pingback: http://middlewaremagic.com/jboss/xmlrpc.php
Vary: Accept-Encoding
Connection: close
Content-Type: text/html; charset=iso-8859-1
Cache-Control: private

500 - Internal Server Error