dev@glassfish.java.net

Re: addServlet question (glassfish v3)

From: Reik Schatz <reik.schatz_at_bwin.org>
Date: Tue, 23 Jun 2009 11:28:33 +0200

I am running 3.0-47.4, i wrote a very basic web application with only 1
ServletContextListener and 1 WebServlet to reproduce the problem, but
now it won't even let me access my dynamically added servlet at all.
Gonna look into this later, weird. Anyway, do you know from the top of
your head, if this will works in a later v3 version (after 3.0-47.4)?
What credentials are required to access the unit test?

/Reik

Jan Luehe wrote:
> On 06/15/09 10:26 AM, Sahoo wrote:
>> Sounds like a bug to me. Pl. file an issue.
>
> I'm unable to reproduce the issue with the latest build.
> Reik, which version of GlassFish are you using?
>
> There may have been an issue in the past, but it has been fixed
> in the meantime.
>
> We actually have a unit test for this very feature, see
>
> https://svn.dev.java.net/svn/glassfish-svn/trunk/v2/appserv-tests/devtests/web/servlet-3.0/servletContextAddServletAndFilterByInstance
>
>
> which instantiates, configures, and registers a servlet, and then
> checks to make sure
> that the custom configuration is available when the servlet is accessed.
>
>
> Jan
>
>
>> 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
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>

-- 
*Reik Schatz*
Technical Lead, Platform
P: +46 8 562 470 00
M: +46 76 25 29 872
F: +46 8 562 470 01
E: reik.schatz_at_bwin.org <mailto:reik.schatz_at_bwin.org>
*/bwin/* Games AB
Klarabergsviadukten 82,
111 64 Stockholm, Sweden
[This e-mail may contain confidential and/or privileged information. If 
you are not the intended recipient (or have received this e-mail in 
error) please notify the sender immediately and destroy this e-mail. Any 
unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.]