Saturday, 26 January 2013

Open Terminal and Execute following commands:

-------------------------------------------------------- RHC SETUP ------------------------------------------------------
STEP 1) Install Redhat Packages:

$ sudo gem install rhc

STEP 2) Setup Redhat:

$ rhc setup

STEP 3) Check the setup is properly done:

rhc domain show OR rhc app show --state

---------------------------------------------- RHC SETUP COMPLETED ----------------------------------------------



--------------------------------------------------------- EXAMPLE-----------------------------------------------------------

STEP 4) Create an application using rhc command where ever you want. Note that according to the value of the local git repository path you declare, this is where  your application will be created. This will create a project with all folder structure and other web app descriptor files.
So for example if you use the following rhc command:

$ rhc-create-app -a HelloWorld -l sunil.gulabani@indianic.com -t jbossas-7 -r HelloWorld

you will see that HelloWorld directory created at the path that was supplied with -r created. See below the content of HelloWorld directory after creation:


STEP 5) Now with maven you can easily turn this application into an eclipse application.
Switch your working directory to the folder of you new application for example

$ cd HelloWorld

Now use the following maven command in order to prepare the project for import to eclipse:

$ mvn eclipse:eclipse

Once the maven task end the project is ready to be imported into eclipse.

STEP 6) Before starting adding content removing the current pom.xml and other artifacts created at application creation is required:

$ git rm -r src pom.xml

$ git commit -m "removing artifacts from application creation phase"



STEP 7) Import the project to eclipse
We start by importing an existing project into eclipse

Now select the directory of you new application as the root:

Click next and the project will appear in you eclipse projects tree.



STEP 8) Change the project facet to Dynamic Web, Java (1.6 and above), Javascript

Changing the project facet is just a matter of few clicks:
- Right click on your project and select properties.
- Select Project Facets (press convert to allowing facets to be defined for you project as eclipse suggests).

- Click ok. You project now is configured in eclipse as Dynamic Web Project which is more convenient for later common web app tasks.

- Now lets add a simple jsp file to the project before commiting and deploying to openshift express.

- Just right click on the project and select New–>jspFile (as the project facet is dynamic web app new jsp is available and will be placed under the WebContent folder the same will be available with other web resources like servlets).
    - Now its time to commit and deploy to openshift.

STEP 9) Creating a war file The easiest way to package the project into a war via eclipse export option so just right click on the project and export as HelloWorld.war into the HelloWorld/deployments folder of the application.

STEP 10) From console: Add to your openshift git commit and push
Now that you have a war file ready for deployment (HelloWorld/deployments/HelloWorld.war) lets add it to the git repository and then commit and finally we will push the war to the openshift express instance.
Open a terminal window and switch the working directory to the application’s deployments directory then execute the following commands:

$ cd deployments/

$ git add HelloWorld.war

$  git commit -m "depolying myapp application" HelloWorld.war

$ git push

Note that git repository is created at the root project level so all files can be added to git and not only the deployment.

STEP 11) Your push completed and you application should be available at the following openshift URL:

http://helloworld-jsr10.rhcloud.com/HelloWorld/index.jsp

0 comments:

Post a Comment

Find me on Facebook! Follow me on Twitter!