On 18/02/2021 10:46, aghart...@gmail.com wrote: > Hi all, > > A question, I can't solve that.... > > Tested with Tomcat 9.0.41, java 8 x64, linux (Fedora 32). > > > I have a standard tomcat web.xml (3.0 or 3.1, no matter). > > I have created an external simple servlet with @WebServlet annotation, > and packaged it to a jar file:
Name of the JAR file? Package the Servlet has been placed in? Standard Tomcat downloaded from the ASF or one provided by your package manager? Have you tried enabling debug logging for org.apache.tomcat.util.scan.StandardJarScanner ? Mark > > > @WebServlet(name = "TestServlet", urlPatterns = {"/TestServlet"}, > loadOnStartup = 1) > public class TestServlet extends HttpServlet { > > private static final Logger log = > Logger.getLogger(TestServlet.class.getName()); > > private static final long serialVersionUID = 1L; > > @Override > public void init() throws ServletException { > log.setLevel(Level.ALL); > log.log(Level.WARNING, "TESTSERVLET INIT"); > super.init(); > } > > @Override > public void destroy() { > } > > @Override > protected void doGet(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > processRequest(req, resp); > } > > protected void processRequest(HttpServletRequest request, > HttpServletResponse response) > throws ServletException, IOException { > response.setContentType("text/html;charset=UTF-8"); > PrintWriter out = response.getWriter(); > > try { > out.println("<!DOCTYPE html>"); > out.println("<html>"); > out.println("<head>"); > out.println("<title>Servlet TestServlet</title>"); > out.println("</head>"); > out.println("<body>"); > out.println("<h1>Servlet TestServlet at " + > request.getContextPath() + "</h1>"); > > out.println("</body>"); > out.println("</html>"); > } finally { > out.close(); > } > } > > } > > > So, if I copy the .jar file inside WEB-INF/lib folder of destination war > project the log message will appears and the servlet is reachable. > > But, if I copy the .jar file inside tomcat/lib folder the annotation > won't be processed. > > > FYI, in tomcat 7 both cases (inside WEB-INF/lib and tomcat/lib) works well. > > > I searched on breaking changes between tomcat 7 and 8/8.5/9 but nope. > Seems related to jarscanner.....but no luck! > > > Because my servlet is in common to all projects I want to put it inside > tomcat/lib folder and share it to all my projects > > > Somebody can help me? > > > Many thanks, > > Agharta > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org