Chris
Chris

Reputation: 565

Tomcat not serving static files

I'm at the end of my rope on this one. I'm try to get a super simple webapp up and I can't seem to get tomcat to not 404 static files.

So I thought this setup would map localhost:8080/hey-world/static/index.html to the file, but it 404's everytime. Is this a problem with some convention in the gradle tomcat plugin?

Upvotes: 4

Views: 12539

Answers (1)

Harald K
Harald K

Reputation: 27113

The URL-patterns used in web.xml/servlet-mapping is often a little simplistic. I think in your case, the /* pattern for Resteasy will work as a catch-all, so that no other mapping will really matter.

For debugging, I suggest you remove the Resteasy-servlet altogether, and see if you can serve static files from a custom URL with your mapping. If that works, re-enable Resteasy, but on a different URL-pattern (eg. /rest/*).

If that works, well, then everything really works fine, it's just that the URL-mapping for /* blocks anything else from working.

The easiest solution would probably be to server static files as per default (no mapping), and serve rest-stuff from another URL.

Alternatively use two web apps. One with context root /static, one with context root /.

Upvotes: 5

Related Questions