I am using the @WebServlet
annotation in my app, like so:
@WebServlet("/tokenize")
public class TokenizerServlet extends HttpServlet {
...
}
This does not work in the "J2EE Preview at localhost" within Eclipse. Any request to http://localhost:8080/myApp/tokenizer
returns a 404. When mapped from the web.xml
, this same URL works fine.
However, when the app is deployed (to Azure, in my case), it does work. So the problem isn't in the code or the config, it's something to do with the preview server in Eclipse.
How do I need to configure the preview server to respect my annotation? I've looked everywhere, and there doesn't seem to be much config to speak of. The root element of my web.xml
looks like this:
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
Under the "J2EE Preview" node in the project, I have this:
UPDATE --
I never got a solution to this, but I found it so easy to run Tomcat locally, that I just started doing that instead. I'm leaving this question here in case anyone else has the same problem, just so you know you're not alone, and perhaps someone will provide an answer at some point.