Sounds like a bug to me. Pl. file an issue.
Reik Schatz wrote:
> I am using the servletContext.addServlet method that was added in
> Servlet 3.0 to dynamically add a new servlet. I wrote a
> ServletContextListener and in the contextInitialized method, I
> instantiate, initialize and add the Servlet. I expected that Glassfish
> would use this instance when serving requests mapped to the servlet.
> But this is not the case. Glassfish will create another instance
> instead. It looks like it does that when I request the URL path and a
> Thread is picked from the ThreadPool to handle the request. This is a
> bit unfortunate since the new instance lacks my manual initialization.
>
> Why does Glassfish instantiate another object when I call
> servletContext.addServlet(String, Servlet) with a pre-intantiated
> Servlet?
> /Reik
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>