Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
4.4.1
-
None
Description
Registering the servlet to http whiteboard:
Dictionary<String, String> props = new Hashtable<>(); props.put(HTTP_WHITEBOARD_SERVLET_PATTERN, "/hello"); props.put(HTTP_WHITEBOARD_SERVLET_NAME, "helloservlet"); props.put(HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED, "true"); props.put(HTTP_WHITEBOARD_CONTEXT_SELECT, String.format("(osgi.http.whiteboard.context.name=%s)", "default")); context.registerService(Servlet.class, new MyServlet(), props);
The following code will get an exception.
public class MyServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().println("<h1>it worked</h1>"); try { Thread.currentThread().getContextClassLoader().loadClass(MyServlet.class.getName()); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } }
The demo project is here.demo.zip