I'm trying to get Undertow working in a Java App but I'm having some issues with dependencies. Everything is compiling ok but every time I try to run I am getting the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: org/xnio/ChannelListener
I'm not using maven but I downloaded the following Undertow jars from the link off of the Undertow site.
undertow-core-2.2.13.Final.jar
undertow-servlet-2.2.13.Final.jar
undertow-websockets-jsr-2.2.13.Final.jar
The code is pretty much the same as the example given on the Undertow site and I can't find very much mention of the specific dependencies. I'm sure I'm missing something
import java.util.*;
import java.io.*;
import io.undertow.*;
import io.undertow.server.*;
import io.undertow.util.*;
public class TestingUndertow {
public static void main(String[] args) {
Undertow server = (
Undertow
.builder()
.addHttpListener(31, "0.0.0.0")
.setHandler(new HttpHandler() {
public void handleRequest(final HttpServerExchange exchange) throws Exception {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("Nothing");
}
})
.build()
);
server.start();
}
}
It turns out I was missing many dependencies, these were all needed for it to work
If this can help anyone else who has dependency issues like me, I found this site really helpful https://javalibs.com/
You can search for a module and it will let you know all of the dependencies for that module so you can know to download them too (or just use maven really)