I am working with an application deployed in maven, in which I need to modify the pom.xml file, to make it use a jar file when the application is deployed.
I have duplicated and modified a piece of code from that file where -javaagent is used, but I must be doing something wrong because it throws an error and, neither activates the jar nor starts tomcat.
As an option, I tried to manually copy the war file into the tomcat webapps directory, but even though tomcat starts and the jar is activated, since the deployed application needs access to a database, it does not work in all cases.
Attached code of the pom.xml file: the first profile (deploywcontrast) is the original and the second is the modified one (deploywfortify). I also attach a screenshot with the error it gives when trying to boot from maven.
<profile>
<id>deploywcontrast</id>
<properties>
<skipTests>true</skipTests>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>ldap-server</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant target="run" antfile="${basedir}/src/config/build.xml">
<reference torefid="maven.compile.classpath" refid="maven.compile.classpath" />
</ant>
</target>
</configuration>
</execution>
<execution>
<id>database-server</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant target="databaseServer" antfile="${basedir}/src/config/build.xml">
<reference torefid="maven.compile.classpath" refid="maven.compile.classpath" />
</ant>
</target>
</configuration>
</execution>
<execution>
<id>database-init</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant target="databaseInit" antfile="${basedir}/src/config/build.xml">
<reference torefid="maven.compile.classpath" refid="maven.compile.classpath" />
</ant>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.9</version>
<configuration>
<container>
<timeout>300000</timeout>
<containerId>tomcat8x</containerId>
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.21/bin/apache-tomcat-8.0.21.zip</url>
</zipUrlInstaller>
</container>
<properties>
<cargo.jvmargs>-XX:MaxPermSize=6G -Xms1G –Xmx8G</cargo.jvmargs>
</properties>
<configuration>
<files>
<copy>
<file>${basedir}/src/config/local/server.xml</file>
<tofile>conf/server.xml</tofile>
<configfile>true</configfile>
<overwrite>true</overwrite>
</copy>
</files>
<properties>
<cargo.jvmargs>
-Xmx4G
-javaagent:${basedir}/tools/Contrast/contrast.jar
-Dcontrast.dir=${basedir}/tools/Contrast/working
-Dcontrast.log.daily=true
-Dcontrast.level=debug
-Dcontrast.noteamserver.enable=true
-Dcontrast.teamserver.suppress=true
</cargo.jvmargs>
<cargo.servlet.port>8443</cargo.servlet.port>
<cargo.protocol>https</cargo.protocol>
<cargo.tomcat.connector.clientAuth>false</cargo.tomcat.connector.clientAuth>
<cargo.tomcat.connector.sslProtocol>TLS</cargo.tomcat.connector.sslProtocol>
<cargo.tomcat.connector.keystoreFile>../../../../.keystore</cargo.tomcat.connector.keystoreFile>
<cargo.tomcat.connector.keystorePass>changeit</cargo.tomcat.connector.keystorePass>
<cargo.tomcat.connector.keyAlias>tomcat</cargo.tomcat.connector.keyAlias>
<cargo.tomcat.httpSecure>true</cargo.tomcat.httpSecure>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deploywfortify</id>
<properties>
<skipTests>true</skipTests>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>ldap-server</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant target="run" antfile="${basedir}/src/config/build.xml">
<reference torefid="maven.compile.classpath" refid="maven.compile.classpath" />
</ant>
</target>
</configuration>
</execution>
<execution>
<id>database-server</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant target="databaseServer" antfile="${basedir}/src/config/build.xml">
<reference torefid="maven.compile.classpath" refid="maven.compile.classpath" />
</ant>
</target>
</configuration>
</execution>
<execution>
<id>database-init</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant target="databaseInit" antfile="${basedir}/src/config/build.xml">
<reference torefid="maven.compile.classpath" refid="maven.compile.classpath" />
</ant>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.9</version>
<configuration>
<container>
<timeout>300000</timeout>
<containerId>tomcat8x</containerId>
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.21/bin/apache-tomcat-8.0.21.zip</url>
</zipUrlInstaller>
</container>
<properties>
<cargo.jvmargs>-XX:MaxPermSize=6G -Xms1G –Xmx8G</cargo.jvmargs>
</properties>
<configuration>
<files>
<copy>
<file>${basedir}/src/config/remote/server.xml</file>
<tofile>conf/server.xml</tofile>
<configfile>true</configfile>
<overwrite>true</overwrite>
</copy>
</files>
<properties>
<cargo.jvmargs>
-Xmx4G
-javaagent:${basedir}/tools/AppDefender/lib.latest/FortifyAgent.jar
-Dfortify.dir=${basedir}/tools/AppDefender/
-Dfortify.log.daily=true
-Dfortify.level=debug
-Dfortify.noteamserver.enable=true
-Dfortify.teamserver.suppress=true
</cargo.jvmargs>
<cargo.servlet.port>8443</cargo.servlet.port>
<cargo.protocol>https</cargo.protocol>
<cargo.tomcat.connector.clientAuth>false</cargo.tomcat.connector.clientAuth>
<cargo.tomcat.connector.sslProtocol>TLS</cargo.tomcat.connector.sslProtocol>
<cargo.tomcat.connector.keystoreFile>../../../../.keystore</cargo.tomcat.connector.keystoreFile>
<cargo.tomcat.connector.keystorePass>changeit</cargo.tomcat.connector.keystorePass>
<cargo.tomcat.connector.keyAlias>tomcat</cargo.tomcat.connector.keyAlias>
<cargo.tomcat.httpSecure>true</cargo.tomcat.httpSecure>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>