When I reach this non-test code from a new unit test
Response.status(responseStatus).entity(response).build();
I am getting the following exception from a newly written unit test:
java.lang.AbstractMethodError: Receiver class org.apache.wink.common.internal.ResponseImpl$ResponseBuilderImpl does not define or inherit an implementation of the resolved method 'abstract javax.ws.rs.core.Response$ResponseBuilder status(int, java.lang.String)' of abstract class javax.ws.rs.core.Response$ResponseBuilder.
at javax.ws.rs.core.Response$ResponseBuilder.status(Response.java:921)
at javax.ws.rs.core.Response.status(Response.java:592)
at javax.ws.rs.core.Response.status(Response.java:603)
at c.i.c.riker.services.v3.resource.VendorWorkOrderV3Resource.rtsWorkOrderCreateMultipart(VendorWorkOrderV3Resource.java:947)
at c.i.c.riker.services.v3.resource.VendorWorkOrderV3ResourceUnitTest.testRtsWorkOrderCreateMultipart(VendorWorkOrderV3UnitTest.java:134)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:137)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:100)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Before creating the unit test, I have not seen this exception happen.
Not that Response
is javax.ws.rs.core.Response
and ResponseBuilder
is javax.ws.rs.core.Response.ResponseBuilder
, response
is a String
and responseStatus
is javax.ws.rs.core.Response.Status
Am using maven, and well as Mockito and JUnit 5 and Open Liberty server.
I am not sure how to proceed or what to try. I am expecting no exception to happen when I call this.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://raw.github.com/WASdev/ci.maven.tools/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<parent>
<groupId>com.ibm.cio.riker</groupId>
<artifactId>riker</artifactId>
<version>1.0.0</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>riker-services</artifactId>
<packaging>war</packaging>
<name>rikerServices</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>net.wasdev.maven.tools.targets</groupId>
<artifactId>liberty-target</artifactId>
<version>RELEASE</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.cio.riker</groupId>
<artifactId>riker-timer</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-api</artifactId>
<version>2.0</version>
</dependency>
<!-- newly added dependency -->
<dependency>
<groupId>com.ibm.cio.riker</groupId>
<artifactId>riker-common</artifactId>
<version>1.0.0</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
</dependencies>
<build>
<finalName>riker-services</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-package-config</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>../src/main/liberty/config</outputDirectory>
<resources>
<resource>
<directory>src/main/liberty/config</directory>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-package-war</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>../target</outputDirectory>
<resources>
<resource>
<directory>./target</directory>
<includes>
<include>riker-services.war</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<systemPropertyVariables>
<http.port>${liberty.var.default.http.port}</http.port>
<context.root>${liberty.var.default.contextroot}</context.root>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
</executions>
<configuration>
<target>2.2</target>
<sourceDestDir>${basedir}/src/main/java</sourceDestDir>
<wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
<wsdlLocation>/wsdl/wfoutbound.wsdl</wsdlLocation>
<executable>${env.WAS_HOME}/bin/jaxws/wsimport</executable>
<packageName>com.ibm.cio.riker.dao.wsdl</packageName>
<keep>true</keep>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
ResponseBuilder.status(int, String) was added in JAX-RS 2.1. In Liberty, Apache Wink is used for the JAX-RS 1.1 implementation. So it would appear there is a mismatch between the API level you are testing with (2.1) and the implementation used (1.1). If you want to test with JAX-RS 2.1, you will need to switch to the jaxrs-2.1
feature in your server.xml, otherwise you will need to use the 1.1 API for your JUnit / Mockito testing.
To give additional details, you would look at your src/main/liberty/config
directory to look at how your Liberty server is configure. Otherwise it would be good to know what your application (I believe it is riker-services.war) is using for Java EE levels. You would want to have those sync'ed up to have the EE levels match between the two.
I hope that helps.
Jared Anderson
Update:
The problem ended up being that the sever.xml was using jaxrs-2.1 in it and with:
<dependency>
<groupId>net.wasdev.maven.tools.targets</groupId>
<artifactId>liberty-target</artifactId>
<version>RELEASE</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
Apache Wink is getting added. That dependency is EE 6 based and should not be used with Jakarta EE 8 features.