tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Dale <jcdw...@gmail.com>
Subject Re: unable to serve static files with embedded Tomcat
Date Fri, 19 Apr 2019 19:28:15 GMT
Tomcat doesn't seem to timeout one its own unless my DBCP is being
abused in the code.

I'm thinking firewall .. also, double-check your port configuration(s)
in server.xml (or context.xml if that's the route you're going).

On 4/19/19, Garret Wilson <garret@globalmentor.com> wrote:
> Embedding Tomcat 9 (with OpenJDK 11 on Windows 10) I want to serve
> static files from `/foo/bar`. From scouring the web (primarily
> https://stackoverflow.com/a/15235711/421049 ), the documentation, and
> some books (primarily _Apache Tomcat 7_), I have this:
>
>      Tomcat tomcat = new Tomcat();
>      tomcat.setPort(8080);
>      tomcat.setBaseDir("/foo");
>      Context ctx = tomcat.addContext("", "/foo/bar");
>      final Wrapper defaultServlet = ctx.createWrapper();
>      defaultServlet.setName("default");
> defaultServlet.setServletClass("org.apache.catalina.servlets.DefaultServlet");
>      defaultServlet.addInitParameter("debug", "1");
>      defaultServlet.addInitParameter("listings", "false");
>      defaultServlet.setLoadOnStartup(1);
>      ctx.addChild(defaultServlet);
>      ctx.addServletMappingDecoded("/", "default");
>      ctx.addWelcomeFile("index.html");
>      tomcat.start();
>      tomcat.getServer().await();
>
> Everything looks like it starts up:
>
>      Apr 19, 2019 2:18:09 PM org.apache.catalina.core.StandardService
> startInternal
>      INFO: Starting service [Tomcat]
>      Apr 19, 2019 2:18:09 PM org.apache.catalina.core.StandardEngine
> startInternal
>      INFO: Starting Servlet engine: [Apache Tomcat/9.0.19]
>      Apr 19, 2019 2:18:10 PM
> org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
>      WARNING: Creation of SecureRandom instance for session ID
> generation using [SHA1PRNG] took [281] milliseconds.
>      Apr 19, 2019 2:18:10 PM org.apache.catalina.core.ApplicationContext
> log
>      INFO: default: DefaultServlet.init:  input buffer size=2048, output
> buffer size=2048
>
> But connections to http://localhost:8080/ time out. (I'm pretty sure but
> not positive that I don't have anything blocking this in the firewall.)
>
> Is there some simple thing I'm missing to connect things together?
>
> Thanks,
>
> Garret
>
> P.S. The documentation on the web for the details of this is
> surprisingly sparse.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message