You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wink.apache.org by "David Calavera (JIRA)" <ji...@apache.org> on 2010/06/04 11:32:56 UTC

[jira] Created: (WINK-290) DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor

DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor
---------------------------------------------------------------------------------------------------------

                 Key: WINK-290
                 URL: https://issues.apache.org/jira/browse/WINK-290
             Project: Wink
          Issue Type: Bug
          Components: Server
    Affects Versions: 1.1.1
            Reporter: David Calavera


Hi,

I just bumped into this problem, seems the RestServlet doesn't initialize the DeploymentConfiguration properly and the servletContext and servletConfig are not set when the RequestProcessor is not created by the servlet.

When I call context.getAttribute(ServletContext.class); from a userHandler the servletContext is null, it's also null if I call context.getAttribute(DeploymentConfiguration.class).getServletContext();

Seems the servlet doesn't call getDeploymentConfiguration in some cases. To expose the bug I instanced an embedded jetty and overloaded the servlet, this is the code I'm using it:

{code}
Server server = new Server(9009);
Context contextHandler = new Context(server, "/api", Context.SESSIONS);

contextHandler.addEventListener(new ContextLoaderListener());

        ServletHolder servletHolder = new ServletHolder(new RestServlet()
        {
            @Override
            public void init() throws ServletException
            {
                super.init();
                System.err.println("SERVLET CONTEXT !!!!!!!! " + this.getServletContext());
                System.err.println("CONFIGURATION SERVLET CONTEXT !!! "
                    + this.getRequestProcessor().getConfiguration().getServletContext());
            }
        });
        contextHandler.addServlet(servletHolder, "/*");
{code}

When the method init is called I get this output:

{noformat}
SERVLET CONTEXT !!!!!!!! ServletContext@675926d1{/api,null}
CONFIGURATION SERVLET CONTEXT !!! null
{noformat}

I'm including a patch and test cases to solve this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WINK-290) DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor

Posted by "David Calavera (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Calavera updated WINK-290:
--------------------------------

    Attachment: WINK-290.patch

Please, could you fix this bug for wink 1.1.1?

> DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: WINK-290
>                 URL: https://issues.apache.org/jira/browse/WINK-290
>             Project: Wink
>          Issue Type: Bug
>          Components: Server
>    Affects Versions: 1.1.1
>            Reporter: David Calavera
>         Attachments: WINK-290.patch
>
>
> Hi,
> I just bumped into this problem, seems the RestServlet doesn't initialize the DeploymentConfiguration properly and the servletContext and servletConfig are not set when the RequestProcessor is not created by the servlet.
> When I call context.getAttribute(ServletContext.class); from a userHandler the servletContext is null, it's also null if I call context.getAttribute(DeploymentConfiguration.class).getServletContext();
> Seems the servlet doesn't call getDeploymentConfiguration in some cases. To expose the bug I instanced an embedded jetty and overloaded the servlet, this is the code I'm using it:
> {code}
> Server server = new Server(9009);
> Context contextHandler = new Context(server, "/api", Context.SESSIONS);
> contextHandler.addEventListener(new ContextLoaderListener());
>         ServletHolder servletHolder = new ServletHolder(new RestServlet()
>         {
>             @Override
>             public void init() throws ServletException
>             {
>                 super.init();
>                 System.err.println("SERVLET CONTEXT !!!!!!!! " + this.getServletContext());
>                 System.err.println("CONFIGURATION SERVLET CONTEXT !!! "
>                     + this.getRequestProcessor().getConfiguration().getServletContext());
>             }
>         });
>         contextHandler.addServlet(servletHolder, "/*");
> {code}
> When the method init is called I get this output:
> {noformat}
> SERVLET CONTEXT !!!!!!!! ServletContext@675926d1{/api,null}
> CONFIGURATION SERVLET CONTEXT !!! null
> {noformat}
> I'm including a patch and test cases to solve this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-290) DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12876109#action_12876109 ] 

Hudson commented on WINK-290:
-----------------------------

Integrated in Wink-Trunk-JDK1.5 #344 (See [http://hudson.zones.apache.org/hudson/job/Wink-Trunk-JDK1.5/344/])
    Set ServletContext/Config is not set

See [WINK-290]

Thanks to David Calavera for the suggestion.


> DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: WINK-290
>                 URL: https://issues.apache.org/jira/browse/WINK-290
>             Project: Wink
>          Issue Type: Bug
>          Components: Server
>    Affects Versions: 1.1.1
>            Reporter: David Calavera
>            Assignee: Bryant Luk
>             Fix For: 1.1.1
>
>         Attachments: WINK-290.patch
>
>
> Hi,
> I just bumped into this problem, seems the RestServlet doesn't initialize the DeploymentConfiguration properly and the servletContext and servletConfig are not set when the RequestProcessor is not created by the servlet.
> When I call context.getAttribute(ServletContext.class); from a userHandler the servletContext is null, it's also null if I call context.getAttribute(DeploymentConfiguration.class).getServletContext();
> Seems the servlet doesn't call getDeploymentConfiguration in some cases. To expose the bug I instanced an embedded jetty and overloaded the servlet, this is the code I'm using it:
> {code}
> Server server = new Server(9009);
> Context contextHandler = new Context(server, "/api", Context.SESSIONS);
> contextHandler.addEventListener(new ContextLoaderListener());
>         ServletHolder servletHolder = new ServletHolder(new RestServlet()
>         {
>             @Override
>             public void init() throws ServletException
>             {
>                 super.init();
>                 System.err.println("SERVLET CONTEXT !!!!!!!! " + this.getServletContext());
>                 System.err.println("CONFIGURATION SERVLET CONTEXT !!! "
>                     + this.getRequestProcessor().getConfiguration().getServletContext());
>             }
>         });
>         contextHandler.addServlet(servletHolder, "/*");
> {code}
> When the method init is called I get this output:
> {noformat}
> SERVLET CONTEXT !!!!!!!! ServletContext@675926d1{/api,null}
> CONFIGURATION SERVLET CONTEXT !!! null
> {noformat}
> I'm including a patch and test cases to solve this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WINK-290) DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryant Luk resolved WINK-290.
-----------------------------

         Assignee: Bryant Luk
    Fix Version/s: 1.1.1
       Resolution: Fixed

I added some slightly different code to set the ServletContext and ServletConfig if it wasn't already set in the DeploymentConfiguration.  I think this achieves the same effect but won't override a previously set ServletContext/ServletConfig (in cases where someone returns a decorated ServletConfig for instance).

If you also don't mind, can you give a hint on why you're creating your own request processor?

Thanks for the feedback/patch.

> DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: WINK-290
>                 URL: https://issues.apache.org/jira/browse/WINK-290
>             Project: Wink
>          Issue Type: Bug
>          Components: Server
>    Affects Versions: 1.1.1
>            Reporter: David Calavera
>            Assignee: Bryant Luk
>             Fix For: 1.1.1
>
>         Attachments: WINK-290.patch
>
>
> Hi,
> I just bumped into this problem, seems the RestServlet doesn't initialize the DeploymentConfiguration properly and the servletContext and servletConfig are not set when the RequestProcessor is not created by the servlet.
> When I call context.getAttribute(ServletContext.class); from a userHandler the servletContext is null, it's also null if I call context.getAttribute(DeploymentConfiguration.class).getServletContext();
> Seems the servlet doesn't call getDeploymentConfiguration in some cases. To expose the bug I instanced an embedded jetty and overloaded the servlet, this is the code I'm using it:
> {code}
> Server server = new Server(9009);
> Context contextHandler = new Context(server, "/api", Context.SESSIONS);
> contextHandler.addEventListener(new ContextLoaderListener());
>         ServletHolder servletHolder = new ServletHolder(new RestServlet()
>         {
>             @Override
>             public void init() throws ServletException
>             {
>                 super.init();
>                 System.err.println("SERVLET CONTEXT !!!!!!!! " + this.getServletContext());
>                 System.err.println("CONFIGURATION SERVLET CONTEXT !!! "
>                     + this.getRequestProcessor().getConfiguration().getServletContext());
>             }
>         });
>         contextHandler.addServlet(servletHolder, "/*");
> {code}
> When the method init is called I get this output:
> {noformat}
> SERVLET CONTEXT !!!!!!!! ServletContext@675926d1{/api,null}
> CONFIGURATION SERVLET CONTEXT !!! null
> {noformat}
> I'm including a patch and test cases to solve this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-290) DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor

Posted by "David Calavera (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12876143#action_12876143 ] 

David Calavera commented on WINK-290:
-------------------------------------

I'm not creating my own processor, I'm using the spring extension that creates it's own and I needed to access to the spring context into a request handler, so I needed the servlet context to get it but it was null. That's how I bumped into this.

> DeploymentConfiguration is not propertly initialized when the servlet doesn't create the RequestProcessor
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: WINK-290
>                 URL: https://issues.apache.org/jira/browse/WINK-290
>             Project: Wink
>          Issue Type: Bug
>          Components: Server
>    Affects Versions: 1.1.1
>            Reporter: David Calavera
>            Assignee: Bryant Luk
>             Fix For: 1.1.1
>
>         Attachments: WINK-290.patch
>
>
> Hi,
> I just bumped into this problem, seems the RestServlet doesn't initialize the DeploymentConfiguration properly and the servletContext and servletConfig are not set when the RequestProcessor is not created by the servlet.
> When I call context.getAttribute(ServletContext.class); from a userHandler the servletContext is null, it's also null if I call context.getAttribute(DeploymentConfiguration.class).getServletContext();
> Seems the servlet doesn't call getDeploymentConfiguration in some cases. To expose the bug I instanced an embedded jetty and overloaded the servlet, this is the code I'm using it:
> {code}
> Server server = new Server(9009);
> Context contextHandler = new Context(server, "/api", Context.SESSIONS);
> contextHandler.addEventListener(new ContextLoaderListener());
>         ServletHolder servletHolder = new ServletHolder(new RestServlet()
>         {
>             @Override
>             public void init() throws ServletException
>             {
>                 super.init();
>                 System.err.println("SERVLET CONTEXT !!!!!!!! " + this.getServletContext());
>                 System.err.println("CONFIGURATION SERVLET CONTEXT !!! "
>                     + this.getRequestProcessor().getConfiguration().getServletContext());
>             }
>         });
>         contextHandler.addServlet(servletHolder, "/*");
> {code}
> When the method init is called I get this output:
> {noformat}
> SERVLET CONTEXT !!!!!!!! ServletContext@675926d1{/api,null}
> CONFIGURATION SERVLET CONTEXT !!! null
> {noformat}
> I'm including a patch and test cases to solve this problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.