Reputation: 706
I am setting up a back-end test using Java. When running my test I am presented with the following error:
java.lang.NoSuchMethodError: io.netty.util.internal.PlatformDependent.allocateUninitializedArray(I)[B
My pom file contains the following dependencies in regard to Netty:
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>4.1.36.Final</version>
</dependency>
My code itself looks as follows:
import cucumber.api.java.en.And;
import org.mockserver.client.MockServerClient;
import org.mockserver.matchers.Times;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class PdfGenerateStep {
@Autowired
private MockServerClient mockServerClient;
@And("Pdf {string} is generated")
public void generatePDF(String pdfFile) {
HttpRequest httpRequest = new HttpRequest();
httpRequest.withPath("/pdf-service/doc/request")
.withHeader("template", "TEST")
.withHeader("docFormat", "pdf")
.withHeader("fromParty", "PDFGEN")
.withHeader("APPLICATION", "App")
.withMethod("POST");
HttpResponse httpResponse = new HttpResponse();
httpResponse.withStatusCode(200);
httpResponse.withBody(readPdfFile(pdfFile));
mockServerClient.when(httpRequest, Times.once()).respond(httpResponse);
}
private byte[] readPdfFile(String file) {
try {
Path path = Paths.get(getClass().getClassLoader().getResource(file).toURI());
return Files.readAllBytes(path);
} catch (URISyntaxException | IOException e) {
e.printStackTrace();
}
return null;
}
}
Upvotes: 2
Views: 8367
Reputation: 1013
<dependency>
<groupId>com.corundumstudio.socketio</groupId>
<artifactId>netty-socketio</artifactId>
<version>1.7.13</version>
</dependency>
add this dependency in your pom.xml file.
Upvotes: 1
Reputation: 1513
There is no allocateUninitializedArray method in io.netty.util.internal.PlatformDependent class, so in your classpath there is an another jar that contains this class, but the version, and therefore the code of this class will be different.
The io.netty.util.internal.PlatformDependent class can be found in netty-common, which is a transitive dependency of netty-transport.
So, check the dependency tree of your project. Very probably you have an another dependency that has a different version of netty-common as a transitive dependency. Exclude the wrong one and you will be done.
Upvotes: 3