auto-deploy java server faces (jsf) web application to amazon web services (aws) cloud using jenkins...
DESCRIPTION
More on the steps at: http://jmsktm.tumblr.com/post/84078298860/auto-deploy-jsf-maven-project-on-amazon-ec2-using There are few more in my blog on the topic. http://jmsktm.tumblr.com/TRANSCRIPT
James SinghMaharishi University of Management
04/23/2014
[email protected]://www.twitter.com/jmsktm
Web Application Architecture (WAA)Honors Project (presentation)
Auto-Deploy Java Server Faces (JSF) Web Application To
Amazon Web Services (AWS) cloud
Using Jenkins CI
Old School way of deploying Java/JSF applications:
1. Build the project to get .war file
2. Upload the .war file to server
Major Problems:
1.Version control isn't inherent.
2.Time consuming, and bandwidth heavy. Requires generating and
uploading bulky war file during every deployment, even when the
change is very small.
3.The WAR will deploy even if the test cases weren't all passing. This
leads to defective application running in production.
The Auto deployment way
1. Commit the change in version control in desired branch.
What problems does it solve?
1.Version controlled. Any branch/version can be deployed anytime.
2.Only difference (changes) get committed to version control repository.
3.Test cases are run automatically during deployment. If test cases fail,
build fails, and the application isn't deployed.
4.Deployment happens automatically on commit (if configured so).
About the Application
Simple JSF (CDI) application created on NetBeans using Maven
archetype weld-jsf-jee.
Tools used for auto-deployment setup
1.Apache Maven http://en.wikipedia.org/wiki/Apache_Maven
2.Git/GitHub (Options: Bitbucket, Assembla, Install gitolite/gitosis)
3.Jenkins CI http://en.wikipedia.org/wiki/Jenkins_(software)
4.Glassfish server
5.Git Bash (For command line interface to Git remote repository)
6.Amazon EC2 Instance (On Ubuntu 12.04 LTS 64 bit)
Three components:
1.Client Machine
2.Git Repository
3.Server Instance
Client Machine: JSF (CDI) project created on NetBeans The project has Junit test cases. Uses Maven Project is git initialized and points to remote github repository. Sample project: https://github.com/james-singh/jsf-maven
Git Repository: The code repository resides here (GitHub in this case). Changes committed from client machine are reflected here. Server Instance polls git repo for changes periodically.
Server Instance on Amazon EC2 IP: http://54.83.62.123 Running Ubuntu 12.04 LTS. Installed applications: Jenkins (Also the plugin: Deploy Plugin), Maven, Git, Jdk1.8, Glassfish If any changes are pushed to Git repository, Jenkins will automatically PULL the changes, BUILD the project, TEST the project, and if successful, DEPLOY the project to Glassfish. It can be made to send emails on BUILD SUCCESS, BUILD FAILURE and successful deployment.
Sequence of Events
ActionChanges are merged and pushed to git.
Internal chain of events●Changes happen in remote git repo on Github●Jenkins PULLs changes using Git●Jenkins BUILDs project using Maven●Jenkins TESTs changes using Maven●Jenkins DEPLOYs project to Glassfish●Jenkins sends out emails
Result●The changes are deployed.●Emails are received notifying about Build/Deployment success/failure.
References:
1. Setting up a JSF Maven project in NetBeans (including working autocompletion for JSP/JSF)http://www.congiu.com/setting-up-a-jsf-maven-project-in-netbeans-including-working-autocompletion-for-jspjsf/
2. NetBeans Maven Best Practices - Installing sectionhttp://wiki.netbeans.org/MavenBestPractices#section-MavenBestPractices-Installing
3. Get running on CDI & JSF 2 in a jiffy using Maven archetypeshttp://planet.jboss.org/post/get_running_on_cdi_jsf_2_in_a_jiffy_using_maven_archetypes
4. Weld maven archetype (weld-jsf-jee) for creating a Java EE 6 application using JSF 2.0, CDI 1.0, EJB 3.1 and JPA 2.0 (persistence unit included)http://mvnrepository.com/artifact/org.jboss.weld.archetypes/weld-jsf-jee/1.0.0-BETA1
5. weld-jsf-jee (Github)https://github.com/indhio/weld/tree/master/weld-jsf-jee
6. Pre-configured, ready to run image for running Jenkins on Amazon EC2https://aws.amazon.com/marketplace/pp/B0085PMZ9Q
7. Glassfish Ubuntu 12.04 Ubber Quick Install Guidehttp://www.silvatechsolutions.com/tech-tips/glassfish-ubuntu-12-04-ubber-quick-install-guide/
Questions?