maven cargo plugin configuration for Jboss as 7.1.0 - maven

I am trying to configure the maven cargo plugin for deployment on existing jboss 7.1.0 on my local machine. I am able to start the server by
mvn cargo :run command. It is using the jboss-modules.jar to start the server. I want to configure it in such a way that it executes the standalone.bat inside the bin to start the server. I have my datasource configured in standalone.conf.bat and hence I need to execute the standalone.bat to start and deploy the war.. My configuration looks like this..
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.1.2</version>
<configuration>
<wait>true</wait>
<container>
<containerId>jboss7x</containerId>
<home>C:/jboss-as-7.1.0.Final/</home>
</container>
<configuration>
<type>existing</type>
<home>C:/jboss-as-7.1.0.Final/standalone</home>
</configuration>
</configuration>
Is there any property in cargo configuration to set to call the standalone.bat to start the server?
Thanks,

The question is a bit outdated, however with the current release of JBoss Maven plugin it is actually possible to start and stop the application server using mvn jboss-as:start and mvn jboss-as:shutdown commands. I have added a Maven JBoss tutorial time ago describing exactly this.

Related

Hot deployment failure with Maven jetty plugin on Windows

I have configured the Jetty Maven plugin to run my compiled war.
Here is the relevant part of my pom.xml.
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.50.v20221201</version>
<configuration>
<war>${jway.webapps.dir}/myapp.war</war>
<scanIntervalSeconds>2</scanIntervalSeconds>
</configuration>
</plugin>
If I execute mvn jetty:run-war, my war is build and Jetty serves the app as expected.
I have configured scanIntervalSeconds to allow hot redeploy.
However, if I rebuild using mvn install, I get the following error during redeployment:
java.lang.IllegalStateException: Failed to delete temp dir F:\...\myproject\target\tmp
at org.eclipse.jetty.webapp.WebInfConfiguration.configureTempDirectory (WebInfConfiguration.java:532)
at org.eclipse.jetty.webapp.WebInfConfiguration.resolveTempDirectory (WebInfConfiguration.java:424)
at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure (WebInfConfiguration.java:140)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure (WebAppContext.java:488)
at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:523)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:397)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:73)
at org.eclipse.jetty.maven.plugin.JettyRunWarMojo.restartWebApp (JettyRunWarMojo.java:113)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo$1.filesChanged (AbstractJettyMojo.java:472)
at org.eclipse.jetty.util.Scanner.reportBulkChanges (Scanner.java:848)
at org.eclipse.jetty.util.Scanner.reportDifferences (Scanner.java:765)
at org.eclipse.jetty.util.Scanner.scan (Scanner.java:641)
at org.eclipse.jetty.util.Scanner$1.run (Scanner.java:558)
at java.util.TimerThread.mainLoop (Timer.java:555)
at java.util.TimerThread.run (Timer.java:505)
It seems that Jetty wants to delete the file, but Windows locks the file. In the plugin documentation, I have not found any configuration which seems to be helpful. Furthermore I have nothing found on Google. Is there any way to solve this issue?
I don't know if its relevant, but I do not use the jetty:run goal, because my war is build using a third party tool and I do not have a standard directory structure.
The jetty documentation contains a section about Troubleshooting Locked Files on Windows.
So I updated my plugin config according to the documentation:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.50.v20221201</version>
<configuration>
<war>${jway.webapps.dir}/myapp.war</war>
<scanIntervalSeconds>2</scanIntervalSeconds>
<webApp>
<_initParams>
<org.eclipse.jetty.servlet.Default.useFileMappedBuffer>false</org.eclipse.jetty.servlet.Default.useFileMappedBuffer>
</_initParams>
</webApp>
</configuration>
</plugin>

How to automatic deploy spring boot in jenkin and put images to docker

I using jenkins spring boot and docker in my app. I want deploy spring boot in jenkin and put jar when deploy into docker and start it automatic. I reference to here :
https://denisdbell.wordpress.com/2017/08/26/automated-deployment-jenkins-docker-spring-boot/
But i have a problem. It deploy success but don't run jar in docker. When i type docker - ps it show me jar and i must run it manually. I want when jenkin deploy it automatic put images into docker and run it automatic.
I have two question:
- In my project spring boot, i need put docker in root project ?
- How to jenkin deploy and put images to docker and run automatic jar when jenkin deploy
- When i have mutiple modules, how to i specific copy only jar modules i need deploy and copy to docker and run it.
Thanks you so much help me
Question 1:- Yes you need to add it to the root folder.
Question 2:- You have to use the dockerfile-maven-plugin to push/pull images and use the shell commands from Jenkins to run the same.
Add the SCM GIT, Stash, Hg as this
<scm>
<connection>scm:git:ssh://git#guthub.com/yourproject.git</connection>
<developerConnection>scm:git:ssh://git#guthub.com/yourproject.git[push=]scm:git:ssh://git#guthub.com/yourproject.git</developerConnection>
<tag>HEAD</tag>
</scm>
Add the plugin as
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.3</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${docker.image.prefix}/yourproject-${project.artifactId}
</repository>
<tag>${project.version}</tag>
</configuration>
In this while building your jar pass the arguments
mvn clean install -DskiptTests -Ddocker.image.prefix=<your docker repo url>
This command would automatically push the latest project version docker image to the repository.
Use the Shell commands to fetch this image and start the docker from the shell.

mvn clean tomcat:run command

When I run "mvn clean tomcat:run" (without specifying any tomcat version) command from command prompt for running my web application, it download tomcat 6.0.29 version dependency as shown below:
org/apache/tomcat/juli/6.0.29/juli-6.0.29.pom
org/apache/tomcat/annotations-api/6.0.29/annotations-api-6.0.29.pom
org/apache/tomcat/catalina-ha/6.0.29/catalina-ha-6.0.29.pom
org/apache/tomcat/coyote/6.0.29/coyote-6.0.29.pom
org/apache/tomcat/tribes/6.0.29/tribes-6.0.29.pom
org/apache/tomcat/jasper-el/6.0.29/jasper-el-6.0.29.pom
org/apache/tomcat/dbcp/6.0.29/dbcp-6.0.29.pom
pom.xml file of the application does not contain any tomcat version it require to run
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<finalName>esa</finalName>
</build>
So my query is how does it decide to download particular this tomcat version dependency.
Probably the default settings of the tomcat plugin you run.
Try running mvn tomcat:help -Ddetails to see what version of the plugin you use, and how it can be configured.
I think it is an earlier version of the plugin, and you can now use explicit versions, such as
mvn org.apache.tomcat.maven:tomcat6-maven-plugin:2.0:run
mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:run
(or the shorter form)
Seems, you are running the tomcat-maven-plugin from codehaus, whihc has tomcat 6.0.29 built-in. (Seems there was no activity since 2010.)
You should try the tomcat7 plugin from apache.
Regards
Tibor
In command line for maven use --debug option to get explanation of build process. For our case output looks like:
...[DEBUG] Resolving plugin prefix tomcat from [org.apache.maven.plugins, org.codehaus.mojo]
...
[DEBUG] Resolved plugin version for org.codehaus.mojo:tomcat-maven-plugin to 1.1 from repository central (http://repo.maven.apache.org/maven2, releases)...
Actually to explain why we've got tomcat v1.1 without specifying anything about tomcat, remember that maven build process has been customized with build plugins. And each build plugins has own build plugins. So it is enough to examine effective pom file to get clear understanding that almost empty initial pom.xml has quite big effective pom.xml.
To overcome issue just use explicit version of the tomcat plugin.

Remote Deploy to WebSphere 8.5 using maven

I would like to control a remote deployment of a maven generated EAR over to an existing WAS instance not running on the build server.
Ideally, I would like to do this within Maven so that I can remote deploy in say the integration-test phase then proceed to run some JMeters in the verify phase. I guess this is pretty standard.
I have looked around and am unable to find a sensible way to do this in WAS 8.5.
There are a few posts:
Remote Deployment to WAS 6.1
websphere7am-maven-plugin
Cargo
and others around the web, including IBM. None seem to offer a way to achieve a remote deploy to WAS 8.5
Does anybody have a solution?
EDIT 1:
Further confirmation from IBM that no official maven solution exists can be found here:
WAS 8.5 - Using Ant to automate tasks
AFAIK there is no Maven plugin for full-fledged WAS 8.5, only for WAS Liberty Profile. But that one does not support deployment to remote server.
Remote deployment can be done using WsAdmin Ant Task & Maven AntRun Plugin
<plugin>
<groupId>com.orctom.mojo</groupId>
<artifactId>was-maven-plugin</artifactId>e
<version>1.0.8</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<wasHome>${env.WAS_HOME}</wasHome>
<applicationName>${project.build.finalName}</applicationName>
<host>${local or remote address}</host>
<server>server01</server>
<node>node01</node>
<virtualHost>default_host</virtualHost>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
From https://github.com/orctom/was-maven-plugin
Updated on 5/29/2014
Developer of this plugin states on github, "1.0.1 and 1.0.2 is not working, please don't use them!", so I've updated this answer to show version 1.0.3.
Updated on 1/27/2015
Updated to '1.0.8'.
You will soon be able to automatically deploy to WebSphere remotely using Jenkins. You can create a maven project and have Jenkins automatically deploy to WebSphere with the plugin listed below. If you're interested, follow it since I'll be taking feature requests for a limited time.
https://wiki.jenkins-ci.org/display/JENKINS/WebSphere+Deployer+Plugin
Enjoy!
we're using was6-maven-plugin to perform both local and remote deployments to WAS 7. Internally this plugin uses ant tasks from wsadmin so I guess it would also work with WAS 8.5.

maven cargo plugin with tomcat6

I'm trying to setup maven cargo plugin. I have the following requirements:
tomcat 6
custom server.xml
custom context.xml
log4j jar deployed to tomcat lib
install tomcat on the machine if it's not there already
tie to maven's install lifecycle phase to deploy a war and restart the container
make the deployed war be ROOT.war
I've followed the following: http://www.java-tutorial.ch/maven/maven-tomcat-deployment-using-cargo. This isn't the complete feature set I want, and even it doesn't work entirely. This is what I get:
Can't load log handler "4host-manager.org.apache.juli.FileHandler"
[INFO] [talledLocalContainer] java.lang.ClassNotFoundException: 4host-manager.org.apache.juli.FileHandler
And then when mvn install returns I do ps -ef and there's no tomcat process.
Also it copies the war to ROOT.war but the old ROOT/ directory is not replaced so the new ROOT.war doesn't actually get deployed.
For the "install tomcat if not already there" requirement, it seems like this should be absolutely straightforward, yet when I provide
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip</url>
<extractDir>/usr/local</extractDir>
</zipUrlInstaller>
and run mvn cargo:install, it throws this:
org.codehaus.cargo.container.ContainerException: Failed to get container installation home as the container has not yet been installed. Please call install() first.
Which is puzzling. It wants me to call install first, but I AM calling install.
Ideas?
Link you followed has given demo for cargo 1.0.6. Recent version available is 1.1.1 so I suggest you to use recent and there is certain changes in child tags
As described in post http://cargo.codehaus.org/Deploying+to+a+running+container. There are ceratin changes in child tags of ZipUrlInstaller.
<!--
Careful: As described in the ZipUrlInstaller documentation,
Cargo versions older than 1.1.0 accept only installDir, you therefore
need to set installDir instead of downloadDir and extractDir.
-->
Try to use maven archetype to create cargo sample project following post http://cargo.codehaus.org/Maven2+Archetypes. I suggest you to user "Single Webapp Module Archetype"
After setting up maven project, You can install tomcat 6 running mvn cargo:install -P tomcat6x command.
pom.xml snippet of "single webapp module archetype" which can be useful for you.
<profiles>
<profile>
<id>tomcat6x</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<wait>true</wait>
<container>
<containerId>tomcat6x</containerId>
<!-- download zip url -->
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip</url>
<downloadDir>${project.build.directory}/downloads</downloadDir>
<extractDir>${project.build.directory}/extracts</extractDir>
</zipUrlInstaller>
</container>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
where wait parameter true will give you option to check whether server is running or not.

Resources