Deploying with Maven Tomcat plugin failes - maven

I'm trying to deploy application using tomcat7-maven-plugin with this configuration
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://127.0.0.1:8080/manager/text</url>
<server>TomcatServer</server>
<path>/Ohta</path>
<username>tomcat</username>
<port>8080</port>
<password>s3cret</password>
</configuration>
</plugin>
I get the folowing error
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project ohta: Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1]
As I understand maven tries to use org.codehaus.mojo:tomcat-maven-plugin instead of specified and can't find configuration, but why it is so?

This link contains a good tutorial about Maven Tomcat plugin. Might be useful to see the whole process from archetype creation to deployment using the plugin.

Related

Deploy war in Glassfish 5 Docker Image

I am trying to deploy a war in a docker container based on the oracle/glassfish:5.0 image.
I am able to deploy the war through the Glassfish Administration Console and manually uploading the war file.
Nevertheless, I would like to deploy the war with maven using the cargo plugin.
The versions I am using are:
javac 9.0.1
Apache Maven 3.3.9
Maven cargo plugin 1.6.6
Docker image oracle/glassfish:5.0
The container has been built as:
docker run -ti -e ADMIN_PASSWORD=password -p 4848:4848 -p 8080:8080 -d oracle/glassfish:5.0
The configuration I have setup in the pom.xml is:
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>glassfish5x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.runtime.args>force=true</cargo.runtime.args>
<cargo.hostname>127.0.0.1</cargo.hostname>
<cargo.glassfish.admin.port>4848</cargo.glassfish.admin.port>
<cargo.glassfish.domain.name>domain1</cargo.glassfish.domain.name>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>password</cargo.remote.password>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
The error displayed is:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-
plugin:1.6.6:deploy (default-cli) on project hello1:
Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.6.6:deploy failed:
Deployment has failed: Action failed Deploying application to target server failed;
File not found : /var/folders/b0/kd4wyk3s1rnfs_rvvbc_m2400000gn/T/cargo/19525/hello1.war -> [Help 1]

Jetty 6 Maven Plugin fails to start on Intellij

I'm moving from Eclipse to Intellij, and switching from Tomcat to Jetty in the dev environment.
My Tomcat plugin works fine, but when I start Jetty it outputs the following error:
Failed to execute goal org.mortbay.jetty:maven-jetty-plugin:6.1.2:run (default-cli) on project projeto: Webapp source directory C:\Users\EvCash - Blue\workspace\projeto\src\main\webapp does not exist -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.mortbay.jetty:maven-jetty-plugin:6.1.2:run (default-cli) on project projeto: Webapp source directory C:\Users\EvCash - Blue\workspace\projeto\src\main\webapp does not exist
Here is my pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.2</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
</connector>
</connectors>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
...
</plugins>
</build>
And the run configuration:
jetty:run -e
I tried using the jetty-runner plugin, but it requires JDK 1.8 and I must use the 1.7 version.
Any ideas? Thanks in advance

Cannot push to remote repo using the (spotify) Docker maven plugin

I've got a Spring Boot project which I want to built an image from and push to a Docker private registry. I've followed Spring Boot official docs for that, using the Spotify Docker Maven plugin. That worked well when publishing my image to a docker local instance using Boot2Docker.
Now I'm trying to do the same with a remote private repo (an unsecured one) and I'm struggling with it. I've followed the plugin documentation for that and that's how my configuration looks like:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.9</version>
<configuration>
<imageName>service-discovery</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.war</include>
</resource>
</resources>
</configuration>
<executions>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>tag-image</id>
<phase>package</phase>
<goals>
<goal>tag</goal>
</goals>
<configuration>
<image>service-discovery</image>
<newName>develop01.mycompany.com:5000/service-discovery</newName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
My registry is accessible through http://develop01.mycompany.com:5000, but the docker plugin seems not to be able to find it.
Executing mvn clean install throws:
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.9:build (buil
d-image) on project service-discovery: Exception caught: java.util.concurrent.Ex
ecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingExcepti
on: org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375 [lo
calhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connec
t -> [Help 1]
Executing mvn docker:tag -DpushImage throws:
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.9:tag (defaul
t-cli) on project service-discovery: The parameters 'image', 'newName' for goal
com.spotify:docker-maven-plugin:0.4.9:tag are missing or invalid -> [Help 1]
So the plugin seems not to recognize the parameters into the image goal (in fact, it looks like it's trying to connect to a local Docker instance when executing mvn clean install).
Software:
docker version: Server: 1.11.0
docker-maven-plugin version: 0.4.9
maven version: 3.2.3
A link to the GitHub issue I created
Update
I have set my DOCKER_HOST environment variable to tcp://develop01.mycompany.com:5000 and now the plugin seems to pick it. Still don't understand why I have to do it through an environment variable, when I'm declaring the server name in the execution configuration. All in all, that's the error I'm getting right now:
[ERROR] Failed to execute goal
com.spotify:docker-maven-plugin:0.4.9:build (buil d-image) on project
service-discovery: Exception caught: Request error: GET http
://develop01.mycompany.com:5000/version: 404: HTTP 404 Not Found ->
[Help 1]
In fact, the /version endpoint of my registry returns 404. The /v2 endpoint however, returns an empty JSON. Is the plugin trying to deal with a previous docker version API?

How to check failed module during deployment - Maven multi module

I am deploying application to Jboss AS 7.1.1.Final using Maven multi module configuration. The 'jboss-as-maven-plugin' plugin with version 7.4.Final is used to deploy to AS using remote deployment. I have a parent POM with multiple modules as shown below.
<modules>
<module>ProjectA</module>
<module>ProjectB</module>
<module>ProjectC</module>
<module>ProjectD</module>
</modules>
Configuration in master POM
<plugins>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
<configuration>
<skip>true</skip>
<filename>${project.build.finalName}.${project.packaging}</filename>
<username>${userName}</username>
<password>${password}</password>
</configuration>
</plugin>
</plugins>
Configuration in each module's POM
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
<configuration>
<filename>${project.build.finalName}.jar</filename>
<username>${userName}</username>
<password>${password}</password>
</configuration>
</plugin>
There has been deployment errors related to connection timeout to Jboss server that can occure while deploying any of the module configured. I am planning on writting script to check when a specific module failed from multi module configuration, will try to redeploy failed module. For this to happen I would need to know which of these module failed during deployment. Is it possible to know while running maven as following command?
mvn clean package install jboss-as:deploy -DskipTests
-DuserName=username -Dpassword=password -Ddeploy.host=10.10.10.10 -Ddeploy.port=9999

Tomcat7 Maven Plugin appears to not be picking up url in configuration [duplicate]

This is my pom.xml build configuration:
<build>
<finalName>cfwd</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://xx.xxx.xxx.xxx:8080/manager/text</url>
<server>cifServer</server>
<path>/cfwd</path>
<addContextWarDependencies>true</addContextWarDependencies>
<addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
where http://xx.xxx.xxx.xxx:8080 is the remote server IP.
When I try to deploy via mvn tomcat:deploy I get this error:
[ERROR] Failed to execute goal
org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on
project cfwd: Cannot invoke Tomcat manager: Server returned HTTP
response code: 403 for URL:
http://localhost:8080/manager/deploy?path=%2Fcfwd&war= -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy
(default-cli) on project cfwd: Cannot invoke Tomcat manager
where it looks like maven is attempting to deploy to localhost:8080 rather than the remote server IP. Any idea?
You need to execute mvn tomcat7:deploy (note the '7') in order to trigger the plugin you've configured.
See this page for more information about the available goals.
403 means Forbidden.
Check with the official documentation in order to configure authentication to the Tomcat manager (parameters Server, password, username).
Duncan Jones is right : you are not executing the correct plugin : use tomcat7.

Resources