Maven doesn't execute any unit test - unit-testing

I am using Maven with multi-modules. There are 3 projects.
foo(the parent project)
foo-core
foo-bar
I configure all the dependencies and plugins in foo's pom:
<modules>
<module>../foo-core</module>
<module>../foo-bar</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
...
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.14.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
There are several base classes and util classes for unit test in foo-core, so I add the maven-jar-plugin in foo-core project to make it available to foo-bar:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
When I execute test goal, I got the result as follow:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
parallel='none', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
I do got tests in my projects. But why it doesn't run any of them?

Rename test files from **Tests.java to **Test.java or add the following configuration to pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>

Additionally, one more cause for such a behaviour is if you have an exclusion for junit-vintage-engine in your pom.xml dependencies.
In my case I had excluded it from the spring-boot-starter-test dependency in my pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
This resulted in the same problem. Maven not able to recognize/find any test cases in the project even though they are present.
So just remove the exclusions section and run the maven command again.

Had similar issue was able to run unit test case by adding dependency to sunfire plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.22.0</version>
</dependency>
</dependencies>
</plugin>
above worked fine byb executing test cases on mvn install , mvn test and all

In my case, it was necessary to add the word "Test" to the end of the name of all files with tests.
For example, if you have "LoginTestNegative" then this will not work. You need to rename this to LoginNegativeTest. And now it will work.

I had a similar problem today. I had converted most of my tests to JUnit5 and surefire was not executing them via mvn test. I had to modify the pom.xml entry for surefire to force it to use the JUnit5 engine as it was selecting JUnit4 by default
Dependencies section (vintage is for the JUnit4 tests)
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
Plugin section
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M6</version>
<configuration>
<argLine>#{argLine}</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit-platform</artifactId>
<version>3.0.0-M6</version>
</dependency>
</dependencies>
</plugin>

Related

Need simple working pom.xml file for wsconsume

I am using Java8 and I am trying to consume webservice using jboss plugin.
I have tried https://docs.jboss.org/author/display/JBWS/wsconsume and ran into lot of compatibility issues
The problem is I am having lot of dependency error all the time and I am now fed up. The current error is Failure to find com.sun.istack:istack-commons-runtime:jar:1.1. My concern is do i need these many dependency to run simple wsconsume?
<pluginRepositories>
<pluginRepository>
<id>JBOSS</id>
<name>JBoss Repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
<version>6.1.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jboss.ws.plugins</groupId>
<artifactId>maven-jaxws-tools-plugin</artifactId>
<version>1.1.1.Final</version>
<executions>
<execution>
<id>My execution</id>
<goals>
<goal>wsconsume</goal>
</goals>
<configuration>
<wsdls>
<wsdl>mylocation?wsdl</wsdl>
</wsdls>
<targetPackage>src</targetPackage>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jboss.ws.native</groupId>
<artifactId>jbossws-native-client</artifactId>
<version>3.3.1.GA</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.ws</groupId>
<artifactId>jbossws-spi</artifactId>
<version>3.1.4.Final</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
Resolved by executed the wsconsume.bat with exec-maven-plugin instead of CRAPY JBoss plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>runbatchfile</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${env.RH-SSO}/bin/wsconsume.bat</executable>
<arguments>
<argument>-o</argument>
<argument>${project.build.directory}\classes</argument>
<argument>C:\my.wsdl</argument>
</arguments>
</configuration>
</plugin>

Pom.xml is failing to create output directory for reportng results

I have gone through many posts and blogs but couldn't generate reportng or testng-xslt reports via maven. Finally I have got this tutorial but no luck. I cant understand what am I missing.
Here's what I have tried : It successfully generates the surefire reports in the target folder but doesnt create(generate reports) a directory for reportng reports.
<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.testng.xslt</groupId>
<artifactId>testng-xslt-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>TestNG XSLT Maven Plugin</name>
<version>1.2</version>
<prerequisites>
<maven>2.0.4</maven>
</prerequisites>
<developers>
<developer>
<id>cosminaru</id>
<name>Cosmin Marginean</name>
<email>cosminaru#gmail.com</email>
</developer>
</developers>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>C:/Users/paul/Desktop/reporty-ng-1.2/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.reportyng</groupId>
<artifactId>reporty-ng</artifactId>
<version>1.2</version>
<configuration>
<surefireReportDirectory>C:/Users/paul/Desktop/reporty-ng-1.2/target/surefire-reports</surefireReportDirectory>
<!--Setting the output directory -->
<outputDir>C:/Users/paul/workspace/windowspc/target/site/testng-xslt-plugin</outputDir>
<!--Setting the testNgXslt.showRuntimeTotals flag -->
<showRuntimeTotals>true</showRuntimeTotals>
<!--Setting the testNgXslt.cssFile parameter. This should be relative
to the '${basedir}/target/site/testng-xslt' directory -->
<sortTestCaseLinks>true</sortTestCaseLinks>
<testDetailsFilter>FAIL,PASS,SKIP,CONF</testDetailsFilter>
</configuration>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>saxon</artifactId>
<version>8.7</version>
</dependency>
<!-- selenium and testng -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.34.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.34.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.34.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>2.34.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
<scope>test</scope>
</dependency>
<!-- selenium and testng -->
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>reporty-ng</id>
<url>https://github.com/cosminaru/reporty-ng/raw/master/dist/maven</url>
</pluginRepository>
</pluginRepositories>
</project>
Take a look at:
http://maven.apache.org/surefire/maven-surefire-report-plugin/examples/report-custom-location.html
for maven-surefire-report-plugin, the configuration should include outputDirectory tag, e.g.:
<outputDirectory>${project.basedir}/test-output</outputDirectory>
Or when using maven-surefire-plugin, set reportsDirectory tag, e.g.:
<reportsDirectory>${project.basedir}/test-output</reportsDirectory>

persistence.xml dependency in maven test

Consider this structure:
/project
/module-1
/src/test/resources/META-INF/persistence.xml
/module-2
In module-1 test jar is created.
module-1/pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
This test jar is a dependency in module-2/pom.xml:
<dependency>
<groupId>com.domain.test</groupId>
<artifactId>module-1</artifactId>
<scope>test</scope>
<type>jar</type>
</dependency>
Problem is that in tests of module-2, persitence units(PU) defined in /src/test/resources/META-INF/persistence.xml cannot be found. PU are created programatically:
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnit);
EntityManager entityManager = entityManagerFactory.createEntityManager();
How can I get it work? Thanks.
The dependency you declared is not targetting the test-jar you created.
You should declared it like this:
<dependency>
<groupId>com.domain.test</groupId>
<artifactId>test-shared</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>

wsimport fail with maven

I'm trying to create an ssl webservice client using maven and netbeans(7.2).
The webservice is perfectly working and I test it using an ant project.
When I try to build the project and generate webservice stubs I get this error:
Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.2:wsimport (wsimport-generate-test_project_ws_v1) on project mavenproject3: Error executing: wsimport [-keep, -s, C:\Users\no_name\Documents\NetBeansProjects\mavenproject3\target\generated-sources\jaxws-wsimport, -verbose, -encoding, UTF-8, -extension, -Xnocompile, -catalog, C:\Users\no_name\Documents\NetBeansProjects\mavenproject3\src\jax-ws-catalog.xml, -wsdllocation, https://localhost:8181/test_project_ws_v1/test_project_ws_v1?wsdl, file:/C:/Users/no_name/Documents/NetBeansProjects/mavenproject3/src/wsdl/localhost_8181/test_project_ws_v1/test_project_ws_v1.wsdl]: UndeclaredThrowableException: javax.xml.bind.annotation.XmlElementRef.required() -> [Help 1]
This is my pom (generated by netbeans)
<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.procc</groupId>
<artifactId>mavenproject3</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mavenproject3</name>
<url>http://maven.apache.org</url>
<build>
<resources>
<resource>
<targetPath>META-INF</targetPath>
<directory>src</directory>
<includes>
<include>jax-ws-catalog.xml</include>
<include>wsdl/**</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>localhost_8181/test_project_ws_v1/test_project_ws_v1.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>https://localhost:8181/test_project_ws_v1/test_project_ws_v1?wsdl</wsdlLocation>
<staleFile>${project.build.directory}/jaxws/stale/test_project_ws_v1.stale</staleFile>
</configuration>
<id>wsimport-generate-test_project_ws_v1</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>webservices-rt</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Thanks.
I was having the same error recently.
It seems that it happens because wsimport messes with 2.1 and 2.2 versions of jaxb.
I was able to generate the Web Services sources correctly by editing the project pom.xml and adding a <target>2.1</target> tag to the configuration of each imported wsdl, like this:
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>path/to/file.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>http://path/to/webservice?wsdl</wsdlLocation>
<staleFile>path/to/file.stale</staleFile>
<target>2.1</target>
</configuration>
<id>wsimport-generate-WebServiceName</id>
<phase>generate-sources</phase>
</execution>
Hope it helps whoever is having this issue.
We had a similar issue. When doing a wsimport we got a command line error stating -encoding was an invalid parameter.
Looking in the POM, and the plugin section for jaxws-maven-plugin the following dependency existed:
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.5</version>
</dependency>
</dependencies>
Removing this fixed the issue. We were also using version 2.3 of jaxws-maven-plugin
I could build on one machine but not another - the issue was caused by environment variables
Check your maven environment variables, M2 and M2_HOME
M2_HOME - "<Apache-maven-root-directory>" e.g. ("C:\Tools\apach-maven")
M2 - "%M2_HOME%\bin" (For windows machine)

*.jaxws package is not generated with java2ws under cxf

Im trying to generate a wsdl from java first strategy using cxf maven plugin , it compiles, build well but only generates the wsdl and not the wrapper beans which should created with the package *.jaxws.
so when deploying with weblogic ( 10.0 ) it throws :
class: com.edf.ftn.ws.jaxws.GetIban could not be found
at com.sun.xml.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:272)
at com.sun.xml.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:566)
at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:513)
at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:358)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:245)
at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:229)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:161)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:291)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:315)
at weblogic.wsee.jaxws.JAXWSServlet.registerEndpoint(JAXWSServlet.java:125)
at weblogic.wsee.jaxws.JAXWSServlet.init(JAXWSServlet.java:64)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:282)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:63)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:507)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1853)
at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1830)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1750)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2918)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:973)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:361)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:566)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:136)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:104)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:320)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:816)
at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1223)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:434)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:161)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:181)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:67)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
here is my pom.xml configuration :
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2ws-plugin</artifactId>
<version>2.6.2</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-simple</artifactId>
<version>${cxf.version}</version>
</dependency>
<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>
<executions>
<execution>
<id>process-classes</id>
<phase>package</phase>
<configuration>
<className>com.edf.ftn.ws.InfosRibProducteurImpl</className>
<genWrapperbean>true</genWrapperbean>
<genServer>true</genServer>
<outputFile>com.edf.ftn.ws.jaxws</outputFile>
<classpath>com.edf.ftn.ws.jaxws</classpath>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
</executions>
</plugin>
and here is my webservice interface class :
#WebService(name="InfosRibProducteurService")
#SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL,parameterStyle=ParameterStyle.WRAPPED)
#Policies({ #Policy( uri ="META-INF/policy/usernametoken.xml", placement=Policy.Placement.BINDING) } )
public interface InfosRibProducteur {
#WebMethod
#WebResult(name = "responsegetIban")String getIban(#XmlElement(nillable = false, required = true) #WebParam(name = "fournisseur") final String pNumeroFournisseur);
#WebMethod
#WebResult(name = "responseEditIban") ResponseRibDTO editIban(#XmlElement(nillable = false, required = true) #WebParam(name = "Fournisseur")final String pNumeroFournisseur, #XmlElement(nillable = false, required=true) #WebParam(name = "iban") final String pRib);
}
any help will be welcomed thanks.
Try removing the outputFile and classpath entries. Those are likely not needed in this case and may be causing problems. They are also wrong as the outputFile should be the full path to the wsdl file that would be generated. Like: ${basedir}/target/generated/wsdl/MyWsdl.wsdl
This worked for me.
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2ws-plugin</artifactId>
<version>${cxf.version}</version>
<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-frontend-simple</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
<type>jar</type>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-wsdl</id>
<phase>process-classes</phase>
<goals>
<goal>java2ws</goal>
</goals>
<configuration>
<className>com.demo.helloworld</className>
<outputFile>./WebContent/wsdl/helloworld.wsdl</outputFile>
<argline>-createxsdimports</argline>
<verbose>true</verbose>
<frontend>jaxws</frontend>
<databinding>jaxb</databinding>
<genWsdl>true</genWsdl>
<genWrapperbean>true</genWrapperbean>
<soap12>false</soap12>
<attachWsdl>true</attachWsdl>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-classes</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>./target/classes/com/demo/jaxws</outputDirectory>
<resources>
<resource>
<directory>./com/demo/jaxws</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>