Tag: jboss

Integrate your Eclipse Juno IDE with Openshift


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. 🙂

Middlewaremagic Team 🙂

How to achieve high availability on Openshift ?


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 :


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.

Middlewaremagic Team 🙂

Continuous Integration on OpenShift using Jenkins


In this article we will discuss about Continuous Integration. What it is? Why to use it? and how to integrate the this model on OpenShift.

While working on a code change, a developer takes a copy of the current code base on which to work. As other developers submit changed code to the source code repository, this copy gradually does not reflect the repository code. There may be addition/removal of new/old libraries and resources, that the developer may not be aware of and can result in potential conflicts.

The longer a branch of code remains checked out, the greater the risk of multiple integration conflicts and failures becomes when it is reintegrated into the main line. When developers submit code to the repository they must first update their code to reflect the changes in the repository since they took their copy. The more changes the repository contains, the more work developers must do before submitting their own changes. In a worst-case scenario, developers may have to discard their changes and completely redo the work.

Continuous integration involves integrating early and often, so as to avoid above issues. The practice aims to reduce rework and thus reduce cost and time. With CI each programmer must do a complete build and run (and pass) all unit tests before submitting their work. Integration tests are usually run automatically on a CI server when it detects a new commit.

Lets see how we can use jenkins on Openshift :

Step-1 :

We will create an application using jbossas-7 web cartridge with jenkins enabled. This will eventually create two applications in your OpenShift account, one as jenkins and one as your app.

$ rhc app create -a $application name -t jbossas-7 –enable-jenkins

for example :

[userone@userone OpenShift]$ rhc app create -a testjenkins -t jbossas-7 --enable-jenkins
Password: ********

Creating application: jenkins in userone
Now your new domain name is being propagated worldwide (this might take a minute)...
Confirming application 'jenkins' is available:  Success!

jenkins published:  http://jenkins-userone.rhcloud.com/
git url:  ssh://0b514430c6c24688aa0475d34cfe8a95@jenkins-userone.rhcloud.com/~/git/jenkins.git/

Jenkins created successfully.  Please make note of these credentials:

   User: admin
   Password: CgyLzMVUzVg3

Note:  You can change your password at: https://jenkins-userone.rhcloud.com/me/configure

Creating application: testjenkins in userone
Now your new domain name is being propagated worldwide (this might take a minute)...
Warning: Permanently added the RSA host key for IP address '' to the list of known hosts.
Now embedding the jenkins client into 'testjenkins'...
Confirming application 'testjenkins' is available:  Success!

testjenkins published:  http://testjenkins-userone.rhcloud.com/
git url:  ssh://2483a237b65e44cf932d1e6ecc49f047@testjenkins-userone.rhcloud.com/~/git/testjenkins.git/
Successfully created application: testjenkins

Note : Make sure to save the credentials for Jenkins server.

Step-2 :

Log in to Jenkins console by navigating to : https://jenkins-yourdomain name.rhcloud.com/

You will see a build with your application name.


Step-3 :

Now open a terminal on your local machine and navigate to the directory from where you ran Step-1. There will be a directory with your application name.

$ cd testjenkins/deployments

Now put a sample application (war/ear) inside it. You can also put an exploded war/ear but just make sure to create an empty file as “yourapplication.war.dodeploy”.

for eg :

[userone@userone deployments]$ pwd
[userone@userone deployments]$ ls -ltra
total 12
-rw-rw-r--. 1 userone userone    0 Jul 21 12:47 .gitkeep
drwxr-xr-x. 6 userone userone 4096 Jul 21 12:47 ..
-rw-rw-r--. 1 userone userone    0 Jul 21 13:05 PostDataDemo.war.dodeploy
drwxrwxr-x. 3 userone userone 4096 Jul 21 13:05 .
drwxrwxr-x. 4 userone userone 4096 Jul 21 13:07 PostDataDemo.war

Step-4 :

Now push the changes to OpenShift repository :

$ cd $yourappdir

$ git add .

$ git commit -a -m “my first commit”

$ git push

Once we push the changes you will see a build is getting scheduled on Jenkins server and you can track it from Jenkis console (mentioned in Step-2)

for eg:

[userone@userone testjenkins]$ git add .

[userone@userone testjenkins]$ git commit -a -m "unexploded commit"
[master e08e8bc] unexploded commit
 6 files changed, 49 insertions(+), 0 deletions(-)
 delete mode 100644 deployments/PostDataDemo.war
 create mode 100644 deployments/PostDataDemo.war.dodeploy
 create mode 100644 deployments/PostDataDemo.war/META-INF/MANIFEST.MF
 create mode 100644 deployments/PostDataDemo.war/WEB-INF/web.xml
 create mode 100644 deployments/PostDataDemo.war/index.jsp
 create mode 100644 deployments/PostDataDemo.war/logout.jsp
 create mode 100644 deployments/PostDataDemo.war/test.jsp

[userone@userone testjenkins]$ git push
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 1.25 KiB, done.
Total 11 (delta 1), reused 0 (delta 0)
remote: Executing Jenkins build.
remote: You can track your build at https://jenkins-userone.rhcloud.com/job/testjenkins-build
remote: Waiting for build to schedule....Done
remote: Waiting for job to complete.........................................................Done
remote: SUCCESS
remote: New build has been deployed.
To ssh://2483a237b65e44cf932d1e6ecc49f047@testjenkins-userone.rhcloud.com/~/git/testjenkins.git/
   8e4fe25..e08e8bc  master -> master

From console you can see :

The build is successful.

Step-5 :

Now try to access your application. Just make sure if you have given a context root for your application you need to add it in front of your openshift app url. for eg :


where “PostDataDemo” was context root of my application.

So from here you can make changes in any part of your code and just follow step-4. If by any chance there are any issues in code or build fails.. need not to worry as when build fails the content will not be deployed and hence won’t affect your running application.

In case of any issue, you can tail jenkins or application logs, using below command :

$ rhc app tail -a jenkins

$ rhc app tail -a $yourapplication name

Also you can check Jenkins build console output, by logging in Jenkins server from browser.

You can always tweak in your Jenkins configuration to have added functionalities. 🙂

MiddlewareMagic Team 🙂

Copyright © 2010-2012 Middleware Magic. All rights reserved. |