How to implement continuous deployment for a web service

I have a Java application that runs inside a web container (Jetty at the moment) and responds to requests through web services.

Now I want to create a mechanism that makes it possible to deploy (transfer the WAR file to the server, install the new version there) the new version of the application in an instance of Amazon EC2 (ideally, by running some Maven).

I use Beanstalk for my version control and they offer deployment support, but I could not figure out how to apply it to my scenario.

Are there any guides for deploying web applications on Amazon EC2 with Maven (with or without Beanstalk)?

Update 1 (04/10/2013): Beanstalk employees recommended that I use SSH deployment .

Update 2 (04/11/2013 23:17 MSK):

In my first attempt to use the Maven Cargo plugin, I added the following things to my pom.xml :

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> [...] <build> [...] <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <configuration> <container> <containerId>Heaven7</containerId> <type>remote</type> </container> <configuration> <type>runtime</type> <properties> <cargo.remote.username>myusername</cargo.remote.username> <cargo.remote.password>mypassword</cargo.remote.password> </properties> </configuration> <!-- Deployer configuration --> <deployer> <type>remote</type> </deployer> <deployables> <deployable> <groupId>ru.mycompany</groupId> <artifactId>my-product</artifactId> <type>war</type> </deployable> </deployables> </configuration> </plugin> </plugins> </build> [...] </project> 

Then I ran mvn cargo:deploy and got the following output:

 [ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.3.3:dep oy (default-cli) on project [...]: Execution default-cli of goal org.codeh us.cargo:cargo-maven2-plugin:1.3.3:deploy failed: Cannot create configuration. here no registered configuration for the parameters (container [id = [Heaven7 , type = [remote]], configuration type [runtime]). Actually there are no valid ypes registered for this configuration. Maybe you've made a mistake spelling it 

2 questions:

  • How can i fix this?
  • Where can I provide the address of my Tomcat container?

Update 3 (04/12/2013 10:36 p.m. MSK):

I changed the section related to the Cargo plugin as follows:

  <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.3.3</version> <configuration> <container> <containerId>tomcat7</containerId> <type>remote</type> </container> <configuration> <type>runtime</type> <properties> <cargo.remote.username>myuser</cargo.remote.username> <cargo.remote.password>mypassword</cargo.remote.password> <cargo.hostname>ec2-NN-NNN-NN-NN.compute-1.amazonaws.com</cargo.hostname> <cargo.protocol>http</cargo.protocol> <cargo.servlet.port>8080</cargo.servlet.port> </properties> </configuration> <!-- Deployer configuration --> <deployer> <type>remote</type> </deployer> <deployables> <deployable> <groupId>ru.mycompany</groupId> <artifactId>myproduct</artifactId> <type>war</type> </deployable> </deployables> </configuration> </plugin> </plugins> 

Then I mvn cargo:deploy and got this output:

 [ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.3.3:depl oyer-deploy (default-cli) on project ccp-server: Execution default-cli of goal o rg.codehaus.cargo:cargo-maven2-plugin:1.3.3:deployer-deploy failed: Cannot creat e configuration. There no registered configuration for the parameters (contain er [id = [tomcat7], type = [remote]], configuration type [runtime]). Actually th ere are no valid types registered for this configuration. Maybe you've made a mi stake spelling it? -> [Help 1] 

Update 4 (04/12/2013 23:12):

I changed pom.xml again to:

 <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.3.3</version> <configuration> <container> <containerId>tomcat7x</containerId> <type>remote</type> </container> <configuration> <type>runtime</type> <properties> <cargo.remote.username>myuser</cargo.remote.username> <cargo.remote.password>mypassword</cargo.remote.password> <cargo.hostname>ec2-NN-NNN-NN-NN.compute-1.amazonaws.com</cargo.hostname> <cargo.protocol>http</cargo.protocol> <cargo.servlet.port>8080</cargo.servlet.port> </properties> </configuration> <!-- Deployer configuration --> <deployer> <type>remote</type> </deployer> <deployables> <deployable> <groupId>ru.mycompany</groupId> <artifactId>myproduct</artifactId> <type>war</type> </deployable> </deployables> </configuration> </plugin> 

Then I used the following commands to deploy my application to the server:

  • mvn clean
  • mvn install
  • mvn cargo:deploy

Please note: <packaging> must be set to war in order for this sequence to work (otherwise you may receive strange error messages).

+5
source share
3 answers

Please correct me if I am wrong. I understand that you are using Tomcat version 7 . Cargo configuration for Tomcat 7 should be as follows: -

 <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>1.3.3</version> <configuration> <container> <containerId>tomcat7x</containerId> <type>remote</type> </container> <configuration> <type>runtime</type> <properties> <cargo.remote.username>myusername</cargo.remote.username> <cargo.remote.password>mypassword</cargo.remote.password> <cargo.hostname>MY_HOST</cargo.hostname> <cargo.protocol>http</cargo.protocol> <cargo.servlet.port>SERVER_PORT</cargo.servlet.port> </properties> </configuration> <!-- Deployer configuration --> <deployer> <type>remote</type> <deployables> <deployable> <groupId>ru.mycompany</groupId> <artifactId>my-product</artifactId> <type>war</type> <properties> <context>MY_CONTEXT</context> </properties> </deployable> </deployables> </deployer> </configuration> </plugin> 

note that

  • <cargo.hostname> - remote host name or IP address.
  • <cargo.protocol> - either http or https .
  • <cargo.servlet.port> is a remote port based on <cargo.protocol> , for example. 8080 or 8443
  • <context> is the context name to use when deploying the web application.

Refer to Cargo: Tomcat 7.x and the Maven2 Guide link for more information.

Hope this helps.

+1
source

You can use the load maven plugin to deploy to a remote server. See this example for remote deployment on a Tomcat server: Maven: How to deploy my WAR file on a remote Tomcat server?

+2
source

As Charlie and Dmitry previously reported, a cargo plug-in would usually be the easiest way. At the same time, you can also consider the method of creating EC2 instances (as in many scenarios, both dev / test and production), you should always create fresh instances (see Martin Fowler's thoughts on this at http://martinfowler.com/ bliki / PhoenixServer.html and http://martinfowler.com/bliki/SnowflakeServer.html .

An interesting solution for this is Ravello Systems, which basically allows you to easily create a full-blown copy of the application in the cloud, and they even implemented the maven plugin to help automate it. Take a look at http://www.ravellosystems.com/blog/ravello_maven_plugin/ - you can link the whole process together using maven - from creating an environment for deploying the application, testing it and breaking it off.

0
source

All Articles