Could someone tell me why using the following code:
Undertow server = Undertow.builder()
.addHttpListener(8080, "0.0.0.0")
.setHandler(path().addPrefixPath("/",
resource(new ClassPathResourceManager(
HelloWorldServer.class.getClassLoader()))
.addWelcomeFiles("index.html")))
.build();
server.start();
would then give you a blank page when going to the URL
http://localhost:8080
but works correctly for the URL http://localhost:8080/index.html
I was under the impression that the PrefixPath of "/" should redirect all default requests to the welcome file you define but that doesn't appear to be the case. Note: the index.html file is embedded in the jar file on the root path. Verified it's there and can extract it from the ClassPathResourceManager.
I have also tried to define a different PrefixPath other than "/" but the welcome file never gets triggered by default. I always have to define it in the URL. Much appreciate some help in my understanding!
It turns out that my classpath was not correct. A false assumption was made that the location of my jar files was automatically added to my classpath, when in fact NetBeans builds the default classpath with just the specific jar files rather than locations. Solution was to add the location of my html files to the classpath in my build.gradle file and all is well.