Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-7548

currentThread.contextClassLoader does not include the Servlet bundle using http whiteboard

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.4.1
    • None
    • karaf

    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

      Attachments

        1. demo.zip
          8 kB
          Weichun Qian

        Activity

          People

            Unassigned Unassigned
            qianwch Weichun Qian
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: