Classes from WSDL aren't auto-generated by CXF - java

I'm trying to port a SOAP consuming application to JAVA. I'm having issues making cxf-codegen-plugin to read the WSDL, which is from a third party and it actually works. I'm guessing that the issue is that the WSDL is not fully compliant with the standard and CXF can't complete the parsing.
Following for example the tutorial at http://www.littlebigextra.com/consume-secure-soap-web-service-spring-boot-application/, I can succesfully parse the following WSDLs https://osetesting.bizlinks.com.pe/ol-ti-itcpe/billService?wsdl and https://test.conose.pe/ol-ti-itcpe/billService.svc, but can't process https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl, which would be funny if I weren't stuck in this issue, since the last one is SUPPOSED to be the reference for the first two.
I have also tried the SpringBoot tutorial at https://spring.io/guides/gs/consuming-web-service/, it doesn't raise an error, but it doesn't create the classes as well
Here is my pom (taken from http://www.littlebigextra.com/consume-secure-soap-web-service-spring-boot-application/)
<?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>test.wsdl</groupId>
<artifactId>test-sunat-soap-ws</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<cxf.version>3.1.10</cxf.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent>
<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-ws-policy</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-common</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</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>
<additionalJvmArgs>
-Djavax.xml.accessExternalDTD=all
-Djavax.xml.accessExternalSchema=all
</additionalJvmArgs>
<sourceRoot>${basedir}/src/main/generated</sourceRoot>
<wsdlOptions>
<wsdlOption>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-p</extraarg>
<extraarg>sunat.generated</extraarg>
<extraarg>-exsh</extraarg>
<extraarg>true</extraarg>
</extraargs>
<!--<wsdl>https://osetesting.bizlinks.com.pe/ol-ti-itcpe/billService?wsdl</wsdl>-->
<!--<wsdl>https://test.conose.pe/ol-ti-itcpe/billService.svc</wsdl>-->
<wsdl>https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/src/main/generated</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I run mvn generate-sources, I can see that is calling the wsdl2java tool
wsdl2java -encoding UTF-8 -d C:\dev-tools\testbizlinksgetstatuscdr\src\main\generated -verbose -p sunat.generated -exsh true https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl
However, I get the following stacktrace
org.apache.cxf.tools.common.ToolException: java.io.IOException: Server returned HTTP response code: 503 for URL: https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?ns1.wsdl
at org.apache.cxf.tools.validator.internal.Stax2DOM.getDocument(Stax2DOM.java:64)
at org.apache.cxf.tools.validator.internal.Stax2DOM.getDocument(Stax2DOM.java:47)
at org.apache.cxf.tools.validator.internal.WSDLRefValidator.getWSDLDocument(WSDLRefValidator.java:168)
at org.apache.cxf.tools.validator.internal.WSDLRefValidator.getWSDLDocuments(WSDLRefValidator.java:185)
at org.apache.cxf.tools.validator.internal.WSDLRefValidator.isValid(WSDLRefValidator.java:231)
at org.apache.cxf.tools.validator.internal.WSDL11Validator.isValid(WSDL11Validator.java:134)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.validate(JAXWSDefinitionBuilder.java:207)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:201)
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)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:414)
at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:279)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:511)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
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:954)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
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: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)
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?ns1.wsdl
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at java.net.URL.openStream(URL.java:1045)
at org.apache.cxf.tools.validator.internal.Stax2DOM.getDocument(Stax2DOM.java:59)
... 37 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.681 s
[INFO] Finished at: 2019-07-18T15:21:38-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.3.2:wsdl2java (generate-sources) on project test-bizlinks-getstatuscdr: Execution generate-sources of goal org.apache.c
xf:cxf-codegen-plugin:3.3.2:wsdl2java failed:
[ERROR] Summary: Failures: 14, Warnings: 0
[ERROR]
[ERROR] <<< ERROR!
[ERROR] null
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[29,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendSummary][output:sendSummaryResponse] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[27,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendSummary][input:sendSummaryRequest] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[25,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendSummary] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[23,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendPack][output:sendPackResponse] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[21,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendPack][input:sendPackRequest] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[19,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendPack] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[17,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendBill][output:sendBillResponse] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[15,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendBill][input:sendBillRequest] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[13,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:sendBill] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[11,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:getStatus][output:getStatusResponse] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[9,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:getStatus][input:getStatusRequest] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[7,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService][operation:getStatus] not exist.
[ERROR] https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl:[5,1]
[ERROR] Caused by {http://service.sunat.gob.pe}[portType:billService] not exist.
[ERROR]
[ERROR] -> [Help 1]
Edited: I included the whole error output, since I realized there were additional errors after the stacktrace
The line 503 for URL: https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?ns1.wsdl is what makes me think that the WSDL is not fully compliant (because of the ?ns1.wsdl param, instead of just ?wsdl) However, if I try to access that link, I do get the same WSDL as if I used the original link, so I don't understand the 503 error at all.
When I run the code from the second tutorial, I get the following messages
[INFO] --- maven-jaxb2-plugin:0.12.3:generate (default) # sunat-consuming-web-service ---
[INFO] Up-to-date check for source resources [[https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl, file:/C:/dev-tools/sunatconsumingwebservice/pom.xml]] and taret resource
s [[]].
[WARNING] The URI [https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl] seems to represent an absolute HTTP or HTTPS URL. Getting the last modification timestamp is only po
ssible if the URL is accessible and if the server returns the [Last-Modified] header correctly. This method is not reliable and is likely to fail. In this case the last modification time
stamp will be assumed to be unknown.
[ERROR] Could not retrieve the last modification timestamp for the URI [https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl] from the HTTP URL connection. The [Last-Modifie
d] header was probably not set correctly.
[WARNING] Last modification of the URI [https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl] is not known.
[INFO] Sources are not up-to-date, XJC will be executed.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Cool, no error... but also no classes at all. When I use any of the other two URLs, the classes are generated at target/xjc/sunat.wsdl, showing exactly the same messages.
I tried using verbose, with mvn generate-sources -X, but apart of showing additional messages about the settings, no errors or more information of why the classes aren't generated appears.
How can I get either code to generate the classes for the WS?

Related

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project grpc_hello_server: Compilation failure

I'm trying to create a gRPC service with Java using below codelab.
I created a sample proto file. While compiling the .proto using maven, i got a build failure error. It says javax.annotation.Generated anottation class is not found.
Could you help me find the root cause of the issue and steps to fix it. I feel it should be a versioning issue but not clear on how to solve it.
https://codelabs.developers.google.com/codelabs/cloud-grpc-java/index.html?index=..%2F..index#2
Errors:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/grpc_hello_server/target/generated-sources/protobuf/grpc-java/com/example/grpc/GreetingServiceGrpc.java:[20,18] cannot find symbol
symbol: class Generated
location: package javax.annotation
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.845 s
[INFO] Finished at: 2020-06-29T16:56:21-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project grpc_hello_server: Compilation failure
[ERROR] /home/grpc_hello_server/target/generated-sources/protobuf/grpc-java/com/example/grpc/GreetingServiceGrpc.java:[20,18] cannot find symbol
[ERROR] symbol: class Generated
[ERROR] location: package javax.annotation
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException.
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.example.grpc</groupId>
<artifactId>grpc_hello_server</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>grpc_hello_server</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.4.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.7.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Issue is due to missing dependency in pom.xml for Java 9+
<dependency> <!-- necessary for Java 9+ -->
<groupId>org.apache.tomcat</groupId>
<artifactId>annotations-api</artifactId>
<version>6.0.53</version>
<scope>provided</scope>
</dependency>
Any reason you are using Java 1.6?
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
Can you change it to 1.7 and see if it works?

What causes "an unknown compilation problem occurred"?

When trying to compile my project using Maven, I get the following error: An unknown compilation problem occurred.
I tried running the following command to get more details on the error, but I still can't figure it out: mvn -e -X clean install
This is the log I got:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] An unknown compilation problem occurred
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] app ................................................ SUCCESS [ 2.033 s]
[INFO] models ............................................. SUCCESS [ 4.418 s]
[INFO] authorization-db ................................... SUCCESS [ 1.654 s]
[INFO] test-utils ......................................... SUCCESS [ 0.721 s]
[INFO] clients ............................................ SUCCESS [ 7.412 s]
[INFO] data-access ........................................ FAILURE [ 3.289 s]
[INFO] templating ......................................... SKIPPED
[INFO] guice-vertx ........................................ SKIPPED
[INFO] routing ............................................ SKIPPED
[INFO] frontend-tests ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.756 s
[INFO] Finished at: 2019-06-18T11:00:07+01:00
[INFO] Final Memory: 53M/190M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project data-access: Compilation failure
[ERROR] An unknown compilation problem occurred
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project data-access: Compilation failure
An unknown compilation problem occurred
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
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)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
An unknown compilation problem occurred
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 21 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :data-access
EDIT: This is the pom.xml file of the data-access module:
<?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>com.some.app</groupId>
<artifactId>app</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>data-access</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.some.app</groupId>
<artifactId>authorization-db</artifactId>
</dependency>
<dependency>
<groupId>com.englishtown.vertx</groupId>
<artifactId>vertx-guice</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>testtools</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-unit</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-codetrans</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-rx-java</artifactId>
</dependency>
<dependency>
<groupId>com.some.app</groupId>
<artifactId>clients</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.some.app</groupId>
<artifactId>models</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.some.app</groupId>
<artifactId>test-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
EDIT 2: Maven compiler plugin configuration on root pom.xml:
...
<properties>
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<java.version>11</java.version>
</properties>
...
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
...
To note that this compilation problem started happening after I migrated the Java version in the project from 1.8 to 11.
I was facing same issue. I was able to get rid of this issue after removing
<compilerArgument>-Werror</compilerArgument>
line from maven compiler plugin configuration in pom.xml file.
maven-compiler-plugin configuration before removing above line:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-Werror</compilerArgument>
</configuration>
</plugin>
maven-compiler-plugin configuration after removing above line:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
You are using old version of maven plugin (3.1) to compile your code. To compile java 11 code using maven please use maven plugin with below configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
Follow steps are given below,
1) Run as Maven clean
2) Go to Project(top bar in eclipse) and clean it
3) Run as Maven install
(Sometimes need to clean twice in eclipse before run mvn install)
Hope this will help.
You are using the maven compiler plugin and it is a fight to use correct version compatibility between maven, JDK, and this plug-in.
In my case, reason of the issue was, I was using jdk-8u291-windows-x64 instead of jdk-8u211-windows-x64.

Getting org.apache.jorphan.logging.Slf4jLogkitLogger overrides final method error while using maven jmeter plugin 2.7.0

We have used Ultimate Thread group in our Jmeter test plan. Currently, we are looking to execute the test using maven jmeter plugin.
I am getting following error while trying to run jmeter test using jmeter-maven-plugin version 2.7.0:
[INFO] An error occurred: class org.apache.jorphan.logging.Slf4jLogkitLogger overrides final method log.(Lorg/apache/log/Priority;Ljava/lang/String;Ljava/lang/Throwable;)V
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.556 s
[INFO] Finished at: 2018-05-17T15:15:12-04:00
[INFO] Final Memory: 18M/437M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.lazerycode.jmeter:jmeter-maven-plugin:2.7.0:jmeter (test) on project chilapis: Test failed with exit code:1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.lazerycode.jmeter:jmeter-maven-plugin:2.7.0:jmeter (test) on project chilapis: Test failed with exit code:1
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:497)
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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Test failed with exit code:1
at com.lazerycode.jmeter.testrunner.TestManager.executeSingleTest(TestManager.java:179)
at com.lazerycode.jmeter.testrunner.TestManager.executeTests(TestManager.java:115)
at com.lazerycode.jmeter.mojo.RunJMeterMojo.doExecute(RunJMeterMojo.java:61)
at com.lazerycode.jmeter.mojo.AbstractJMeterMojo.execute(AbstractJMeterMojo.java:233)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] Shutdown detected, destroying JMeter process...
Following is my POM.xml file:
<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.honeywell.jmeter</groupId>
<artifactId>chilapis</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<!-- Default Properties for Project -->
<properties>
<jmeter.analysis.maven.plugin.version>1.0.6</jmeter.analysis.maven.plugin.version>
<jmeter-maven-plugin.version>2.7.0</jmeter-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
<profiles>
<!-- Profile to run -->
<profile>
<id>performance</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
</plugin>
<!-- execute JMeter test -->
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>${jmeter-maven-plugin.version}</version>
<executions>
<execution>
<id>test</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<jmeterVersion>3.3</jmeterVersion>
<testPlanLibraries>
<testPlanLibrary>org.slf4j:slf4j-api:1.7.25</testPlanLibrary>
</testPlanLibraries>
<!-- <downloadJMeterDependencies>false</downloadJMeterDependencies> -->
<!-- <downloadLibraryDependencies>false</downloadLibraryDependencies> -->
<excludedArtifacts>
<exclusion>commons-pool2:commons-pool2</exclusion>
<exclusion>commons-math3:commons-math3</exclusion>
<exclusion>org.slf4j:slf4j-api</exclusion>
<exclusion>org.slf4j:slf4j-ext</exclusion>
<!-- <exclusion>org.slf4j:slf4j-nop</exclusion> -->
<exclusion>logkit:logkit</exclusion>
<exclusion>org.apache.logging.log4j:log4j</exclusion>
<exclusion>org.apache.logging.log4j:log4j-slf4j-impl</exclusion>
</excludedArtifacts>
<jmeterExtensions>
<!-- <jmeterExtension>kg.apc:jmeter-plugins-cmn-jmeter:0.5</jmeterExtension>
<jmeterExtension>kg.apc:jmeter-plugins-graphs-additional:2.0</jmeterExtension>
<jmeterExtension>kg.apc:jmeter-plugins-synthesis:2.1</jmeterExtension> <jmeterExtension>kg.apc:jmeter-plugins-graphs-basic:2.0</jmeterExtension>
<jmeterExtension>kg.apc:jmeter-plugins-cmd:2.1</jmeterExtension> -->
<jmeterExtension>kg.apc:jmeter-plugins-casutg:2.5</jmeterExtension>
<!-- <jmeterExtension>kg.apc:cmdrunner:2.1</jmeterExtension> -->
</jmeterExtensions>
<remoteConfig>
<startAndStopServersForEachTest>true</startAndStopServersForEachTest>
<startServersBeforeTests>true</startServersBeforeTests>
<serverList>$serverlist</serverList>
<!-- <stopServersAfterTests>true</stopServersAfterTests> -->
</remoteConfig>
<resultsFileFormat>xml</resultsFileFormat>
<!-- <resultsFileFormat>csv</resultsFileFormat> -->
<customPropertiesFiles>
<customPropertiesFile>${project.basedir}/src/test/jmeter/custom.properties</customPropertiesFile>
</customPropertiesFiles>
<testFilesIncluded>
<jMeterTestFile>${testsToInclude}</jMeterTestFile>
</testFilesIncluded>
<ignoreResultFailures>true</ignoreResultFailures>
</configuration>
</plugin>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-analysis-maven-plugin</artifactId>
<version>${jmeter.analysis.maven.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>analyze</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
<configuration>
<!-- source file that contains jmeter result data. Needs to be XML
format or a GZIPed XML format -->
<source>${project.build.directory}/jmeter/results/*</source>
<!-- directory where to store analysis report files. At least a file
"summary.txt" will be stored here. -->
<targetDirectory>${project.build.directory}/reports</targetDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Please help in finding the issue in the above pom.xml file. It seems the jmeter jorphan jar is conflicting with other Slf4j jar files.
Thanks in advance.
Looking into your log message, it is not an error, it has INFO severity so you're looking into wrong place. The message is due to your test is using Custom Thread Groups which rely on previous logging subsystem (logkit) and since JMeter 3.2 SL4J and Log4j2 are being used.
[INFO] An error occurred: class org.apache.jorphan.logging.Slf4jLogkitLogger overrides final method log.(Lorg/apache/log/Priority;Ljava/lang/String;Ljava/lang/Throwable;)V
^^^^^^
Looking into JMeter Maven Plugin source code
if (jMeterExitCode != 0) {
throw new MojoExecutionException("Test failed with exit code:"+jMeterExitCode);
}
So your JMeter test simply fails (not because of logging). Check out jmeter.log file under target/jmeter/logs directory - most probably it contains the root cause of the problem in your test.

Maven build throws java.lang.ClassNotFoundException during tests performing [duplicate]

This question already has answers here:
JUnit 5 test case not executed
(2 answers)
Closed 5 years ago.
I have spring-boot project with integration tests. I'm trying to move to JDK 9. After some changes in pom I'm able to build (with tests skipped) and run project on java 9. But when I try to perform integration tests, I get an exception:
mvn clean install:
[ERROR] Please refer to pathToProject\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] java.lang.ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] java.lang.ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:673)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:832)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:955)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
My pom.xml 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>myProject</artifactId>
<version>0.1.4</version>
<packaging>jar</packaging>
<groupId>com.myProject</groupId>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<properties>
<java.version>1.9</java.version>
<!-- Dependency versions -->
<logback.version>1.1.7</logback.version>
<lombok.version>1.16.18</lombok.version>
<!-- Plugin versions-->
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.20.1</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.20.1</maven-failsafe-plugin.version>
<docker-maven-plugin.version>1.0.0</docker-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<!-- tests -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<jdkToolchain>
<version>9</version>
</jdkToolchain>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>--add-modules java.se.ee</argLine>
<argLine>--add-modules java.xml.bind</argLine>
<argLine>--add-modules java.xml.ws.annotation</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
</plugins>
</build>
</project>
Maven version: 3.5.2
All integration tests have the same configuration:
#RunWith(SpringRunner.class)
#SpringBootTest
#TestPropertySource(locations="classpath:application.properties")
public class SomeTest {
The problem was in maven-surefire-plugin version 2.20.1. It is not working for me even on JDK 8. After decreasing version to 2.18.1, it started to work fine.

Jacoco fails only on my system with strange error about StringUtils

Jacoco is giving me this error when trying to test my web service (I get it with any maven goal that includes the test phase):
$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Web Service 1.0
[INFO] ------------------------------------------------------------------------
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to C:\git\myproject\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\git\myproject\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) # myproject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\git\myproject\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) # myproject ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.4.201502262128:report (post-unit-test) # myproject ---
[WARNING] Error initializing: org.codehaus.plexus.velocity.DefaultVelocityComponent#1796b2d4
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:165)
at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:594)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:241)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:116)
at org.codehaus.plexus.velocity.DefaultVelocityComponent.initialize(DefaultVelocityComponent.java:95)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.initialize(PlexusLifecycleManager.java:303)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate(PlexusLifecycleManager.java:207)
at org.eclipse.sisu.bean.BeanScheduler$Pending.activate(BeanScheduler.java:156)
at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:185)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
at org.eclipse.sisu.inject.Guice4$1.get(Guice4.java:162)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:517)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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: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)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.152 s
[INFO] Finished at: 2016-12-06T09:19:16-06:00
[INFO] Final Memory: 24M/266M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:report (post-unit-test) on project myproject: Execution post-unit-test of goal org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:report failed: A required class was missing while executing org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:report: org/apache/commons/lang/StringUtils
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.jacoco:jacoco-maven-plugin:0.7.4.201502262128
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/t1572/.m2/repository/org/jacoco/jacoco-maven-plugin/0.7.4.201502262128/jacoco-maven-plugin-0.7.4.201502262128.jar
[ERROR] urls[1] = file:/C:/Users/t1572/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[2] = file:/C:/Users/t1572/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
[ERROR] urls[3] = file:/C:/Users/t1572/.m2/repository/junit/junit/4.8.2/junit-4.8.2.jar
[ERROR] urls[4] = file:/C:/Users/t1572/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
[ERROR] urls[5] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/shared/file-management/1.2.1/file-management-1.2.1.jar
[ERROR] urls[6] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/shared/maven-shared-io/1.1/maven-shared-io-1.1.jar
[ERROR] urls[7] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
[ERROR] urls[8] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
[ERROR] urls[9] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[ERROR] urls[10] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/reporting/maven-reporting-impl/2.1/maven-reporting-impl-2.1.jar
[ERROR] urls[11] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-core/1.1.2/doxia-core-1.1.2.jar
[ERROR] urls[12] = file:/C:/Users/t1572/.m2/repository/xerces/xercesImpl/2.8.1/xercesImpl-2.8.1.jar
[ERROR] urls[13] = file:/C:/Users/t1572/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
[ERROR] urls[14] = file:/C:/Users/t1572/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar
[ERROR] urls[15] = file:/C:/Users/t1572/.m2/repository/commons-codec/commons-codec/1.2/commons-codec-1.2.jar
[ERROR] urls[16] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-site-renderer/1.1.2/doxia-site-renderer-1.1.2.jar
[ERROR] urls[17] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-decoration-model/1.1.2/doxia-decoration-model-1.1.2.jar
[ERROR] urls[18] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-module-xhtml/1.1.2/doxia-module-xhtml-1.1.2.jar
[ERROR] urls[19] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-module-fml/1.1.2/doxia-module-fml-1.1.2.jar
[ERROR] urls[20] = file:/C:/Users/t1572/.m2/repository/org/codehaus/plexus/plexus-i18n/1.0-beta-7/plexus-i18n-1.0-beta-7.jar
[ERROR] urls[21] = file:/C:/Users/t1572/.m2/repository/org/codehaus/plexus/plexus-velocity/1.1.7/plexus-velocity-1.1.7.jar
[ERROR] urls[22] = file:/C:/Users/t1572/.m2/repository/org/apache/velocity/velocity/1.5/velocity-1.5.jar
[ERROR] urls[23] = file:/C:/Users/t1572/.m2/repository/commons-collections/commons-collections/3.2/commons-collections-3.2.jar
[ERROR] urls[24] = file:/C:/Users/t1572/.m2/repository/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0.jar
[ERROR] urls[25] = file:/C:/Users/t1572/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar
[ERROR] urls[26] = file:/C:/Users/t1572/.m2/repository/commons-digester/commons-digester/1.6/commons-digester-1.6.jar
[ERROR] urls[27] = file:/C:/Users/t1572/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar
[ERROR] urls[28] = file:/C:/Users/t1572/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar
[ERROR] urls[29] = file:/C:/Users/t1572/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[ERROR] urls[30] = file:/C:/Users/t1572/.m2/repository/org/jacoco/org.jacoco.agent/0.7.4.201502262128/org.jacoco.agent-0.7.4.201502262128-runtime.jar
[ERROR] urls[31] = file:/C:/Users/t1572/.m2/repository/org/jacoco/org.jacoco.core/0.7.4.201502262128/org.jacoco.core-0.7.4.201502262128.jar
[ERROR] urls[32] = file:/C:/Users/t1572/.m2/repository/org/ow2/asm/asm-debug-all/5.0.1/asm-debug-all-5.0.1.jar
[ERROR] urls[33] = file:/C:/Users/t1572/.m2/repository/org/jacoco/org.jacoco.report/0.7.4.201502262128/org.jacoco.report-0.7.4.201502262128.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
Just to be clear, I am not using StringUtils anywhere in my code, not even in my test code. My project builds and runs fine without it, if tests are skipped.
I've googled maven issues, jacoco issues, surefire issues, and tried all solutions I came across.
Here is what I tried:
Clean build, also deleting the whole target directory manually
Adding several different dependencies containing StringUtils to the pom (including the original commons-lang-2.6.jar and the new commons-lang3 library)
Deleting my .m2/repository/org/apache/maven directory to redownload all repository libraries
Comparing with my other projects that use similar test cases to find any possible difference that might cause this
Using different versions of surefire, failsafe, and surefire-report plugins
Adding <skipTests>true</skipTests> to both surefire and failsafe plugin configurations in the pom (some similar issues I read happened because test cases were being run twice)
Excluding various output directories using <exclude> tag in jacoco plugin configuration
Altering the source and target JDK versions in the maven compiler plugin configuration
Inserting the StringUtils.class directly into the jacoco pom in the appropriate directory matching the missing class name and package
Using different versions of the jacoco plugin
Installing and using a different version of Maven (tried both 3.1.1 and 3.3.9)
Switching to cobertura (I get a very similar error that differs only in the class it says is missing - org/apache/commons/lang/SystemUtils, rather than StringUtils)
I've been pulling my hair out over this for a whole day. I was able to have someone else test it and it worked fine on their system. I then copied their target directory onto my machine and was able to execute Sonar code analysis against the successful build results (jacoco.exec and the checked in code).
My question is, what is messed up on my system that is causing this?
I am running Windows 7 64-bit on a HP EliteDesk. Here 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.myproject.ws</groupId>
<artifactId>myproject</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>Web Service</name>
<url>http://maven.apache.org</url>
<properties>
<jacoco-maven-plugin.version>0.7.4.201502262128</jacoco-maven-plugin.version>
</properties>
<distributionManagement>
<repository>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<id>internal-repository</id>
<name>Nexus</name>
<url>http://repo.example.com/content/repositories/snapshots</url>
<layout>default</layout>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jdk-http</artifactId>
<version>2.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.net.httpserver</groupId>
<artifactId>http</artifactId>
<version>20070405</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<finalName>webservice</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<forkCount>2</forkCount>
<reuseForks>true</reuseForks>
<argLine>${argLine}</argLine>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<configuration>
<argLine>${argLine}</argLine>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/static/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${basedir}/target/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${basedir}/target/jacoco.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<tomcatLoggingFile>tomcat.log</tomcatLoggingFile>
<serverxml>${project.basedir}/target/tomcat/conf/web.xml</serverxml>
</configuration>
</plugin>
</plugins>
</build>
</project>
My test cases aren't anything special, they basically just send a sample POST request to each of the endpoints and verify that a result comes back.
Here is an example test case:
private CustomResponse executePostRequest()
{
MyPojo data = new MyPojo();
data.setId(0);
data.setRequestType("sometype");
data.setSomeField("value");
data.setSomeOtherField(5);
return target.path(endpoint).request().post(Entity.json(data), CustomResponse.class);
}
#Test
public void testEndpoint()
{
CustomResponse response = executePostRequest();
assertTrue( response.getCode() == 200 );
}
I'll be happy to post any other settings or whatever you might want to know about my system.
UPDATE: I just found out about jHades which is a tool to help you identify conflicting Jar resources when you run into jar-hell scenarios like this. I haven't tried it yet, but I plan to and will update the results here if it produces anything.
go to m2\repository\org\jacoco\jacoco-maven-plugin\0.7.4.201502262128
add this dependency in jacoco-maven-plugin-0.7.4.201502262128.pom:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>

Categories

Resources