[undertow-dev] serving static files
Matthias Wessendorf
matzew at redhat.com
Mon Feb 3 03:38:04 EST 2014
Hello Stuart,
I pushed my test to github. the 'main' is located here:
https://github.com/matzew/undertow-jaxrs-test/blob/master/src/main/java/net/wessendorf/undertow/App.java
When I run that and I am accessing "http://localhost:8080/status", all is fine, my 'StatusEndpoint' JAX-RS resource is executed and I get my response;
However, when I am hitting "http://localhost:8080" am getting 404 in the browser, and the following on the console in my IDE:
Feb 03, 2014 9:26:04 AM org.jboss.resteasy.core.ExceptionHandler
SEVERE: failed to execute
javax.ws.rs.NotFoundException: Could not find resource for full path: http://localhost:8080/
at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:73)
at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
at io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:168)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:687)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
So, looks like the JAX-RS is somewhat having an effect on the actual "FileResourceManager" that should serve my static files
-Matthias
----- Original Message -----
> From: "Stuart Douglas" <sdouglas at redhat.com>
> To: "Matthias Wessendorf" <matzew at redhat.com>
> Cc: undertow-dev at lists.jboss.org
> Sent: Monday, February 3, 2014 8:39:08 AM
> Subject: Re: [undertow-dev] serving static files
>
> What does the rest of your code look like? And when you say it does not work,
> what sort of failure are you getting? A 404?
>
> Stuart
>
> ----- Original Message -----
> > From: "Matthias Wessendorf" <matzew at redhat.com>
> > To: "Stuart Douglas" <sdouglas at redhat.com>
> > Cc: undertow-dev at lists.jboss.org
> > Sent: Monday, 3 February, 2014 8:39:11 AM
> > Subject: Re: [undertow-dev] serving static files
> >
> > HEllo,
> >
> > that works fine - however trying the same in my 'test': does not work :-/
> >
> >
> > UndertowJaxrsServer ut = new UndertowJaxrsServer();
> >
> > TestApplication ta = new TestApplication();
> >
> > ut.deploy(ta);
> >
> > ut.start(
> > Undertow.builder()
> > .addHttpListener(8080, "localhost")
> > .setHandler(resource(new FileResourceManager(new
> > File(System.getProperty("user.home")), 100))
> > .setDirectoryListingEnabled(true))
> >
> >
> > );
> >
> > try {
> > Thread.currentThread().join();
> > }
> > catch (InterruptedException e) {
> > logger.info("shutting down");
> > ut.stop();
> > }
> >
> >
> >
> >
> > -Matthias
> >
> >
> >
> >
> > ----- Original Message -----
> > > From: "Stuart Douglas" <sdouglas at redhat.com>
> > > To: "Matthias Wessendorf" <matzew at redhat.com>
> > > Cc: undertow-dev at lists.jboss.org
> > > Sent: Sunday, February 2, 2014 6:37:59 PM
> > > Subject: Re: [undertow-dev] serving static files
> > >
> > > I just added a file serving example to the Undertow examples, can you try
> > > that out and let me know if it works for you?
> > >
> > > Just get the latest Undertow, build the examples, then run:
> > >
> > > mvn exec:exec
> > >
> > > And select the file serving one, it should serve up you home directory.
> > >
> > > Stuart
> > >
> > > ----- Original Message -----
> > > > From: "Matthias Wessendorf" <matzew at redhat.com>
> > > > To: undertow-dev at lists.jboss.org
> > > > Sent: Sunday, 2 February, 2014 1:58:14 PM
> > > > Subject: [undertow-dev] serving static files
> > > >
> > > > Hello,
> > > >
> > > > I might be just doing it wrong, but the following attempts are not
> > > > successful
> > > > for serving static files from a folder:
> > > >
> > > >
> > > > UndertowJaxrsServer ut = new UndertowJaxrsServer();
> > > >
> > > > MyRestApplication app = new MyRestApplication();
> > > >
> > > > ut.deploy(app);
> > > >
> > > > ut.start(
> > > > Undertow.builder()
> > > > .addHttpListener(8080, "0.0.0.0")
> > > >
> > > >
> > > > // first tried this:
> > > > .setHandler(path()
> > > > .addPrefixPath("/",resource(new
> > > > FileResourceManager(new
> > > > File("/some/folder/containing/html/files"),
> > > > 1024))))
> > > >
> > > >
> > > > // afterwards also tried this:
> > > > .setHandler(resource(new
> > > > FileResourceManager(new
> > > > File("/some/folder/containing/html/files"),
> > > > 1024)))
> > > > );
> > > >
> > > > try {
> > > > Thread.currentThread().join();
> > > > }
> > > > catch (InterruptedException e) {
> > > > logger.info("shutting down");
> > > > ut.stop();
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > > Not sure, but none of the above handlers seems to server files from a
> > > > folder
> > > > on my box
> > > >
> > > >
> > > > Greetings,
> > > > Matthias
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Matthias Wessendorf
> > > > matzew at redhat.com
> > > >
> > > > JBoss, by Red Hat
> > > > _______________________________________________
> > > > undertow-dev mailing list
> > > > undertow-dev at lists.jboss.org
> > > > https://lists.jboss.org/mailman/listinfo/undertow-dev
> > > >
> > >
> >
> > --
> > Matthias Wessendorf
> > matzew at redhat.com
> >
> > JBoss, by Red Hat
> >
>
--
Matthias Wessendorf
matzew at redhat.com
JBoss, by Red Hat
More information about the undertow-dev
mailing list