The servlets are on your server's classpath rather than packaged in a WAR.
Servlet 3.0 specification states:
In a web application, classes using annotations will have their
annotations processed only if they are located in the
WEB-INF/classes
directory, or if they are packaged in a jar file
located in WEB-INF/lib
within the application.
The web application deployment descriptor contains a new
“metadata-complete
” attribute on the web-app element. The
“metadata-complete
” attribute defines whether the web descriptor is
complete, or whether the class files of the jar file should be
examined for annotations and web fragments at deployment time. If
“metadata-complete
” is set to "true
", the deployment tool MUST
ignore any servlet annotations present in the class files of the
application and web fragments. If the metadata-complete attribute is
not specified or is set to "false", the deployment tool must examine
the class files of the application for annotations, and scan for web
fragments.
You may have to look at packaging a WAR and using a context with more features like WebAppContext
.
Alternatively, you might try your own annotation scanning. Something of the form:
void registerServlets(ServletContextHandler context,
Class<? extends HttpServlet> type)
throws InstantiationException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException {
WebServlet info = type.getAnnotation(WebServlet.class);
for (String pattern : info.urlPatterns()) {
HttpServlet servlet = type.getConstructor().newInstance();
context.addServlet(new ServletHolder(servlet), pattern);
}
}