I'm building a Web service application to a JBoss (or Wildfly) server. Inside of it, it calls another Web services. I use Maven for dependency, build and tests. My POM file is as follows:
<?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>[GROUPID]</groupId>
<artifactId>DocGen</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>[GROUPID]</groupId>
<artifactId>DocGenWS</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>DocGenData</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<artifactId>commonj.sdo</artifactId>
<groupId>org.eclipse.persistence</groupId>
</exclusion>
<exclusion>
<artifactId>javax.persistence</artifactId>
<groupId>org.eclipse.persistence</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>EA3</version>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<artifactId>jms</artifactId>
<groupId>javax.jms</groupId>
</exclusion>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
<exclusion>
<artifactId>jmxtools</artifactId>
<groupId>com.sun.jdmk</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>DocGenWS</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
</plugin>
</plugins>
</pluginManagement>
<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>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>
<optimize>true</optimize>
<showwarnings>true</showwarnings>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsgen</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<sei>com.nicetech.tigo.docgen.ws.DocGen</sei>
<genWsdl>true</genWsdl>
<keep>true</keep>
<verbose>true</verbose>
<protocol>Xsoap1.2</protocol>
<extension>true</extension>
<inlineSchemas>true</inlineSchemas>
</configuration>
</execution>
<execution>
<id>wsimport-iface</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>sso_wsefactura.asmx.wsdl</wsdlFile>
</wsdlFiles>
<keep>true</keep>
<packageName>gt.com.megaprint.webservice</packageName>
<sourceDestDir>target/generated-code/src</sourceDestDir>
<verbose>true</verbose>
</configuration>
</execution>
<execution>
<id>wsimport-notification</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>http://wlstest-srv.tigo.com.gt:8011/TIGOAPIServicios/SendNotificationRI/ProxyServices/SendNotificationRIPS_?wsdl</wsdlUrl>
</wsdlUrls>
<keep>true</keep>
<packageName>gt.com.tigo.notification</packageName>
<sourceDestDir>target/generated-code/src</sourceDestDir>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-code/src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project>
My generated WSDL is located at target/jaxws/wsgen/wsdl with its schema, but it is not included in the WAR package generated. When I deploy it to JBoss, the Webservices tab is empty, showing no WS in the package. I was using ANT and it had no issue, but the dependency management and automatic builds were a living hell.
Any ideas?
EDIT: WSgen output
warning: The apt tool and its associated API are planned to be
removed in the next major JDK release. These features have been
superseded by javac and the standardized annotation processing API,
javax.annotation.processing and javax.lang.model. Users are
recommended to migrate to the annotation processing features of
javac; see the javac man page for more information.
Note: ap round: 1
[ProcessedMethods Class: com.nicetech.tigo.docgen.ws.DocGen]
[should process method: emitirDocumentoElectronico hasWebMethods: true ]
[endpointReferencesInterface: false]
[declaring class has WebSevice: true]
[returning: true]
[WrapperGen - method: emitirDocumentoElectronico(java.lang.String,java.lang.String,java.util.Date,java.lang.String,java.lang.String[],com.nicetech.tigo.docgen.ws.obj.EmitirDocumentoEncabezado,com.nicetech.tigo.docgen.ws.obj.EmitirDocumentoOpcional,com.nicetech.tigo.docgen.ws.obj.EmitirDocumentoDetalle)]
[method.getDeclaringType(): com.nicetech.tigo.docgen.ws.DocGen]
[requestWrapper: com.nicetech.tigo.docgen.ws.jaxws.EmitirDocumentoElectronico]
[ProcessedMethods Class: java.lang.Object]
com\nicetech\tigo\docgen\ws\jaxws\EmitirDocumentoElectronico.java
com\nicetech\tigo\docgen\ws\jaxws\EmitirDocumentoElectronicoResponse.java
Note: ap round: 2
Related
I'm trying to test my simple API in wso2 using the Redis connector. The GET request is sent to the API bank via its endpoint to retrieve exchange rates and parsing the data into the Redis cache.
I wrote a unit test for the API and mockservice according to the documentation https://ei.docs.wso2.com/en/7.2.0/micro-integrator/develop/creating-unit-test-suite/.
But when I tried to run this test, I got the following error :
[error] Artifact data reading failed
java.nio.file.NoSuchFileException: ..\NBU_EXCHANGE_DATA_INDEX_660_EI\NBU_EXCHANGE_DATA_INDEX_660_EIConnector\redis-connector-1.0.1.zip
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.Files.readAllBytes(Files.java:3152)
at org.wso2.synapse.unittest.SynapseTestCaseFileReader.processConnectorResourcesData(SynapseTestCaseFileReader.java:290)
at org.wso2.synapse.unittest.SynapseTestCaseFileReader.processArtifactData(SynapseTestCaseFileReader.java:91)
at org.wso2.synapse.unittest.UnitTestClient.executeTests(UnitTestClient.java:54)
at org.wso2.synapse.unittest.UnitTestCasesMojo.testCaseRunner(UnitTestCasesMojo.java:141)
at org.wso2.synapse.unittest.UnitTestCasesMojo.execute(UnitTestCasesMojo.java:79)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[error] Error while creating a deployable message with test suites`
This my unit-test.xml :
<unit-test>
<artifacts>
<test-artifact>
<artifact>/NBU_EXCHANGE_DATA_INDEX_660_EIConfigs/src/main/synapse-config/api/WRITE_EXCHANGE_TO_REDIS.xml</artifact>
</test-artifact>
<supportive-artifacts>
<artifact>/NBU_EXCHANGE_DATA_INDEX_660_EI/NBU_EXCHANGE_DATA_INDEX_660_EIConfigs/src/main/synapse-config/sequences/WRITE_INDEX_EXCHANGE_TO_REDIS_XML.xml</artifact>
<artifact>/NBU_EXCHANGE_DATA_INDEX_660_EI/NBU_EXCHANGE_DATA_INDEX_660_EIConfigs/src/main/synapse-config/endpoints/EXCHANGE_XML_FROM_SITE_NBU_EP.xml</artifact>
</supportive-artifacts>
<registry-resources/>
<connector-resources>
<connector-resource>/NBU_EXCHANGE_DATA_INDEX_660_EI/NBU_EXCHANGE_DATA_INDEX_660_EIConnector/redis-connector-1.0.1.zip</connector-resource>
</connector-resources>
</artifacts>
<test-cases>
<test-case name="GetXML_exchange">
<input>
<request-path>/nbu-exchange/xml</request-path>
<request-method>GET</request-method>
<request-protocol>http</request-protocol>
</input>
<assertions>
<assertEquals>
<actual>$body</actual>
<expected><![CDATA[{
"Date": "2022-09-14",
"HTTP_SC": "200",
"XML_connect": "true",
"MAIN_XML_isUpdate": "false",
"TMP_XML_isUpdate": "false",
"NBU_XML_isUpdate": "false"
}]]></expected>
<message>not equals</message>
</assertEquals>
<assertNotNull>
<actual>$body</actual>
<message>not null</message>
</assertNotNull>
</assertions>
</test-case>
</test-cases>
<mock-services>
<mock-service>/NBU_EXCHANGE_DATA_INDEX_660_EI/NBU_EXCHANGE_DATA_INDEX_660_EIConfigs/test/resources/mock-services/ImitationNBU_EP_XML.xml</mock-service>
</mock-services>
</unit-test>
This my mock-service.xml :
<mock-service>
<service-name>EXCHANGE_XML_FROM_SITE_NBU_EP</service-name>
<port>9090</port>
<context>/nbu-exchange</context>
<resources>
<resource>
<sub-context>/xml</sub-context>
<method>GET</method>
<response>
<status-code>200</status-code>
<payload><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<exchange>
<currency>
<r030>36</r030>
<txt>Австралійський долар</txt>
<rate>25.2652</rate>
<cc>AUD</cc>
<exchangedate>14.09.2022</exchangedate>
</currency>
<currency>
<r030>124</r030>
<txt>Канадський долар</txt>
<rate>28.1969</rate>
<cc>CAD</cc>
<exchangedate>14.09.2022</exchangedate>
</currency>
</exchange>]]></payload>
<headers>
<header name="Content-Type" value="application/xml"/>
</headers>
</response>
</resource>
</resources>
</mock-service>
This my pom.xml for test
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>NBU_EXCHANGE_DATA_INDEX_660_EI</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.example</groupId>
<artifactId>NBU_EXCHANGE_DATA_INDEX_660_EIConfigs</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>NBU_EXCHANGE_DATA_INDEX_660_EIConfigs</name>
<description>NBU_EXCHANGE_DATA_INDEX_660_EIConfigs</description>
<properties>
<CApp.type>bpel/workflow=zip,lib/registry/filter=jar,webapp/jaxws=war,lib/library/bundle=jar,service/dataservice=dbs,synapse/local-entry=xml,synapse/proxy-service=xml,carbon/application=car,registry/resource=zip,lib/dataservice/validator=jar,synapse/endpoint=xml,web/application=war,lib/carbon/ui=jar,service/axis2=aar,synapse/sequence=xml,synapse/configuration=xml,wso2/gadget=dar,lib/registry/handlers=jar,lib/synapse/mediator=jar,synapse/task=xml,synapse/api=xml,synapse/template=xml,synapse/message-store=xml,synapse/message-processors=xml,synapse/inbound-endpoint=xml,synapse/metadata=yaml</CApp.type>
<maven.test.skip>false</maven.test.skip>
</properties>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<id>wso2-nexus</id>
<url>https://maven.wso2.org/nexus/content/groups/wso2-public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<id>wso2-nexus</id>
<url>https://maven.wso2.org/nexus/content/groups/wso2-public/</url>
</pluginRepository>
</pluginRepositories>
<build>
<directory>target/capp</directory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>package</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>mvn</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>clean</argument>
<argument>package</argument>
<argument>-Dmaven.test.skip=${maven.test.skip}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>mvn</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>clean</argument>
<argument>install</argument>
<argument>-Dmaven.test.skip=${maven.test.skip}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>mvn</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>deploy</argument>
<argument>-Dmaven.test.skip=${maven.test.skip}</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration />
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<buildcommands />
<projectnatures>
<projectnature>org.wso2.developerstudio.eclipse.esb.project.nature</projectnature>
</projectnatures>
</configuration>
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>synapse-unit-test-maven-plugin</artifactId>
<version>5.2.38</version>
<executions>
<execution>
<id>synapse-unit-test</id>
<phase>test</phase>
<goals>
<goal>synapse-unit-test</goal>
</goals>
</execution>
</executions>
<configuration>
<server>
<testServerType>${testServerType}</testServerType>
<testServerHost>${testServerHost}</testServerHost>
<testServerPort>${testServerPort}</testServerPort>
<testServerPath>${testServerPath}</testServerPath>
</server>
<testCasesFilePath>${project.basedir}/test/${testFile}</testCasesFilePath>
<mavenTestSkip>${maven.test.skip}</mavenTestSkip>
</configuration>
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-sequence-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>sequence</id>
<phase>process-resources</phase>
<goals>
<goal>pom-gen</goal>
</goals>
<configuration>
<artifactLocation>.</artifactLocation>
<typeList>${artifact.types}</typeList>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration />
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-endpoint-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>endpoint</id>
<phase>process-resources</phase>
<goals>
<goal>pom-gen</goal>
</goals>
<configuration>
<artifactLocation>.</artifactLocation>
<typeList>${artifact.types}</typeList>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration />
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-api-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>api</id>
<phase>process-resources</phase>
<goals>
<goal>pom-gen</goal>
</goals>
<configuration>
<artifactLocation>.</artifactLocation>
<typeList>${artifact.types}</typeList>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration />
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-metadata-plugin</artifactId>
<version>5.2.34</version>
<extensions>true</extensions>
<executions>
<execution>
<id>metadata</id>
<phase>process-resources</phase>
<goals>
<goal>pom-gen</goal>
</goals>
<configuration>
<artifactLocation>.</artifactLocation>
<typeList>${artifact.types}</typeList>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration />
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-task-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>task</id>
<phase>process-resources</phase>
<goals>
<goal>pom-gen</goal>
</goals>
<configuration>
<artifactLocation>.</artifactLocation>
<typeList>${artifact.types}</typeList>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration />
</plugin>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>wso2-esb-proxy-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>proxy</id>
<phase>process-resources</phase>
<goals>
<goal>pom-gen</goal>
</goals>
<configuration>
<artifactLocation>.</artifactLocation>
<typeList>${artifact.types}</typeList>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration />
</plugin>
</plugins>
</build>
</project>
What am I doing wrong?
If you have a Connector Exporter Project created, you should be able to add the connector as a dependency when creating the Test Suite in the Supportive Artifacts Page.
Another option is to deploy the connector separately before running the Test Suite. You can create a Common project to pack all the common dependencies and have it deployed to MI runtime so it can be referred to by all the other projects.
Jacoco reports for this project contain line coverage for test classes, despite attempting to exclude tests as below
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<excludes>
<exclude>**/*Test.*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<configuration>
<excludes>
<exclude>**/*Test.*</exclude>
</excludes>
</configuration>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<configuration>
<excludes>
<exclude>**/*Test.*</exclude>
</excludes>
</configuration>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule implementation="org.jacoco.maven.RuleConfiguration">
<excludes>
<exclude>**/*Test.*</exclude>
</excludes>
<element>CLASS</element>
<limits>
<limit implementation="org.jacoco.report.check.Limit">
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.94</minimum>
</limit>
<limit implementation="org.jacoco.report.check.Limit">
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.85</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
The above pom is basically us shotgunning the config with solutions from existing StackOverflow questions, but none of them are working.
Any feedback would be much appreciated!
In absence of Minimal Complete Reproducible Example one can only guess how your test files are placed in your project and why they are shown in report, because jacoco-maven-plugin doesn't show test classes in report by default - here is proof:
for the following 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
src/main/java/Example.java
class Example {
void sayHello() {
System.out.println("Hello, World!");
}
}
and src/test/java/ExampleTest.java
import org.junit.Test;
public class ExampleTest {
#Test
public void test() {
new Example().sayHello();
}
}
execution of
mvn clean verify
generates following report that as you can see doesn't contain src/test/java/ExampleTest.java:
Trying to blindly guess, one can assume that your project has non-standard structure where the above Example.java and ExampleTest.java reside in the same src directory and you have following 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<testSourceDirectory>${project.basedir}/src</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
then execution of mvn clean verify indeed will produce following report that contains ExampleTest.java
however in this case following exclusion of **/*Test.*
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<testSourceDirectory>${project.basedir}/src</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
<goal>report</goal>
</goals>
<configuration>
<excludes>
<exclude>**/*Test.*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
works just fine
I have used maven to generate metamodel for JPA entities
But I'm getting the following error:
[ERROR] No plugin found for prefix 'maven-compiler-plugin' in the current project
and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available
from the repositories [local, central (http://repo.maven.apache.org/maven2)] -> [Help 1]
org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found
for prefix 'maven-compiler-plugin' in the current project and in the plugin groups
[org.apache.maven.plugins, org.codehaus.mojo] available from the repositories
[local, central (http://repo.maven.apache.org/maven2)]
at org.apache.maven.plugin.prefix.internal.DefaultPluginPrefixResolver.resolve(DefaultPluginPrefixResolver.java:93)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.findPluginForPrefix(MojoDescriptorCreator.java:260)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:220)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:106)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:86)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:98)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
And my pom.xml is
<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>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.signalmapper</groupId>
<artifactId>SignalMapper</artifactId>
<properties>
<appengine.target.version>1.9.15</appengine.target.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.0.1.RELEASE</spring.version>
<build.directory>./war/WEB-INF</build.directory>
<datanucleus.version>3.1.3</datanucleus.version>
</properties>
<dependencies>
<!-- Compile/runtime dependencies -->
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- App Engine dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${appengine.target.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- Datanucleus persistence -->
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>2.0.1.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.version}</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jpa</artifactId>
<version>${datanucleus.version}</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-enhancer</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>
<!-- JSON-parser dependencies -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
<!-- Spring data JPA dependency -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.7.1.RELEASE</version>
</dependency>
<!-- slf4j dependency -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<outputDirectory>${build.directory}/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>2.5.1</version>
<artifactId>eccompiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>default-war</id>
<phase>prepare-package</phase>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archiveClasses>false</archiveClasses>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix />
</manifest>
</archive>
</configuration>
</execution>
</executions>
<version>2.3</version>
<configuration>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<api>JPA</api>
<metadataDirectory>${build.directory}/classes/com/signalmapper/data/model</metadataDirectory>
<metadataIncludes>**/*.class</metadataIncludes>
<persistenceUnitName>transactions-optional</persistenceUnitName>
<verbose>true</verbose>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/resources/META-INF</directory>
<includes>
<include>persistence.xml</include>
</includes>
</resource>
</resources>
</configuration>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>generate-entity-metamodel</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.6</source>
<target>1.6</target>
<optimize>true</optimize>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<proc>only</proc>
<compilerArgument>-Aopenjpa.metamodel=true</compilerArgument>
<generatedSourcesDirectory>${build.directory}/generated-sources</generatedSourcesDirectory>
<compilerArguments>
<processor>org.apache.openjpa.persistence.meta.AnnotationProcessor6</processor>
</compilerArguments>
</configuration>
</execution>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I am newbie to maven and I don't know what am I missing?
Any help would be highly appreciated.
I have created a web project using maven 2(it will be deployed on tomcat 7.0.35), which should serve as a client for JAX-WS web service. I am trying to generate client classes from wsdl file(I have 1 wsdl and 1 xsd).
After I run "mvn clean install" command, no classes are generated and I don't see any errors in console
This is my 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.ws</groupId>
<artifactId>my_ws</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>cs Maven Webapp</name>
<url>http://maven.apache.org</url>
<build>
<finalName>my_ws</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<projectNameTemplate>
[artifactId]-[version]
</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
<manifest>
${basedir}/src/main/resources/META-INF/MANIFEST.MF
</manifest>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>my_ws.wsdl</wsdlFile>
</wsdlFiles>
<packageName>com.test.ws.client</packageName>
<sourceDestDir>${basedir}/target/generated-sources/</sourceDestDir>
<keep>true</keep>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/wsdl/binding.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/wsdl/jaxb-binding.xml</bindingFile>
</bindingFiles>
</configuration>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>11.2.0.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.8</version>
</dependency>
</dependencies>
</project>
Here is binding.xml
<bindings
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="./my_ws.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws">
<!-- Disable default wrapper style -->
<enableWrapperStyle>false</enableWrapperStyle>
</bindings>
and jaxb-binding.xml
<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:globalBindings generateElementProperty="false" />
</jaxb:bindings>
When using <pluginManagement> element in a pom file, you don't declare plugins usage, but plugins availability. <pluginManagement> is used in a parent pom to announce available plugins for child pom usage.
Just remove this element, and the plugins should be called.
Hi i m running into some error
I have a really small project in groovy.
I want to use maven.
I was able to compile my files, source and test(i have my .class in the target folder). But no test are executed.
here is my pom file.
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gmedia</groupId>
<artifactId>gmedia.api</artifactId>
<name>Gmedia API project</name>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.2.3</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0-rc-5</version>
<executions>
<execution>
<goals>
<!--<goal>generateStubs</goal>-->
<goal>compile</goal>
<!--<goal>generateTestStubs</goal>-->
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<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>
</build>
<repositories>
<repository>
<url>http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo</url>
<id>eclipselink</id>
<layout>default</layout>
<name>Repository for library Library[eclipselink]</name>
</repository>
</repositories>
My groovy files are in src/groovy and test/groovy
What i'm dooing wrong?
BTW, I get compilation errors when I add this configuration:
<configuration>
<sources>
<fileset>
<directory>${pom.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</fileset>
</sources>
</configuration>
compile my file with erro when adding this to the groovy-maven-plugin
<configuration>
<sources>
<fileset>
<directory>${pom.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</fileset>
</sources>
</configuration>
Well for one thing you are using an outdated version of GMaven.
The plugin has moved to the Group Id org.codehaus.gmaven and the current version is 1.3:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Also, you probably need to keep the stub goals active for JUnit to find you test classes.
See this page for reference: Buildung Groovy Projects with GMaven
Update:
If i define a test to run, it run. but
with just mvn clean test, the test are
compiled, but not executed
This sounds like you're not following the naming conventions for test classes.
See the first section of this page: Inclusions and Exclusions of Tests