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> <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> <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> <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 cleanmvn installmvn cargo:deploy
Please note: <packaging> must be set to war in order for this sequence to work (otherwise you may receive strange error messages).