Cargo Cannot deploy to remote tomcat 8 with using cargo-maven-plugin - maven

I am trying to deploy war on tomcat8 using cargo plugin my entry is as follows:
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.8</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>tomcat</cargo.remote.username>
<cargo.remote.password>s3cret</cargo.remote.password>
<cargo.tomcat.manager.url>http://localhost:1234/manager/text</cargo.tomcat.manager.url>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>/auditAPP</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
when i trying to run this using mvn cargo:deploy its giving me the following error
Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.8:deploy (default-cli) on project Audit_Management_DS: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.8:deploy failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [tomcat8x], type = [remote]], configuration type[runtime]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [Help 1]

Update to cargo-plugin version 1.4.13 solved this error message for me.

Related

Docker maven fabric8 plugin (on Windows): building image gives incompatibility issues ?

Via Maven I would like to build a Docker image from a Springboot project.
I run: mvn clean package docker:build
Issue:
ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.21.0:build (default-cli) on project spring-boot-docker: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.21.0:build failed: An API incompatibility was encountered while executing io.
fabric8:docker-maven-plugin:0.21.0:build: java.lang.UnsatisfiedLinkError: unknown
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>io.fabric8:docker-maven-plugin:0.21.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/Johan/.m2/repository/io/fabric8/docker-maven-plugin/0.21.0/docker-maven-plugin-0.21.0.jar
Etc
The maven pom.xml file contains:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<docker.image.prefix>springframeworkguru</docker.image.prefix>
<docker.image.name>springbootdocker</docker.image.name>
<docker.host.url>unix:///var/run/docker.sock</docker.host.url>
</properties>
The build plugin section contains:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.21.0</version>
<configuration>
<dockerHost>${docker.host.url}</dockerHost>
<verbose>true</verbose>
<images>
<image>
<name>${docker.image.prefix}/${docker.image.name}</name>
<build>
<dockerFileDir>${project.basedir}/src/main/docker/</dockerFileDir>
<assembly>
<descriptorRef>artifact</descriptorRef>
</assembly>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
As suggested, I removed my maven repository, which did not help.
Using other dockerHost values (like http://127.0.0.1:2375) did not help.
I really hope you can help!
This is the solution on Windows 7, 8 and 10 Home:
Find the docker machine environment variables. Go to the docker (shell) and type: docker-machine env. The docker host and certification path are important.
Add the following properties to your pom.xml (maven) file:
<docker.host.url>(e.g.) tcp://192.168.99.100:2376</docker.host.url>
<docker.host.certPath>(e.g.) a path</docker.host.certPath>
In your build plugin add just after configuration
<dockerHost>${docker.host.url}</dockerHost>
<certPath>${docker.host.certPath}</certPath>

phantomjs-maven-plugin : error Could not find a suitable constructor

I am trying to run the com.github.klieber.phantomjs-maven-plugin alone before trying to run it with com.github.searls.jasmine-maven-plugin.
The final goal is to be able to run Javascripts tests in maven then in Jenkins.
But I always have the same error :
[ERROR] Failed to execute goal com.github.klieber:phantomjs-maven-plugin:0.7:install (default) on project my-jasmine-project: Execution default of goal com.gith
ub.klieber:phantomjs-maven-plugin:0.7:install failed: Unable to load the mojo 'install' (or one of its required components) from the plugin 'com.github.klieber:
phantomjs-maven-plugin:0.7': com.google.inject.ProvisionException: Guice provision errors:
[ERROR]
[ERROR] 1) Could not find a suitable constructor in com.github.klieber.phantomjs
.mojo.InstallPhantomJsMojo. Classes must have either one (and only one) constructor annotated with #Inject or a zero-argument constructor that is not private.
[ERROR] at com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo.class(Unknown
Source)
[ERROR] while locating com.github.klieber.phantomjs.mojo.InstallPhantomJsMojo
[ERROR] at ClassRealm[plugin>com.github.klieber:phantomjs-maven-plugin:0.7, parent: sun.misc.Launcher$AppClassLoader#f4a24a]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with #com.google.inject.name.Named(value=com.github.klieber:phantomjs-maven-plugin:0.7:install)
[ERROR]
[ERROR] 1 error
[ERROR] role: org.apache.maven.plugin.Mojo
[ERROR] roleHint: com.github.klieber:phantomjs-maven-plugin:0.7:install
I created a maven project with
mvn archetype:generate -DarchetypeGroupId=com.github.searls
-DarchetypeArtifactId=jasmine-archetype
-DarchetypeVersion=RELEASE
-DjasminePluginVersion=2.1
-DgroupId=com.acme
-DartifactId=my-jasmine-project
-Dversion=0.0.1-SNAPSHOT
and here is the pom where I try to only install Phantom JS
<build>
<plugins>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.7</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<version>1.9.7</version>
</configuration>
</plugin>
</plugins>
</build>
Could you tell me what I am doing wrong ?
Thanks in advance,
I think your issue is the same as this one: https://github.com/klieber/phantomjs-maven-plugin/issues/34
Solution: Make sure you are using Maven 3.1 or higher.
I found an other solution for running Javascripts tests in maven then in Jenkins
Below is how I use it in my POM:
<!-- Install phantom JS binaries. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.phantomjs</groupId>
<artifactId>phantomjs</artifactId>
<version>${phantomjs.version}</version>
<type>${phantomjs.packaging}</type>
<classifier>${phantomjs.classifier}</classifier>
<!-- Unpack the artifact in a directory at the same level than
the build directory. -->
<outputDirectory>${project.build.directory}/..</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Depending on the platform I activate different profile so that I download the correct artifact (the one for Windows or the one for Linux on where our Jenkins runs. Hope it helps ! :)
<!-- PhantomJS for Windows -->
<profile>
<id>phantomJS-windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<phantomjs.classifier>windows</phantomjs.classifier>
<phantomjs.bin>phantomjs.exe</phantomjs.bin>
<phantomjs.packaging>zip</phantomjs.packaging>
<test.script.ext>bat</test.script.ext>
</properties>
</profile>
<!-- XXX: Jenkins instance runs on Linux 64 bits. -->
<!-- 64 bits. -->
<profile>
<id>phantomJS-bca-jenkins</id>
<activation>
<property>
<name>sun.arch.data.model</name>
<value>64</value>
</property>
</activation>
<properties>
<phantomjs.classifier>linux-x86_64</phantomjs.classifier>
<phantomjs.bin>bin/phantomjs</phantomjs.bin>
<phantomjs.packaging>tar.bz2</phantomjs.packaging>
<test.script.ext>sh</test.script.ext>
</properties>
</profile>

Cargo:run If you specify a containerId, you also need to specify a containerUrl

I am trying to run tomcat though cargo. Tomcat is already installed. cargo:deploy is working fine but when I try cargo:run I get the following error
If you specify a containerId, you also need to specify a containerUrl.
If I specify a containerURL I get the following error
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-
plugin:1.4.13:run (default-cli) on project ctm: Unable to parse configuration
of mojo org.codehaus.cargo:cargo-maven2-plugin:1.4.13:run for parameter
containerURL: Cannot find 'containerURL' in class org.codehaus.cargo.maven2.configuration.Container
...
This is my Maven config
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.13</version>
<configuration>
<container>
<type>existing</type>
<containerId>${cargo.maven.containerId}</containerId>
<home>${container.home}</home>
</container>
<configuration>
<type>existing</type>
<home>${container.home}</home>
</configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>example</context>
</properties>
</deployable>
</deployables>
</configuration>
<executions>
<execution>
<id>run</id>
<configuration>
<configuration>
<type>existing</type>
</configuration>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
this is my profile
<profile>
<id>developer-properties</id>
<properties>
<cargo.maven.containerId>tomcat7x</cargo.maven.containerId>
<container.home>C:/apache-tomcat-7.0.35</container.home>
</properties>
</profile>
According to cargo documentation; type "existing" should use an existing container installation. I don't think I need containerURL unless the type is "standalone". I don't understand why I'm getting the containerURL error.
Documentation on type is here: https://codehaus-cargo.github.io/cargo/Existing+Local+Configuration.html
I think the documentation is unclear. I think cargo:run always uses a standalone local configuration, hence the description
If the plugin configuration defines a container with a standalone
local configuration, it will create the configuration.
So it's probably ignoring your existing local configuration.

Maven don't execute generate-resources

EDIT
The problem is the generate-resources goal is not executed by Maven in Unix.
With Maven 2.0.10, I execute that instruction : mvn resources:resources
On windows :
[INFO] [dependency:unpack {execution: unpack-filters}]
[INFO] Configured Artifact: com.viaccess.testtools:filters:1.0-SNAPSHOT:jar
[INFO] filters-1.0-SNAPSHOT.jar already unpacked.
On Unix :
[INFO] No goals needed for project - skipping
Strange ... Same maven, same conf.
OLD POST
I have a problem with filtering my maven project.
It works good on windows, but not on unix (redhat).
Though, maven version is the same, java version is the same and settings.xml of maven is the same. So, I don't see where is the problem.
The maven instruction is mvn clean package
On windows, it works good. On windows, it failed with the error Error loading property file '/var/tmp/test/target/filters/empty.properties'
And not target directory is created.
Somebody can help me ?
More information about the pom files.
Here info about the parent pom :
<properties>
<filters.path>${project.build.directory}/filters</filters.path>
<filter.default>empty.properties</filter.default>
</properties>
<profiles>
<profile>
<id>default</id>
<properties>
<filter.defaut>default.properties</filter.defaut>
</properties>
</profile>
<profile>
<id>windows</id>
<properties>
<filter.defaut>default.properties</filter.defaut>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>filters</directory>
<targetPath>${project.build.directory}/filters</targetPath>
</resource>
</resources>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-filters</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.viaccess.testtools</groupId>
<artifactId>filters</artifactId>
<version>1.0-SNAPSHOT</version>
<includes>*.properties</includes>
<outputDirectory>${filters.path}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
The filter project is like that :
<build>
<resources>
<resource>
<directory>src/filters</directory>
<targetPath>${project.build.directory}/classes</targetPath>
<includes>
<include>*.properties</include>
</includes>
</resource>
</resources>
</build>
And the main project is like that.
<parent>
<!-- link to my parent project -->
</parent>
<build>
<filters>
<filter>${filters.path}/${filter.defaut}</filter>
</filters>
Thanks for your help.
I have found the problem. No problem on the pom, a problem of nexus.
On windows, I used the last pom parent beacause it's my work desktop (and I make a pom install).
Unix is a remote server. The downloading of the pom parent was already done, so new version was never uploaded.
Noob problem, sorry ... :)
Thanks for your help.
Eric

How to implement continuous deployment for a web service

I have a Java application, which runs inside web container (Jetty at the moment) and responds to requests via web services.
Now I want to create a mechanism, which allows to deploy (transfer the WAR file to the server, install the new version there) a new version of the application to Amazon EC2 instance as easily as possible (ideally - by running some Maven command).
I'm using Beanstalk for my version control and they offer deployment support, but I couldn't figure out how to apply it to my scenario.
Are there any tutorials on how to deploy web applications to Amazon EC2 with Maven (with or without Beanstalk) ?
Update 1 (10.04.2013): Beanstalk staff has recommended me to use SSH deployments.
Update 2 (11.04.2013 23:17 MSK):
In my first attempt to use Maven Cargo plugin, I added following stuff 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 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's 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 it?
Where can I specify the address my Tomcat container?
Update 3 (12.04.2013 22:36 MSK):
I changed the section related to Cargo plugin like this:
<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 executed 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's 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 (12.04.2013 23:12):
I changed pom.xml once 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 following commands to deploy my application to the server:
mvn clean
mvn install
mvn cargo:deploy
Please note that <packaging> must be set to war in order for this sequence to work (otherwise you may get strange error messages).
You could use the cargo maven plugin to deploy on a remote server. See this example for a remote deployment on a Tomcat server : Maven: How do I deploy my WAR file to a remote Tomcat server?
Please correct me if I'm wrong. I understand that you're using the Tomcat version 7. The Cargo configuration for Tomcat 7 should be as the following: -
<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>
Please note that
<cargo.hostname> is the remote host name or ip address.
<cargo.protocol> is either http or https.
<cargo.servlet.port> is the remote port based on the <cargo.protocol>, e.g. 8080 or 8443
<context> is the context name to use when deploying the web application.
Please refer to Cargo: Tomcat 7.x and Maven2 Plugin Reference Guide for further information.
I hope this may help.
As Charlee and Dmitri answered earlier, the cargo plugin would usually be the easiest way to go.
While doing that, you might also consider the way you actually create your EC2 instances (as in many scenarios, both dev/test ones and production ones) you would like to 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 doing so is provided by Ravello Systems, which basically lets you easily create a full blown replica of an application in the cloud, and they even implemented a maven plugin to help in automating that. Take a look at http://www.ravellosystems.com/blog/ravello_maven_plugin/ - you can tie the whole process together end-to-end with maven - from creating the environment to deploying the application, testing it, and tearing it down.

Resources