I am using maven-cargo plugin for deployment of a very simple JavaEE application.
And I was able to run and deploy to jboss but the hot deployment of the class files and jsps is not working.
(By hot deployment I mean when I change my Java classes then the changes should be reflected in the application without the server being getting restarted.)
For understanding cargo, I went through their documentation:
https://codehaus-cargo.github.io/cargo/Maven2+plugin.html
and various other So links also :
maven - Failed to execute cargo:start
Maven2: Cargo plugin hot deployment & Jonas support
Deploy web application using Cargo plugin to remote server
But none of posts gives an adequate answer to the questions.
I am using following maven goals which I am using to run and deploy my application :
cargo:deploy
cargo:run
Following the configuration done in pom.xml :
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.7</version>
<configuration>
<container>
<containerId>jboss71x</containerId>
<type>installed</type>
<home>C:\softwares\jboss\jboss-eap</home>
</container>
<configuration>
<type>existing</type>
<home>C:\softwares\jboss\jboss-eap\standalone</home>
</configuration>
<deployer>
<type>installed</type>
</deployer>
<deployables>
<deployable>
<groupId>com.test</groupId>
<artifactId>test-demo</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-controller-client</artifactId>
<version>7.0.2.Final</version>
</dependency>
</dependencies>
</plugin>
Related
I have a project my.group.id:my.art.id which has the following plugin defined:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<type>remote</type>
</container>
<deployables>
<deployable>
<groupId>my.group.id</groupId>
<artifactId>my.art.id</artifactId>
<type>war</type>
<properties>
<context>/my-root</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
</build>
In CLI, I deploy my WAR as following:
mvn cargo:deploy -Dcargo.user=... -Dcargo.password=...
I am now in the situation that I want to deploy my.group.id:my.art.id from another project pom.xml. This project is responsible for integration tests, I am spawning a Dockerized Tomcat container and need to deploy the WAR.
What is the best approach here?
Just copy/paste the plugin code as above
Execute Maven target cargo:deploy -Dcargo.user=... -Dcargo.password=... on my.group.id:my.art.id. Is it possible to call a Maven target from within a Maven build plugin? Will it spawn a child Maven process and wait for execution? Should I use the exec-maven-plugin plugin for this?
The same deployment works correctly on windows, and on linux - but using teamcity and its built in maven I get an error. Local deploys, and the error is :
the container configuration directory
"/BuildAgent/work/68d4a71c8dc5cfd9/target/cargo/configurations/tomcat8x"
does not exist. Please configure the container before attempting to
perform any local deployment.
The relevant section of pom looks like this :
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.8</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<home>${env.CATALINA_HOME}</home>
</container>
<configuration>
<type>existing</type>
<home>${env.CATALINA_HOME}</home>
</configuration>
<deployables>
<deployable>
<groupId>com.myapp</groupId>
<artifactId>ROOT</artifactId>
<type>war</type>
<properties>
<context>${project.build.finalName}</context>
</properties>
</deployable>
</deployables>
<deployer>
<type>installed</type>
</deployer>
</configuration>
</plugin>
Have I missed a section of the pom that is required for ubuntu ? Does teamcity do something different to vanilla maven ? I am using same version of maven in both environments.
Does your deploy work when you perform it on linux machine outside TeamCity?
Is ${env.CATALINA_HOME} defined correctly?
My guess is that ${env.CATALINA_HOME} is pointing to the wrong place
I'm wondering exactly how I would set this up. I have a normal java/tomcat/mysql app, and I want to deploy to EC2. I'd like to use pallet to provision the box, configure it, and deploy my war there. I'm hoping I can do this via a maven plugin?
I guess my other option is to create a lein project and deploy the war using a relative path, but I'm hoping for the maven plugin...
I can't speak to the AWS and Pallet part of your question, but assuming you have a running tomcat instance you can use the Apache Cargo project directly from maven to deploy your app:
Here is a sanitized version of our cargo configuration:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>${tomcat.hostname}</cargo.hostname>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.remote.username>$[tomcat.username}</cargo.remote.username>
<cargo.remote.password>${tomcat.password}</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>com.mycompany</groupId>
<artifactId>MyWebApp</artifactId>
<type>war</type>
<pingURL>http://my.company.com/url</pingURL>
<pingTimeout>80000</pingTimeout>
<properties>
<context>ROOT</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
You can then get this run with this command (set the relevant properties of course):
mvn -DskipTests package cargo:deploy
More information on Using Apache Cargo with Maven is here: http://cargo.codehaus.org/Maven2+Plugin+Getting+Started
I have a multi module project. When I launch mvn site:deploy, the deployment of the base module works fine, but it fails to create the directory of the module sites on the FTP server:
[INFO] Error uploading site
Embedded error: Required directory: '/myremoteftprepository/myproject-mymodule' is missing
When I create the missing directory by hand, it works fine, but I would like to avoid that. It is surprising that the deploy command do not create it. Do you how to force this directory creation? Is it a bug in the wagon-ftp plugin?
FYI, here is my POM:
<build>
<extensions>
<!-- Enabling the use of FTP -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0</version>
</extension>
</extensions>
</build>
I have chosen to include the javadoc with:
<reporting>
<plugins>
<!-- include javadoc in the site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<show>public</show>
</configuration>
</plugin>
</plugins>
</reporting>
and
<distributionManagement>
<site>
<id>site</id>
<name>maven site</name>
<url>ftp://ftp.blabla.org/myremoteftprepository</url>
</site>
</distributionManagement>
and my settings.xml is good.
You should not launch the site:deploy goal, but rather the site-deploy Maven lifecycle phase e.g. like that
mvn clean install site-deploy
and also make sure that the latest version of your wagon transport is used (2.2).
Also for javadoc plugin you should configure it as reporting plugin under the configuration of the maven site plugin.
With the most recent version of wagon-ftp (2.2), it works.
I have just started to use Apache Maven. Now I would like to make Maven to be able to make production and development enviroment deploys with one click. I'm using Eclipse (Springsource version) and I have Maven plugin installed. My server has tomcat and only thing needed for deployment is to overwrite old war with new one and server has SSH access.
Both the Tomcat Maven Plugin and the Maven2 Cargo Plugin support remote Tomcat deployments (assuming the manager application is available).
For the Tomcat Maven Plugin, see the Usage page, the configuration is pretty simple.
For the Maven2 Cargo Plugin, here is a sample configuration (for a remote container):
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.1-sr-1</version>
<configuration>
<wait>true</wait>
<container>
<containerId>tomcat6x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.tomcat.manager.url>[https://yourhost/manager]</cargo.tomcat.manager.url>
<cargo.remote.username>[username]</cargo.remote.username>
<cargo.remote.password>[password]</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>[war group id]</groupId>
<artifactId>[war artifact id]</artifactId>
<type>war</type>
<properties>
<context>[optional root context]</context>
</properties>
<pingURL>[optional url to ping to know if deployable is done or not]</pingURL>
<pingTimeout>[optional timeout to ping (default 20000 milliseconds)]</pingTimeout>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
</plugins>
</build>
And type mvn cargo:deploy.
Cargo is more powerful (because container agnostic) but also more complicated. For simple needs, I find that the Maven Tomcat Plugin is, well, simpler.
Try the Maven Cargo Plugin. This handles various versions of Tomcat, among other app servers. It can start and stop the server before/after deploying. It should also be able to deploy remotely, although I can't testify it with Tomcat.
If what you need is a file replacement over SSH, I would recommend antrun plugin for the task.
For other deployments, take a look at the great cargo plugin.