Deploy war in Glassfish 5 Docker Image - maven

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]

Related

target does not exist when use docker-maven-plugin to build docker image

when i use docker-maven-plugin to build docker image , it fails
ERROR:Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project spring-boot-basic: Exception caught: basedir /root/workSpace/spring-boot-basic/spring-boot-basic-web/target does not exist
this is some code of pom.xml
<!-- docker plugin -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<!-- docker config -->
<configuration>
<!-- image name -->
<imageName>${project.build.finalName}</imageName>
<!-- image tag -->
<imageTags>
<imageTag>${project.version}</imageTag>
</imageTags>
<dockerDirectory>${project.basedir}</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.basedir}/${jar.real.path}/target</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
this is my project structure
spring-boot-basic
Dockerfile
module----spring-boot-basic-web
src/main--------MainApp.java
pom.xml
target will build in spring-boot-basic-web(module)
but when i run the 'mvn clean package' , it builds success and generates the target folder
then i run 'mvn clean package docker:build' , it builds docker image success but the error still happened
How can i do to solve the error ?
now i know why cause the problem that i config the maven docker plugin in the parent pom which package type is 'pom' not 'jar' so when i build the project the problem occurs.
so i put the maven docker config in the module 'spring-boot-basic-web' and then build success.

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>

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

Deploy to $CATALINA_HOME using maven cargo plugin

I use cargo-maven2-plugin to deploy war files to a running remote tomcat container. Now I need to copy files to $CATALINA_HOME/myfolder. I do this using ant-run/scp/ssh.
But is it possible to do this with the cargo-maven2-plugin or does it only operate on the application/webapps level?
Try cargo with installed deployer and existing configuration
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.5</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<home>${env.CATALINA_HOME}</home>
</container>
<configuration>
<type>existing</type>
<home>${env.CATALINA_HOME}</home>
</configuration>
<deployer>
<type>installed</type>
</deployer>
</configuration>
</plugin>
My sample project works this way
$ mvn cargo:deploy
[INFO] --- cargo-maven2-plugin:1.4.5:deploy (default-cli) # sample-war ---
[INFO] [edDeployerDeployMojo] Resolved container artifact org.codehaus.cargo:cargo-core-container-tomcat:jar:1.4.5 for container tomcat7x
[INFO] [stalledLocalDeployer] Deploying [/home/mariuszs/git/sample-war/target/sample.war] to [/opt/tomcat/webapps]...
You can check full sample project for this https://github.com/mariuszs/cargo-existing-installed-sample
Some links than can help:
Local container
Existing Local Configuration

Deploying with Maven Tomcat plugin failes

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.

Resources