Running Tomcat WebApp on OneOps (1)

tomcat

(Disclaimer: the blogs posted here only represent the author’s respective, OneOps project does not guarantee the support or warranty of any code, tutorial, documentation discussed here)

Apache Tomcat is a the most widely used web application server that are powering from small websites to large-scale enterprise networks.If the applications are developed on top of Java technologies (JSP, Servlet), Apache Tomcat is best choice for it.

Today I would like to introduce how to deploy a Tomcat Web Application on OneOps.

First we need to choose a Tomcat web application for demonstration purpose. Without loss of generality, the following war file hosted on a public Nexus server will be chosen: (it is totally fine to choose other war file as long as it is hosted on Nexus and be accessible from your local environment):

https://repository.jboss.org/nexus/content/groups/public/org/jboss/seam/examples-ee6/remoting/helloworld/helloworld-web/2.3.0.Beta2-SNAPSHOT/helloworld-web-2.3.0.Beta2-20120521.053313-26.war

Next on OneOps UI, create a new Tomcat platform in the Design phase:

Screen Shot 2016-07-10 at 2.41.08 PM

After the platform is created, we need to configure a couple of components:

(1) Click the “variables” tab (between “summary” and “diff”) to add the following key-value pairs:

  • groupId: org.jboss.seam.examples-ee6.remoting.helloworld
  • appVersion: 2.3.0.Beta2-20120521.053313-26
  • artifactId: helloworld-web
  • extension: war
  • deployContext: hello

Overall it should resemble as below,

Screen Shot 2016-07-10 at 2.48.06 PM

(2) Add a new artifact component, possibly called artifact-app,  which defines the Tomcat web application. Then input the following information:

  • Repository URL: https://repository.jboss.org
  • Repository Name: pubic
  • Identifier: $OO_LOCAL{groupId}:$OO_LOCAL{artifactId}:$OO_LOCAL{extension}
  • Version: $OO_LOCAL{appVersion}
  • Install Directory: /app/$OO_LOCAL{artifactId}
  • Deploy as user: app
  • Deploy as group: app
  • Restart: execute “rm -fr /app/tomcat7/webapps/$OO_LOCAL{deployContext}”

Screen Shot 2016-07-10 at 3.03.19 PM

As noted, OO_LOCAL{} is typically used for defining artifacts and the variables used in OO_LOCAL{}is defined in “variables” tab (between “summary” and “diff”). For more use cases about OO_LOCAL{}, please refer to http://oneops.github.io/user/references/#variables

 

(3) Update Tomcat component:

  • User: app
  • Group: app

Also it may worth to review the following components if it matters to you: (not required for this demonstration)

  • Max Threads: The max number of active threads in the pool, default is 50
  • Min Spare Threads: The minimum number of threads kept alive, default is 25
  • Java Options: JVM command line option.
  • System Properties: key-value pairs for -D args to JVM
  • Startup Parameters: -XX arguments. For example,

Screen Shot 2016-07-10 at 3.23.12 PM

(4) Create a new user (“Username” is your local login name) and add your local SSH key, so that you could directly ssh into the virtual machines after the deployment.

Save & commit the platform.

Now move the Transition phase and create a new environment. Please note that, (1) Availability Mode should be set to Redundant, (2) choose 1 cloud as Primary cloud for this demonstration.

Save the environment, then “Commit & Deploy”. The deployment plan should show up as follow. In this case, we will deploy 2 web application instances with a load balancer (fqdn) in front.

Screen Shot 2016-07-10 at 3.41.26 PM

After the deployment, we still need to add some (dependent) jar files to the library folder:

/app/helloworld-web/current/WEB-INF/lib/

The additional jar files are:

After the jar files are added, restart all 2 Tomcat instances in order to load the new jar files into the runtime. Go to “Operate” phase, click the platform name of Tomcat, and Tomcat component. Tick all Tomcat instances and click “restart” from the “Action” dropdown list. Please see following,

Screen Shot 2016-07-10 at 3.52.27 PM

To get access to the web application, we only need to know the address of load balancer, which is platform-level FQDN. Go to “Operate” phase, click the platform name of Tomcat, and fqdn component. The shorter address is the platform-level FQDN and we will input the following URL into the web browser:

http://your_platform_fqdn_address/hello

The web application should look like:

Screen Shot 2016-07-11 at 10.37.38 PM

Regarding to the availability, as we deployed 2 instances of web applications, losing 1 instance should not hurt the availability as long as we use address of load balancer to access the application.

What is Next?

This is the first blog to introduce Tomcat and its web application deployment on OneOps. More production-driven features and use cases may be the next topics, for example:

Please stay tuned!

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s