How to deploy a war in an specific path jboss as 7.4 using jenkins and jboss-as? - maven

im trying to deploy a war file to jboss-AS 7.4, but when i run the deploy, the plugin deploy the war file genetated by the plugin,what i need is that the plugin deploys a war file in a specific directory of my system, this is my pom.
<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>
<groupId>ss</groupId>
<artifactId>ss</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>ss</name>
<description>uses the pom to deploy to Jboss AS 7 with jenkins</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.7</java.version>
<hostName>localhost</hostName>
<jbossUser>user</jbossUser>
<jbossPass>admin</jbossPass>
<warName>ss</warName>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
<configuration>
<force>true</force>
<hostname>${hostName}</hostname>
<username>${jbossUser}</username>
<password>${jbossPass}</password>
<port>10000</port>
<fileNames>
<fileName>${warName}.war</fileName>
</fileNames>
<name>ss.war</name>
</configuration>
</plugin>
</plugins>
</build>
assuming that the war file is in the same directory as the pom, how can i make this work?
Thanks for your answers.

Reading the plugin documentation, it looks like you have to set the targetDir to the target directory where you want your application to be deployed link
Default: ${project.build.directory}/
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
<configuration>
<force>true</force>
<hostname>${hostName}</hostname>
<username>${jbossUser}</username>
<password>${jbossPass}</password>
<port>10000</port>
<fileNames>
<fileName>${warName}.war</fileName>
</fileNames>
<name>ss.war</name>
<targetDir>src/custom/path/</targetDir>
</configuration>
</plugin>
hope it helps

Well i found a solution and apparently the problem be really small, the problem was that i was using a different property inside the configuration tags, this is the pom that worked for me:
<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>
<groupId>cc</groupId>
<artifactId>cc</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>cc</name>
<description>uses the pom to deploy to Jboss AS 7 with jenkins</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.7</java.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
<configuration>
<hostname>localhost</hostname>
<username>user</username>
<password>pass</password>
<port>10000</port>
<filename>mywar.war</filename>
</configuration>
</plugin>
</plugins>
</build>
the change made is that I delete the tags fileNames and fileName and add the property filename, here you can specify the path to the war file to be deployed in the server ignoring the generated war in the target directory.
Thanks to all.

Related

Error running stand-alone jar with ojdbc jar dependency

I have the following pom:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>org.example</groupId>
<artifactId>do_can_proj</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11-production</artifactId>
<version>21.1.0.0</version>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.do.can.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Running,
$ mvn clean package assembly:single
generates a jar in the target folder.
When I run the jar file from the command line:
java -jar target/do_can_proj-1.0-SNAPSHOT-jar-with-dependencies.jar
I get the following error:
SQL State: 08001
No suitable driver found for jdbc:oracle:thin:#hostname:1521:SID
And this is how I have my project setup:
When running with the -jar argument, the classpath is set to the entry in the manifest in the jar file. By default this is empty. It can be argued that the assembly target should be improved to allow this.
It needs to be set to include all libraries used by your code for this to work and the libraries needs to be added from the Maven repository. How exactly to do this depends on your needs. See How can I create an executable JAR with dependencies using Maven? for suggestions.

Spring 2.2.1 Build error Could not find artifact com.fasterxml.jackson:jackson-bom:pom:2.10.5

I am new with Spring boot framework and I added spring-boot-starter-parent
am added spring-boot-starter-parent in my parent pom
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/>
</parent>
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>
<parent>
<groupId>Parent</groupId>
<artifactId>Parent</artifactId>
<version>7.0.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>Child</artifactId>
<packaging>pom</packaging>
<version>7.0.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.compiler.version>1.8</java.compiler.version>
<maven-jar-plugin.version>2.6</maven-jar-plugin.version>
<maven-surefire-plugin>2.19.1</maven-surefire-plugin>
<maven-assembly-plugin.version>2.5.5</maven-assembly-plugin.version>
<spring.version>4.1.7.RELEASE</spring.version>
<junit.version>4.11</junit.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version>
<maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
<tomcat.version>8.5.12</tomcat.version>
<tomcat.8.0.version>8.0.50</tomcat.8.0.version>
<log4j.version>1.2.16</log4j.version>
<httpclient.version>4.5.3</httpclient.version>
<jackson.version>2.9.5</jackson.version>
<powermock.version>1.7.4</powermock.version>
<junit.version>4.11</junit.version>
<mockito.version>1.10.16</mockito.version>
<slf4j.version>1.7.5</slf4j.version>
<consul.version>0.14.0</consul.version>
<json.version>20080701</json.version>
<dom4j.version>1.6.1</dom4j.version>
<implementation.version>7.0.0.0</implementation.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${java.compiler.version}</source>
<target>${java.compiler.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifestEntries>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin}</version>
<configuration>
<argLine>-Xmx512m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
</plugins>
</build>
<modules>
</modules>
</project>
Now it's showing an error in pom.xml.
Project build error: Non-resolvable import POM: Could not find artifact com.fasterxml.jackson:jackson-bom:pom:2.10.5 in central (https://repo.maven.apache.org/maven2)
I tried following solutions
Update my maven project
remove and rebuild the .m2 folder
Please give suggestion on the above query.
The jackson-bom version that maven is trying to resolve is not in the maven repository.When i checked the latest version is version 2.10.1 . So, could you check if in your pom.xml anywhere you are explicitly setting the jackson version ? . If you try removing that and let maven resolve the version from spring.

Spring boot maven plugin not packaging java classes in Openshift environment

I have a multi-module maven project whose one of these modules uses Spring Boot.
When I package my jar in my PC it works fine and all java classes are included in the jar, but when I do this in an Openshift environment, only the web resources are included, not the java classes.
I have an Openshift DIY cartridge in which, using action hooks I setup the environment, package my jar and run it.
This procedure worked fine until I made some recent changes, which were to divide my maven project into modules.
parent pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>XXXX</groupId>
<artifactId>XXXX</artifactId>
<version>XXXX</version>
<packaging>pom</packaging>
<modules>
<module>data</module>
<module>web</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.compiler.plugin.version>3.5</maven.compiler.plugin.version>
<maven.jar.plugin.version>3.0.2</maven.jar.plugin.version>
<maven.clean.plugin.version>2.5</maven.clean.plugin.version>
<maven.spring-boot-maven-plugin.version>1.3.3.RELEASE</maven.spring-boot-maven-plugin.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven.clean.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${maven.spring-boot-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
...
</dependencies>
</dependencyManagement>
<dependencies>
....
</dependencies>
web module pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>XXXX</groupId>
<artifactId>XXXX</artifactId>
<version>1.2.3</version>
</parent>
<artifactId>XXXX</artifactId>
<packaging>jar</packaging>
<properties>
...
</properties>
<build>
<finalName>${project.name}-${project.version}</finalName>
<resources>
<resource>
<directory>${project.resources.path}</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>deployments</directory>
<includes>
<include>*.jar</include>
<followSymlinks>false</followSymlinks>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>XXXX</mainClass>
<finalName>XXXX</finalName>
<outputDirectory>../deployments</outputDirectory>
<excludeGroupIds>org.seleniumhq.selenium,org.projectlombok</excludeGroupIds>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
....
</dependencies>
data module pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>XXXX</groupId>
<artifactId>XXXX</artifactId>
<version>1.2.3</version>
</parent>
<artifactId>XXXX</artifactId>
<packaging>jar</packaging>
<properties>
....
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
....
</dependencies>
Maven command I use to package the jar (executed in Openshift cartridge)
${OPENSHIFT_DATA_DIR}${MVN_LINK}/bin/mvn clean install -s
.openshift/action_hooks/settings.xml -DskipTests=true -P prod
mvn -v command in my Openshift box
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11- 10T11:41:47-05:00)
Maven home: /var/lib/openshift/5713d8630c1e66bfc5000085/app- root/data/maven
Java version: 1.8.0_101, vendor: Oracle Corporation
Java home: /var/lib/openshift/5713d8630c1e66bfc5000085/app- root/data/jdk1.8.0_101/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-573.26.1.el6.x86_64", arch: "i386", family: "unix"
The resulting jar contains all the libs, .properties files, web resources etc. but no sign of the java classes...
What am I missing? why are not the java classes being packaged too?
Many thanks
CASE CLOSED
I found the issue. I gitignored the src folder of the web module by mistake, therefore nothing was being committed to the git repository of the Openshift cartridge, hence it wasn't packaging any java files in the jar, because there were none! Shame on me! ;-)

How to use maven-install-plugin to install-file for module

With this projects structure I cannot install the sqljdbc4.jar to my local maven repository.
This is LiferayBuild/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>
<groupId>...</groupId>
<artifactId>LiferayBuild</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>LiferayBuild</name>
<description>Liferay Aggregator Project (build modules)</description>
<properties>
...
</properties>
<modules>
...
<module>../Liferay</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
<file>${basedir}/lib/sqljdbc4-4.0.jar</file>
<packaging>jar</packaging>
<generatePom>false</generatePom>
<pomFile>../Liferay/pom.xml</pomFile>
</configuration>
<executions>
<execution>
<id>inst_sql</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>install</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And this is Liferay/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>
<groupId>...</groupId>
<artifactId>Liferay</artifactId>
<version>1.2.1</version>
<name>Liferay</name>
<description>Liferay Connector</description>
<properties>
...
</properties>
<dependencies>
...
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
...
</dependencies>
<!-- Build Settings -->
<build>
<resources>
...
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
...
</plugins>
</build>
<pluginRepositories>
...
</pluginRepositories>
<profiles>
<profile>
...
</profile>
</profiles>
When I Run as... Maven install, I get a BUILD FAILURE
[ERROR] Failed to execute goal on project Liferay: Could not resolve dependencies for project com.realsoft:Liferay:jar:1.2.1: Failure to find com.microsoft.sqlserver:sqljdbc4:jar:4.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
What can I do to get the jar installed to my local repository? I have already tried the suggestions from http://blog.valdaris.com/post/custom-jar/ but with no outcome. Please help!
Thanks, I have used
<phase>clean</phase>
and moved the lib folder to my basedir of my multi-module project.

Jenkins package project out of his workspace

I tried to build maven war projects with Jenkins.
Jenkins pulls the code and builds the project. However, the build is not in the workspace, but rather in a folder with the project source. I think Jenkins takes the target folder from maven pom file and builds it.
How can I tune Jenkins to make a build and deploy pipeline?
In the deploy phase Jenkins cannot find war file.
OS is windows, IDE - eclipse.
<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>
<groupId>my.test.webapp</groupId>
<artifactId>webApp</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>webApp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>8.0.5</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<directory>${basedir}\target</directory> <!-- tried with this line and without -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
The way I coped with a problem:
In pom.xml:
<properties>
<baseFolder>${basedir}</baseFolder>
</properties>
<build>
<directory>${baseFolder}/target</directory>
</directory>
In Jenkins run build maven build with properties
baseFolder=$WORKSPACE

Resources