Apache CXF failed by generating of Client webservice after adding cxf-rt-transports-http dependency - maven

I am trying to generate a JAVA based Webservice client from an existing WSDL with it's related XSD files using Apache CXF. To do this i use a maven configuration file listed below which basicall works well.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testcamera</groupId>
<artifactId>TestCamera</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>TestCamera Maven App</name>
<properties>
<java.version>1.8</java.version>
<tomcat.version>9.0.4</tomcat.version>
<cxf.version>3.2.2</cxf.version>
</properties>
<build>
<!-- <finalName>???</finalName> -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<!-- encoding>UTF-8</encoding -->
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdls/ver10/device/wsdl/devicemgmt.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
</resource>
<resource>
<filtering>false</filtering>
<directory>src/main/java</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<filtering>false</filtering>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<filtering>false</filtering>
<directory>src/test/java</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.apache.cxf</groupId> -->
<!-- <artifactId>cxf-rt-transports-http</artifactId> -->
<!-- <version>${cxf.version}</version> -->
<!-- </dependency> -->
<!-- Jetty is needed if you're are not using the CXFServlet -->
<!-- <dependency> -->
<!-- <groupId>org.apache.cxf</groupId> -->
<!-- <artifactId>cxf-rt-transports-http-jetty</artifactId> -->
<!-- <version>${cxf.version}</version> -->
<!-- </dependency> -->
</dependencies>
</project>
The problem is that i need to add proxy support to this web service. That is why i need to add following dependencies to my maven dependencies which cause problem and show me an error.
Here the related POM.xml:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
And related Error Message after aftivation of cxf-rt-transports-http
Caused by: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/xs:schema/xs:schema): faultCode=PARSER_ERROR: Problem parsing 'http://www.w3.org/2003/05/soap-envelope'.: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument (WSDLReaderImpl.java:2198)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema (WSDLReaderImpl.java:830)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema (WSDLReaderImpl.java:864)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema (WSDLReaderImpl.java:654)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes (WSDLReaderImpl.java:610)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions (WSDLReaderImpl.java:320)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL (WSDLReaderImpl.java:2352)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL (WSDLReaderImpl.java:2338)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition (WSDLManagerImpl.java:255)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition (WSDLManagerImpl.java:165)
at org.apache.cxf.tools.wsdlto.core.WSDLDefinitionBuilder.parseWSDL (WSDLDefinitionBuilder.java:80)
at org.apache.cxf.tools.wsdlto.core.WSDLDefinitionBuilder.build (WSDLDefinitionBuilder.java:71)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build (JAXWSDefinitionBuilder.java:83)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build (JAXWSDefinitionBuilder.java:60)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl (WSDLToJavaContainer.java:195)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute (WSDLToJavaContainer.java:164)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute (WSDLToJavaContainer.java:412)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool (ToolRunner.java:105)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run (WSDLToJava.java:113)
It will be great if someone know why that behavior happens!
The related WSDL is available under following url:
https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl
Note: To see content of wsdl you need right click on that page and see source code!
Thanks in advance!
kami

Related

Renaming jar of the same Maven project before bundling it into its war file

We've a Maven project that has war packaging. It has a couple of other projects as dependencies. The requirement here is that all projects added as dependencies should have a common naming convention such that they can be patched in every release. So we decided to replace the version from all such artifacts by -1.0-SNAPSHOT. The below code does it well for artifacts added as dependencies.
We want the classes of this project itself to be included as a jar file. So we set archiveClasses to true. Now the problem here is that the jar generated out of this has the version appended to it - ns-commonservices-6.5.x and maven-dependency-plugin is unable to rename it to ns-commonservices-1.0-SNAPSHOT (Hence, I've removed that code).
Is there any way by which we can rename the jar/artifact of the same project before bundling it into its own war?
Kindly refer the screenshot below. In this we want ns-commonservices-6.5.x.jar to named as ns-commonservices-1.0-SNAPSHOT.jar.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ns.commonservices</groupId>
<artifactId>ns-commonservices</artifactId>
<packaging>war</packaging>
<version>6.5.x</version>
<name>NSHub</name>
<properties>
<nsweb.version>6.5.x</nsweb.version>
<maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
<buildDirectory>${project.basedir}/target</buildDirectory>
</properties>
<prerequisites>
<maven>3.2.5</maven>
</prerequisites>
<dependencies>
<dependency>
<groupId>com.ns</groupId>
<artifactId>ns-core</artifactId>
<version>${nsweb.version}</version>
</dependency>
<dependency>
<groupId>com.ns</groupId>
<artifactId>ns-common</artifactId>
<version>${nsweb.version}</version>
</dependency>
</dependencies>
<build>
<directory>${buildDirectory}</directory>
<outputDirectory>target/classes</outputDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>Cp1252</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<archiveClasses>true</archiveClasses>
<attachClasses>true</attachClasses>
<warSourceIncludes>WEB-INF/**</warSourceIncludes>
<packagingExcludes>
WEB-INF/lib/ns-common-${nsweb.version}.jar,
WEB-INF/lib/ns-core-${nsweb.version}.jar,
WEB-INF/classes
</packagingExcludes>
<webResources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xls</include>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>**/*.version</include>
<include>**/*.json</include>
</includes>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.ns</groupId>
<artifactId>ns-common</artifactId>
<version>${nsweb.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${buildDirectory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
<destFileName>ns-common-1.0-SNAPSHOT.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>com.ns</groupId>
<artifactId>ns-core</artifactId>
<version>${nsweb.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${buildDirectory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
<destFileName>ns-core-1.0-SNAPSHOT.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</plugin>
</plugins>
<finalName>nshub</finalName>
</build>
</project>
I guess that the
https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#outputFileNameMapping
outputFileNameMapping parameter allows you to customise that.

Parallel execution with maven-surefire-plugin is throwing PluginResolutionException

I am trying to execute my feature files via TestRunner.java files (by mentioning them in pom.xml) , in parallel using maven-surefire-plugin, for which i have set up pom.xml as below, but when i run pom.xml as maven test, its throwing PluginResolutionException when the version is 3.0.0-M3, when i have update the version to 2.19.1, the maven test is not running my feature files but the build is shown as successful
I have tried with different versions but not worked
Also I have tried replacing the configuration part with below changes
still my feature files are not executed but the build is
successful
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<!--
<parallel>classes</parallel>
<forkMode>perthread</forkMode>
<threadCount>3</threadCount>
-->
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<includes>
<include>**/*TestRunner.java</include>
</includes>
</configuration>
PS: After reading the below artical
https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html#Running_tests_in_parallel
I understand that there is link between the Junit version and surefireflugin i use in my project, bow one thing is for sure, the correct combination of Junit and maven-surefire-plugin is very much necessary, i have tried with below combinations
JUnit 4.7
plugin 3.0.0-M3
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M3</version>
</dependency>
</dependencies>
</plugin>
JUnit 4.12
plugin 2.20
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<parallel>classes</parallel>
<threadCount>3</threadCount>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<includes>
<include>**/*TestRunner.java</include>
</includes>
</configuration>
</plugin>
but its not helpful, I suppose i am doing mistake in choosing this versions and the config of plugin with proper parameters, please help me
My complete pom is as below
<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>com.practise.raja</groupId>
<artifactId>SeleniumConcepts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.7.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.7.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<executable>C:\Program Files (x86)\Java\jdk1.8.0_211\bin\javac</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<parallel>classes</parallel>
<forkMode>perthread</forkMode>
<threadCount>3</threadCount>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<includes>
<include>**/*TestRunner.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Expected:
My feature files should run in parallel
Actual:
My feature files are not executed
After changing the dependencies and plugin as suggested by sureshmani, this is how it looks
Finally i am able to solve this, to my initial pom, have started doing below changes. Which ran my feature files in parallel
Change 1: I happen to add the dependency for cucumber-jvm-parallel-plugin along with plugin ,so i have deleted the plugin
Change 2: I have realized that the cucumber-jvm-parallel-plugin is not able to recognize the feature files when I have them placed src/main/java , some of the posts said i have to move all feature files to src/main/resources/feature , where features is package
Change 3: I have realized that cucumber-jvm-parallel-plugin is not able to recognize the resources like step def's and drivers etc, so i have used build-helper-maven-plugin where i have declared the resources as below
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/java/</source>
<source>src/main/resources/</source>
<source>features</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Change 4: cucumber-jvm-parallel-plugin in the maven life cycle in my IDE, because for some reason maven is not able to consider this plugin in it execution
Eclipse --> Windoes --> Preferences --> Maven->LifeCycleMappings-> copy paste below code
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<goals>
<goal>generateRunners</goal>
</goals>
<versionRange>[4.2.0,)</versionRange>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
Then , click on "Reload workspace lifecycle mapping metadata" button in Preference
Maven modal
My final pom looks like this
<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>com.practise.raja</groupId>
<artifactId>JUnitCucumberParallelExecutionPractise</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>JUnitCucumberParallelExecutionPractise</name>
<description>JUnitCucumberParallelExecutionPractise</description>
<dependencies>
<!-- <dependency>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>5.0.0</version>
</dependency>
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.7.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.7.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
</dependencies>
<properties>
<src.main.java>src/main/java</src.main.java>
</properties>
<build>
<resources>
<resource>
<directory>${src.main.java}</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/java/</source>
<source>src/main/resources/</source>
<source>features</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<executable>C:\Program Files (x86)\Java\jdk1.8.0_211\bin\javac</executable>
</configuration>
</plugin>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version> 4.2.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<featuresDirectory>src/main/resources/features</featuresDirectory>
<glue>
<package>com.qa.stepdef</package>
</glue>
<outputDirectory>${project.build.directory}/generated-test-
sources/cucumber</outputDirectory>
<cucumberOutputDir>${project.build.directory}</cucumberOutputDir>
<format> json </format>
<strict>true</strict>
<monochrome>false</monochrome>
<useTestNG>false</useTestNG>
<namingScheme>simple</namingScheme>
<namingPattern>Parallel{c}IT</namingPattern>
<parallelScheme>FEATURE</parallelScheme>
</configuration>
</execution>
</executions>
</plugin>
<!-- Specify a custom template for the generated sources (this is a path
relative to the project base directory) -->
<!-- <customVmTemplate>src/test/resources/custom-runner-template.java.vm
</customVmTemplate> -->
<!-- Specify a custom package name for generated sources. Default is no
package. -->
<!--<packageName></packageName> <plugins> <plugin> <name>json</name>
</plugin>
<plugin> <name>html</name> </plugin> <plugin> <name>pretty</name> </plugin>
</plugins> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/*IT.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Even after these changes, an error started showing at <execution> in pom, it says
Plugin execution not covered by lifecycle configuration: com.github.temyers:cucumber-
jvm-parallel-plugin:4.2.0:generateRunners (execution: generateRunners, phase:
generate-
But, its fine, i am able to run the feature files in parallel even with this above
error
test-sources)

Pass port number from docker-maven-plugin to spring property

I'm developing Spring Data JPA project that targets a MySQL database, and I want to run end-to-end integration tests from Maven.
So far, I've configured io.fabric8.docker-maven-plugin to spin up a MySQL container during pre-integration-test phase. It will use a random available port, which I need to pass to my application.properties file.
I've tried Automatic property expansion using Maven but I suspect that the mysql.port maven property is only getting resolved after the spring properties are getting updated.
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>example</groupId>
<artifactId>pass-port-number-from-docker-maven-plugin-to-spring-property</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- other jpa dependencies ... -->
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>docker-test</id>
<properties>
<docker-maven.version>0.21.0</docker-maven.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>mysql.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven.version}</version>
<configuration>
<images>
<image>
<alias>mysql</alias>
<name>mysql:5.7</name>
<run>
<env>
<MYSQL_ROOT_PASSWORD>my-secret-pw</MYSQL_ROOT_PASSWORD>
</env>
<ports>
<port>mysql.port:3306</port>
</ports>
<wait>
<log>ready for connections</log>
<!-- <time>20000</time> -->
</wait>
<log>
<prefix>mysql</prefix>
<date>ISO8601</date>
<color>blue</color>
</log>
</run>
</image>
</images>
</configuration>
<!-- Connect start/stop to pre- and
post-integration-test phase, respectively if you want to start
your docker containers during integration tests -->
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
application.properties
mysql.port = #mysql.port#
When I run my test I get a connection error, and when I inspect target/classes/application.properties I see that #mysql.port# hasn't been updated.
Any suggestions would be much appreciated.
# only works if you extend from spring-boot-starter-parent; you didn't show the relevant portions of your pom.xml. Assuming you did that, try attaching reserve-network-port to process-sources phase, before process-resources. It's very possible that when Maven copies the resources, the reserve-network-port hasn't ran yet.
What happens if you hardcode 3306 in application.properties?

How to get artificactId of dependencies in Maven?

I have multi-module project. Dependencies are as follows:
<dependencies>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-places-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-devices-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-events-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-controls-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-logs-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
And, under src/main/resources of each module/dependency I have one ZIP file named as <module>-persistence.zip (e.g. C:\gwr-logs-module\src\main\resources\logs-persistence.zip). I want to copy this ZIP file of each module under some other directory let us say C:\users\user\project. I have defined maven-resources-plugin as below:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-presubscriptionfiles</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${user.home}/${dasmo.storage}/</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${basedir}/../gwr-logs-module/src/main/resources</directory>
<includes>
<include>*.zip</include>
</includes>
</resource>
<resource>
<directory>${basedir}/../gwr-devices-module/src/main/resources</directory>
<includes>
<include>*.zip</include>
</includes>
</resource>
<resource>
<directory>${basedir}/../gwr-controls-module/src/main/resources</directory>
<includes>
<include>*.zip</include>
</includes>
</resource>
<resource>
<directory>${basedir}/../gwr-events-module/src/main/resources</directory>
<includes>
<include>*.zip</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
As you see, under resource section I have to hard code each module name. How can I avoid this? Can't we use artifactId of each dependency? If yes, how to use it? Or is there any other way to do this job?
Thank you so much.
regards,
Yeshwant
You can reduce the <plugin> section in your multi-module POM to the following:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-presubscriptionfiles</id>
<!-- Note: this phase is more appropriate than 'validate' -->
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${user.home}/${dasmo.storage}</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<!-- or likewise
<directory>${project.projectDirectory}/src/main/resources</directory>
-->
<includes>
<include>*.zip</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
If you declare your multi-module project as <parent> in any of your sub-module POMs this will be inherited by them (see Introduction to the POM, Project Inheritance) and such performed at each sub-module build.
Note: basedir is deprecated in favor of project.basedir.
See Maven: The Complete Reference, Multi-module vs. Inheritance for further reading.

Maven exclude language files from jasig CAS

I searched to disable all languages and set the default language to english. So that only english is available. But i think there is no possibility to do this in jasig CAS.
So i'm trying to remove all language files from the final .war file of my jasig CAS build.
Her is my pom.xml file:
<modelVersion>4.0.0</modelVersion>
<groupId>lu.ion.cas</groupId>
<artifactId>cas-ion</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>cas-ion Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-webapp</artifactId>
<version>${cas.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-support-ldap</artifactId>
<version>${cas.version}</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<cas.version>3.5.1</cas.version>
</properties>
<repositories>
<repository>
<id>ja-sig</id>
<url>http://oss.sonatype.org/content/repositories/releases/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>cas-ion</warName>
<excludes>
<exclude>**/messages_*.properties</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
The part who is supposed to remove those files:
<excludes>
<exclude>**/messages_*.properties</exclude>
</excludes>
But those files are still there.
Use Maven War plugin Overlays described here: http://maven.apache.org/plugins/maven-war-plugin/overlays.html
In this case pom is like this:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<overlays>
<overlay>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-webapp</artifactId>
<excludes>
<exclude>WEB-INF/classes/messages_*.properties</exclude>
</excludes>
</overlay>
</overlays>
</configuration>
If you want include a language, add another overlay like this:
<overlay>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-webapp</artifactId>
<includes>
<include>WEB-INF/classes/messages_en.properties</include>
</includes>
Use webResources element. http://maven.apache.org/plugins/maven-war-plugin/faq.html#webresourcesexclude
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>path_to_messages</directory>
<excludes>
<exclude>messages_*.properties</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>

Resources