Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

Sevlets with @WebServlet annotation in JAR files not accessible (wildfly 26.1.3.Final)

$
0
0

I have a project where I need to include some servlets. For some reasons the customer wants a JAR file not a WAR file. After a few days research I was unable to find a solution to make wildfly's servlet container load the servlets annotated with @WebServlet from JAR file (@WebServlets from WAR file are working great but we can't deploy WAR file).Is there a way how to make the servlets working from jar file?

My server is WildFly 26.1.3.Final with servlets version 4.0

import java.io.IOException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;@WebServlet(name = "hello", urlPatterns = {"/hello"})public class Web extends HttpServlet {    @Override    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {        resp.setContentType("text/html");        resp.getWriter().println("<html><head><title>hello</title></head><body>");        resp.getWriter().println("<h1>Hello World!</h1>");        resp.getWriter().println("</body></html>");        resp.getWriter().close();    }}

I expected that the servlet container will start the web context and load the servlet with the annotation.


Viewing all articles
Browse latest Browse all 675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>