Name: Shekhar

Web Site: http://whyjava.wordpress.com/

Bio: A blogger,writer, and speaker. Loves to learn new technologies and apply them wherever applicable.

Posts by Shekhar Gulati

    OpenShift Express — The Future Of RedHat PaaS

    Last couple of days I was at JUDCon India conference held in Bangalore where I gave a session on OpenShift. The JUDCon India was the biggest JUDCon conference ever with more than 800 attendees. Sessions were mainly on topics -- Infinispan, JBoss AS7 , OpenShift, CDI, Rules Engine, and other JBoss tools. I was mainly interested in hearing the thoughts of RedHat guys on OpenShift -- its future, comparison with Cloud Foundry, and when it will be open sourced. Read more »

    MongoDB Replica Set on OpenShift Flex

    As I am preparing for my JUDCon session on OpenShift one topic that I will be covering is setting up MongoDB Replica Set on OpenShift Flex. There are various reasons to setup MongoDB replication. The primary reason for replication is to ensure data survive single or multiple machine failures. The more replicas you have, the more likely is your data to survive one or more hardware crashes. With three replicas, you can afford to loose two nodes and still serve the data.Replication also helps to scale reads as you can distribute your read load accross multiple machines. There are two ways to support replication in MongoDB -- Master Slave and Replica Set. Replica Set is the recommended way to do replication and OpenShift only supports replica set.  OpenShift Flex MongoDB replica set is yet not polished so you might face issues in setting up. This blog will show steps to configure a working MongoDB replica set on OpenShift Flex. If you are not aware of MongoDB Replica Set you should first refer to the MongoDB documentation. Also you can refer to my blog on how to use MongoDB replica set with Spring. Read more »

    Using Hibernate SafeHtml Validator In Application Running On OpenShift Express

    I use Spring Roo to create sample applications for me. Spring Roo uses JSR 303 (Bean Validation) to validate the entities for invalid values. Today I created a very simple application -- a simple PasteBin clone where you can anonymously create post or share text snippets. I wanted to validate that field post should not contain any Unsafe HTML content in it. So I decided to use Hibernate SafeHtml validator to validate the input field. This post will first show you how to use @SafeHtml validator in an Spring application and then we will deploy the application to OpenShift Express. Read more »

    Running Spring Java MongoDB Apps on OpenShift Express Using Spring Roo OpenShift Express Addon

    Last couple of years Spring Roo has been one of my favorite tool to rapidly build Spring applications for demo, POC, and learning new technologies. With Spring Roo Cloud Foundry integration you can not only build applications rapidly but deploy to Cloud Foundry public cloud with a couple of commands. In case you are not aware of Spring Roo and Cloud Foundry you can refer to my Spring Roo series on IBM DeveloperWorks. From last 5-6 months I have been following OpenShift platform as a service and I am really in love with OpenShift Express because of its feature set and simplicity. In case you are not aware of OpenShift Express please refer to the documentation. There are two ways Java applications can be deployed to express --- using ruby command line tool called RHC and using Eclipse plugin. Personally I like rhc command line more than eclipse plugin. The rhc command line tool is great but you should have ruby runtime installed on your machine. Being Spring Roo afficianado I decided to write Spring Roo OpenShift Express add-on to create, deploy, add cartridges from with Roo shell. This can be thought of as a third way to deploy applications to OpenShift Express. The project is hosted on Google Code at http://code.google.com/p/spring-roo-openshift-express-addon/. In this blog I will show you how you can install the add-on, create a template OpenShift Express application, convert that application to a Spring MongoDB application using Spring Roo, and finally deploy application to OpenShift Express. All of this will be done from with in Roo shell. Read more »

    Deploying Spring Roo MySQL Applications on JBoss AS7

    Today I spend some time deploying a simple Spring Roo application on JBoss AS 7. I faced lot of issues in making Spring Roo application run on JBoss AS7. This is a step by step guide from creating Spring Roo application using Roo shell to configuring different databases like h2 and MySQL and finally making them run on JBoss AS7. So lets get started. Please make sure that you have downloaded latest Spring Roo version 1.2 and JBoss AS 7 from their respective web sites.

    1. Created a simple Spring Roo web application by typing the commands shown below.
      project --topLevelPackage com.shekhar.bookshop --projectName bookshop
      jpa setup --database H2_IN_MEMORY --provider HIBERNATE --jndiDataSource java:jboss/datasources/ExampleDS
      entity jpa --class ~.domain.Book
      field string --fieldName title --notNull
      field string --fieldName author --notNull
      field number --type double --fieldName price --notNull
      web mvc setup
      web mvc all --package ~.web
      perform package
      q
      
    2. Make sure in the applicationContext.xml the jndi declaration look like as shown below
      <jee:jndi-lookup id="dataSource" jndi-name="java:jboss/datasources/ExampleDS"/>
      
    3. Rename the bookshop-0.1.0.BUILD-SNAPSHOT.war to bookshop.war and copy it to <JBoss-AS7-HOME>/standalone/deployments folder and start the server using ./standalone.sh on *nix machines. Read more »