Teresa D Stone | 4 Oct 2010 02:15
Favicon

"Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

I just got my application configured to use DWR version 2.0.3.  I am using reverse ajax.  I am getting the following error in the console...
Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.
- To prevent this message from happening, either call the PageNormalizer from a DWR Thread
- Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread

I have read the section on the NON-Web Threads and Reverse Ajax (http://directwebremoting.org/dwr/reverse-ajax/threads.html) but the link to the example is not working...And I am not clear as to how to resolve the issue.

____
I have a ProductResizeTracker class implements ProductResizeListener class -  the constructor does the following:

WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);

I have a home page called tabbed-home.jsp that onload calls dwr.engine.setActiveReverseAjax(true);

I have a js function called "function updateProductResize(product){alert("product resized!")}"

HOW do I resolve this issue?

Teresa Stone
Raytheon IIS
Sr Software Engineer
Cell 903.356.6097
Work 972.205.4629
David Marginian | 4 Oct 2010 03:09

Re: "Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

There is nothing additional in Publisher, I need to remove that link thanks.

public Publisher()
    {
        WebContext webContext = WebContextFactory.get();
        ServletContext servletContext = webContext.getServletContext();

        serverContext = ServerContextFactory.get(servletContext);

        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

        synchronized (Publisher.class)
        {
            if (worker == null)
            {
                worker = new Thread(this, "Publisher");
                worker.start();
            }
        }
    }



On 10/3/2010 6:15 PM, Teresa D Stone wrote:
I just got my application configured to use DWR version 2.0.3.  I am using reverse ajax.  I am getting the following error in the console...
Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.
- To prevent this message from happening, either call the PageNormalizer from a DWR Thread
- Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread

I have read the section on the NON-Web Threads and Reverse Ajax (http://directwebremoting.org/dwr/reverse-ajax/threads.html) but the link to the example is not working...And I am not clear as to how to resolve the issue.

____
I have a ProductResizeTracker class implements ProductResizeListener class -  the constructor does the following:

WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);

I have a home page called tabbed-home.jsp that onload calls dwr.engine.setActiveReverseAjax(true);

I have a js function called "function updateProductResize(product){alert("product resized!")}"

HOW do I resolve this issue?

Teresa Stone
Raytheon IIS
Sr Software Engineer
Cell 903.356.6097
Work 972.205.4629

Teresa Stone | 4 Oct 2010 03:33
Picon

Re: "Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

David,


Thanks for your response.  

So what is the fix?  It states that there are 2 options;
  • 1. Access PageNormalizer from a DWR thread before you access it from outside of DWR. That way it can use WebContext.get().getServletContext() and cache the result for later use
  • 2. Set the ServletContext manually with DefaultPageNormalizer.getServletContext()
So what line in the example you sent for the Publisher class addresses one of these options?



On Sun, Oct 3, 2010 at 8:09 PM, David Marginian <david <at> butterdev.com> wrote:
There is nothing additional in Publisher, I need to remove that link thanks.

public Publisher()
    {
        WebContext webContext = WebContextFactory.get();
        ServletContext servletContext = webContext.getServletContext();

        serverContext = ServerContextFactory.get(servletContext);

        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

        synchronized (Publisher.class)
        {
            if (worker == null)
            {
                worker = new Thread(this, "Publisher");
                worker.start();

            }
        }
    }



On 10/3/2010 6:15 PM, Teresa D Stone wrote:
I just got my application configured to use DWR version 2.0.3.  I am using reverse ajax.  I am getting the following error in the console...
Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.
- To prevent this message from happening, either call the PageNormalizer from a DWR Thread
- Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread

I have read the section on the NON-Web Threads and Reverse Ajax (http://directwebremoting.org/dwr/reverse-ajax/threads.html) but the link to the example is not working...And I am not clear as to how to resolve the issue.

____
I have a ProductResizeTracker class implements ProductResizeListener class -  the constructor does the following:

WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);

I have a home page called tabbed-home.jsp that onload calls dwr.engine.setActiveReverseAjax(true);

I have a js function called "function updateProductResize(product){alert("product resized!")}"

HOW do I resolve this issue?

Teresa Stone
Raytheon IIS
Sr Software Engineer
Cell 903.356.6097
Work 972.205.4629




--
Teresa Stone
David Marginian | 4 Oct 2010 04:07

Re: "Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

From Joe's comments/the code I sent:
      
        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

On 10/3/2010 7:33 PM, Teresa Stone wrote:
David,

Thanks for your response.  

So what is the fix?  It states that there are 2 options;
  • 1. Access PageNormalizer from a DWR thread before you access it from outside of DWR. That way it can use WebContext.get().getServletContext() and cache the result for later use
  • 2. Set the ServletContext manually with DefaultPageNormalizer.getServletContext()
So what line in the example you sent for the Publisher class addresses one of these options?



On Sun, Oct 3, 2010 at 8:09 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
There is nothing additional in Publisher, I need to remove that link thanks.

public Publisher()
    {
        WebContext webContext = WebContextFactory.get();
        ServletContext servletContext = webContext.getServletContext();

        serverContext = ServerContextFactory.get(servletContext);

        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

        synchronized (Publisher.class)
        {
            if (worker == null)
            {
                worker = new Thread(this, "Publisher");
                worker.start();

            }
        }
    }



On 10/3/2010 6:15 PM, Teresa D Stone wrote:
I just got my application configured to use DWR version 2.0.3.  I am using reverse ajax.  I am getting the following error in the console...
Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.
- To prevent this message from happening, either call the PageNormalizer from a DWR Thread
- Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread

I have read the section on the NON-Web Threads and Reverse Ajax (http://directwebremoting.org/dwr/reverse-ajax/threads.html) but the link to the example is not working...And I am not clear as to how to resolve the issue.

____
I have a ProductResizeTracker class implements ProductResizeListener class -  the constructor does the following:

WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);

I have a home page called tabbed-home.jsp that onload calls dwr.engine.setActiveReverseAjax(true);

I have a js function called "function updateProductResize(product){alert("product resized!")}"

HOW do I resolve this issue?

Teresa Stone
Raytheon IIS
Sr Software Engineer
Cell 903.356.6097
Work 972.205.4629




--
Teresa Stone

Teresa Stone | 4 Oct 2010 19:26
Picon

Re: "Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

David,


When debugging I see the that the method I am using to callback a js function in my jsp is being enter and executed.  The callback function function is never called because the sessions collection length is zero.  Thus when the for loop line is reached in the dispatch method it does not call the callback function



public class ProductResizeTracker implements Listener{
  private ServerContext sctx;
  private String trackerPageUrl = "/tabbed-home.jsp";

  public ProductResizeTracker(){

    WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);
    wctx.getScriptSessionsByPage("");

      
    //sctx = ServerContextFactory.get(wctx.getServletContext());
    //RandomWalkGenerator.getInstance().addListener(this);
    UDPClient.addProductResizedListener(this);
    DockServlet.addProductResizedListener(this);
  }

    public void dispatch(Object dcsr) {
        
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("updateProductResize(")
      .appendData((DockableCatalogSearchResult)dcsr)
      .appendScript(");");

    // Push change out to clients viewing the page
    Collection<ScriptSession> sessions = new HashSet<ScriptSession>();
    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());


    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());

    for (ScriptSession session : sessions) {
      session.addScript(script);
    }
  }


}


On Sun, Oct 3, 2010 at 9:07 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
From Joe's comments/the code I sent:

      
        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

On 10/3/2010 7:33 PM, Teresa Stone wrote:
David,

Thanks for your response.  

So what is the fix?  It states that there are 2 options;
  • 1. Access PageNormalizer from a DWR thread before you access it from outside of DWR. That way it can use WebContext.get().getServletContext() and cache the result for later use
  • 2. Set the ServletContext manually with DefaultPageNormalizer.getServletContext()
So what line in the example you sent for the Publisher class addresses one of these options?



On Sun, Oct 3, 2010 at 8:09 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
There is nothing additional in Publisher, I need to remove that link thanks.

public Publisher()
    {
        WebContext webContext = WebContextFactory.get();
        ServletContext servletContext = webContext.getServletContext();

        serverContext = ServerContextFactory.get(servletContext);

        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

        synchronized (Publisher.class)
        {
            if (worker == null)
            {
                worker = new Thread(this, "Publisher");
                worker.start();

            }
        }
    }



On 10/3/2010 6:15 PM, Teresa D Stone wrote:
I just got my application configured to use DWR version 2.0.3.  I am using reverse ajax.  I am getting the following error in the console...
Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.
- To prevent this message from happening, either call the PageNormalizer from a DWR Thread
- Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread

I have read the section on the NON-Web Threads and Reverse Ajax (http://directwebremoting.org/dwr/reverse-ajax/threads.html) but the link to the example is not working...And I am not clear as to how to resolve the issue.

____
I have a ProductResizeTracker class implements ProductResizeListener class -  the constructor does the following:

WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);

I have a home page called tabbed-home.jsp that onload calls dwr.engine.setActiveReverseAjax(true);

I have a js function called "function updateProductResize(product){alert("product resized!")}"

HOW do I resolve this issue?

Teresa Stone
Raytheon IIS
Sr Software Engineer
Cell 903.356.6097
Work 972.205.4629




--
Teresa Stone




--
Teresa Stone
David Marginian | 4 Oct 2010 19:40

Re: "Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

Why don't you remote debug and inspect sctx.getScriptSessionsByPage.  My guess is that there is more to the path than just /tabbed-home.jsp.  If you look a the examples (for example Publish.java - which can be downloaded) you will see the following:
Collection sessions = serverContext.getScriptSessionsByPage(ContextPathRequestFilter.getContextPath() + "/gi/index.html");

On Mon, Oct 4, 2010 at 5:26 PM, Teresa Stone <tdstone281-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
David,

When debugging I see the that the method I am using to callback a js function in my jsp is being enter and executed.  The callback function function is never called because the sessions collection length is zero.  Thus when the for loop line is reached in the dispatch method it does not call the callback function



public class ProductResizeTracker implements Listener{
  private ServerContext sctx;
  private String trackerPageUrl = "/tabbed-home.jsp";

  public ProductResizeTracker(){

    WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);
    wctx.getScriptSessionsByPage("");

      
    //sctx = ServerContextFactory.get(wctx.getServletContext());
    //RandomWalkGenerator.getInstance().addListener(this);
    UDPClient.addProductResizedListener(this);
    DockServlet.addProductResizedListener(this);
  }

    public void dispatch(Object dcsr) {
        
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("updateProductResize(")
      .appendData((DockableCatalogSearchResult)dcsr)
      .appendScript(");");

    // Push change out to clients viewing the page
    Collection<ScriptSession> sessions = new HashSet<ScriptSession>();
    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());


    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());

    for (ScriptSession session : sessions) {
      session.addScript(script);
    }
  }


}


On Sun, Oct 3, 2010 at 9:07 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
From Joe's comments/the code I sent:

      
        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

On 10/3/2010 7:33 PM, Teresa Stone wrote:
David,

Thanks for your response.  

So what is the fix?  It states that there are 2 options;
  • 1. Access PageNormalizer from a DWR thread before you access it from outside of DWR. That way it can use WebContext.get().getServletContext() and cache the result for later use
  • 2. Set the ServletContext manually with DefaultPageNormalizer.getServletContext()
So what line in the example you sent for the Publisher class addresses one of these options?



On Sun, Oct 3, 2010 at 8:09 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
There is nothing additional in Publisher, I need to remove that link thanks.

public Publisher()
    {
        WebContext webContext = WebContextFactory.get();
        ServletContext servletContext = webContext.getServletContext();

        serverContext = ServerContextFactory.get(servletContext);

        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

        synchronized (Publisher.class)
        {
            if (worker == null)
            {
                worker = new Thread(this, "Publisher");
                worker.start();

            }
        }
    }



On 10/3/2010 6:15 PM, Teresa D Stone wrote:
I just got my application configured to use DWR version 2.0.3.  I am using reverse ajax.  I am getting the following error in the console...
Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.
- To prevent this message from happening, either call the PageNormalizer from a DWR Thread
- Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread

I have read the section on the NON-Web Threads and Reverse Ajax (http://directwebremoting.org/dwr/reverse-ajax/threads.html) but the link to the example is not working...And I am not clear as to how to resolve the issue.

____
I have a ProductResizeTracker class implements ProductResizeListener class -  the constructor does the following:

WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);

I have a home page called tabbed-home.jsp that onload calls dwr.engine.setActiveReverseAjax(true);

I have a js function called "function updateProductResize(product){alert("product resized!")}"

HOW do I resolve this issue?

Teresa Stone
Raytheon IIS
Sr Software Engineer
Cell 903.356.6097
Work 972.205.4629




--
Teresa Stone




--
Teresa Stone

Teresa Stone | 4 Oct 2010 20:49
Picon

Re: "Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

So for instance if I have a context define for my app i.e http://ip:8080/MyApp/tabbed-home.jsp, the /tabbed-home.jsp is incorrect?

On Mon, Oct 4, 2010 at 12:40 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
Why don't you remote debug and inspect sctx.getScriptSessionsByPage.  My guess is that there is more to the path than just /tabbed-home.jsp.  If you look a the examples (for example Publish.java - which can be downloaded) you will see the following:
Collection sessions = serverContext.getScriptSessionsByPage(ContextPathRequestFilter.getContextPath() + "/gi/index.html");


On Mon, Oct 4, 2010 at 5:26 PM, Teresa Stone <tdstone281-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
David,

When debugging I see the that the method I am using to callback a js function in my jsp is being enter and executed.  The callback function function is never called because the sessions collection length is zero.  Thus when the for loop line is reached in the dispatch method it does not call the callback function



public class ProductResizeTracker implements Listener{
  private ServerContext sctx;
  private String trackerPageUrl = "/tabbed-home.jsp";

  public ProductResizeTracker(){

    WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);
    wctx.getScriptSessionsByPage("");

      
    //sctx = ServerContextFactory.get(wctx.getServletContext());
    //RandomWalkGenerator.getInstance().addListener(this);
    UDPClient.addProductResizedListener(this);
    DockServlet.addProductResizedListener(this);
  }

    public void dispatch(Object dcsr) {
        
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("updateProductResize(")
      .appendData((DockableCatalogSearchResult)dcsr)
      .appendScript(");");

    // Push change out to clients viewing the page
    Collection<ScriptSession> sessions = new HashSet<ScriptSession>();
    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());


    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());

    for (ScriptSession session : sessions) {
      session.addScript(script);
    }
  }


}


On Sun, Oct 3, 2010 at 9:07 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
From Joe's comments/the code I sent:

      
        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

On 10/3/2010 7:33 PM, Teresa Stone wrote:
David,

Thanks for your response.  

So what is the fix?  It states that there are 2 options;
  • 1. Access PageNormalizer from a DWR thread before you access it from outside of DWR. That way it can use WebContext.get().getServletContext() and cache the result for later use
  • 2. Set the ServletContext manually with DefaultPageNormalizer.getServletContext()
So what line in the example you sent for the Publisher class addresses one of these options?



On Sun, Oct 3, 2010 at 8:09 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
There is nothing additional in Publisher, I need to remove that link thanks.

public Publisher()
    {
        WebContext webContext = WebContextFactory.get();
        ServletContext servletContext = webContext.getServletContext();

        serverContext = ServerContextFactory.get(servletContext);

        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

        synchronized (Publisher.class)
        {
            if (worker == null)
            {
                worker = new Thread(this, "Publisher");
                worker.start();

            }
        }
    }



On 10/3/2010 6:15 PM, Teresa D Stone wrote:
I just got my application configured to use DWR version 2.0.3.  I am using reverse ajax.  I am getting the following error in the console...
Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.
- To prevent this message from happening, either call the PageNormalizer from a DWR Thread
- Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread

I have read the section on the NON-Web Threads and Reverse Ajax (http://directwebremoting.org/dwr/reverse-ajax/threads.html) but the link to the example is not working...And I am not clear as to how to resolve the issue.

____
I have a ProductResizeTracker class implements ProductResizeListener class -  the constructor does the following:

WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);

I have a home page called tabbed-home.jsp that onload calls dwr.engine.setActiveReverseAjax(true);

I have a js function called "function updateProductResize(product){alert("product resized!")}"

HOW do I resolve this issue?

Teresa Stone
Raytheon IIS
Sr Software Engineer
Cell 903.356.6097
Work 972.205.4629




--
Teresa Stone




--
Teresa Stone




--
Teresa Stone
David Marginian | 4 Oct 2010 20:53

Re: "Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

I am not an expert on reverse-ajax so I can't tell you for certain.  Placing a breakpoint in your code and looking at all of the script sessions will tell you for sure.

On Mon, Oct 4, 2010 at 6:49 PM, Teresa Stone <tdstone281-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
So for instance if I have a context define for my app i.e http://ip:8080/MyApp/tabbed-home.jsp, the /tabbed-home.jsp is incorrect?


On Mon, Oct 4, 2010 at 12:40 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
Why don't you remote debug and inspect sctx.getScriptSessionsByPage.  My guess is that there is more to the path than just /tabbed-home.jsp.  If you look a the examples (for example Publish.java - which can be downloaded) you will see the following:
Collection sessions = serverContext.getScriptSessionsByPage(ContextPathRequestFilter.getContextPath() + "/gi/index.html");


On Mon, Oct 4, 2010 at 5:26 PM, Teresa Stone <tdstone281-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
David,

When debugging I see the that the method I am using to callback a js function in my jsp is being enter and executed.  The callback function function is never called because the sessions collection length is zero.  Thus when the for loop line is reached in the dispatch method it does not call the callback function



public class ProductResizeTracker implements Listener{
  private ServerContext sctx;
  private String trackerPageUrl = "/tabbed-home.jsp";

  public ProductResizeTracker(){

    WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);
    wctx.getScriptSessionsByPage("");

      
    //sctx = ServerContextFactory.get(wctx.getServletContext());
    //RandomWalkGenerator.getInstance().addListener(this);
    UDPClient.addProductResizedListener(this);
    DockServlet.addProductResizedListener(this);
  }

    public void dispatch(Object dcsr) {
        
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("updateProductResize(")
      .appendData((DockableCatalogSearchResult)dcsr)
      .appendScript(");");

    // Push change out to clients viewing the page
    Collection<ScriptSession> sessions = new HashSet<ScriptSession>();
    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());


    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());

    for (ScriptSession session : sessions) {
      session.addScript(script);
    }
  }


}


On Sun, Oct 3, 2010 at 9:07 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
From Joe's comments/the code I sent:

      
        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

On 10/3/2010 7:33 PM, Teresa Stone wrote:
David,

Thanks for your response.  

So what is the fix?  It states that there are 2 options;
  • 1. Access PageNormalizer from a DWR thread before you access it from outside of DWR. That way it can use WebContext.get().getServletContext() and cache the result for later use
  • 2. Set the ServletContext manually with DefaultPageNormalizer.getServletContext()
So what line in the example you sent for the Publisher class addresses one of these options?



On Sun, Oct 3, 2010 at 8:09 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
There is nothing additional in Publisher, I need to remove that link thanks.

public Publisher()
    {
        WebContext webContext = WebContextFactory.get();
        ServletContext servletContext = webContext.getServletContext();

        serverContext = ServerContextFactory.get(servletContext);

        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

        synchronized (Publisher.class)
        {
            if (worker == null)
            {
                worker = new Thread(this, "Publisher");
                worker.start();

            }
        }
    }



On 10/3/2010 6:15 PM, Teresa D Stone wrote:
I just got my application configured to use DWR version 2.0.3.  I am using reverse ajax.  I am getting the following error in the console...
Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.
- To prevent this message from happening, either call the PageNormalizer from a DWR Thread
- Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread

I have read the section on the NON-Web Threads and Reverse Ajax (http://directwebremoting.org/dwr/reverse-ajax/threads.html) but the link to the example is not working...And I am not clear as to how to resolve the issue.

____
I have a ProductResizeTracker class implements ProductResizeListener class -  the constructor does the following:

WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);

I have a home page called tabbed-home.jsp that onload calls dwr.engine.setActiveReverseAjax(true);

I have a js function called "function updateProductResize(product){alert("product resized!")}"

HOW do I resolve this issue?

Teresa Stone
Raytheon IIS
Sr Software Engineer
Cell 903.356.6097
Work 972.205.4629




--
Teresa Stone




--
Teresa Stone




--
Teresa Stone

Mike Wilson | 6 Oct 2010 15:23
Picon
Favicon

RE: "Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

Yes, that's correct.
FWIW, I think the default behaviour should be to ignore the contextPath from this matching process and I can't remember why this isn't done.
Anyway, it's quite easy for you to to this yourself. Make a subclass of
    DefaultPageNormalizer
where you remove contextPath from the unnormalized url, and install it according to
 
Best regards
Mike Wilson

From: Teresa Stone [mailto:tdstone281-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: den 4 oktober 2010 20:49
To: users-EyPigyGktj4FDOXUYO6UHQ@public.gmane.org
Subject: Re: [dwr-user] "Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults."

So for instance if I have a context define for my app i.e http://ip:8080/MyApp/tabbed-home.jsp, the /tabbed-home.jsp is incorrect?

On Mon, Oct 4, 2010 at 12:40 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
Why don't you remote debug and inspect sctx.getScriptSessionsByPage.  My guess is that there is more to the path than just /tabbed-home.jsp.  If you look a the examples (for example Publish.java - which can be downloaded) you will see the following:
Collection sessions = serverContext.getScriptSessionsByPage(ContextPathRequestFilter.getContextPath() + "/gi/index.html");


On Mon, Oct 4, 2010 at 5:26 PM, Teresa Stone <tdstone281-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
David,

When debugging I see the that the method I am using to callback a js function in my jsp is being enter and executed.  The callback function function is never called because the sessions collection length is zero.  Thus when the for loop line is reached in the dispatch method it does not call the callback function



public class ProductResizeTracker implements Listener{
  private ServerContext sctx;
  private String trackerPageUrl = "/tabbed-home.jsp";

  public ProductResizeTracker(){

    WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);
    wctx.getScriptSessionsByPage("");

      
    //sctx = ServerContextFactory.get(wctx.getServletContext());
    //RandomWalkGenerator.getInstance().addListener(this);
    UDPClient.addProductResizedListener(this);
    DockServlet.addProductResizedListener(this);
  }

    public void dispatch(Object dcsr) {
        
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("updateProductResize(")
      .appendData((DockableCatalogSearchResult)dcsr)
      .appendScript(");");

    // Push change out to clients viewing the page
    Collection<ScriptSession> sessions = new HashSet<ScriptSession>();
    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());


    sessions.addAll(sctx.getScriptSessionsByPage(trackerPageUrl));
    System.out.println(sessions.size());

    for (ScriptSession session : sessions) {
      session.addScript(script);
    }
  }


}


On Sun, Oct 3, 2010 at 9:07 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
From Joe's comments/the code I sent:

      
        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

On 10/3/2010 7:33 PM, Teresa Stone wrote:
David,

Thanks for your response.  

So what is the fix?  It states that there are 2 options;
  • 1. Access PageNormalizer from a DWR thread before you access it from outside of DWR. That way it can use WebContext.get().getServletContext() and cache the result for later use
  • 2. Set the ServletContext manually with DefaultPageNormalizer.getServletContext()
So what line in the example you sent for the Publisher class addresses one of these options?



On Sun, Oct 3, 2010 at 8:09 PM, David Marginian <david-H55tQ8LTKd1xxXtqJ93Y6g@public.gmane.org> wrote:
There is nothing additional in Publisher, I need to remove that link thanks.

public Publisher()
    {
        WebContext webContext = WebContextFactory.get();
        ServletContext servletContext = webContext.getServletContext();

        serverContext = ServerContextFactory.get(servletContext);

        // A bit nasty: the call to serverContext.getScriptSessionsByPage()
        // below could fail because the system might need to read web.xml which
        // means it needs a ServletContext, which is only available  using
        // WebContext, which in turn requires a DWR thread. We can cache the
        // results simply by calling this in a DWR thread, as we are now.
        webContext.getScriptSessionsByPage("");

        synchronized (Publisher.class)
        {
            if (worker == null)
            {
                worker = new Thread(this, "Publisher");
                worker.start();

            }
        }
    }



On 10/3/2010 6:15 PM, Teresa D Stone wrote:
I just got my application configured to use DWR version 2.0.3.  I am using reverse ajax.  I am getting the following error in the console...
Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.
- To prevent this message from happening, either call the PageNormalizer from a DWR Thread
- Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread

I have read the section on the NON-Web Threads and Reverse Ajax (http://directwebremoting.org/dwr/reverse-ajax/threads.html) but the link to the example is not working...And I am not clear as to how to resolve the issue.

____
I have a ProductResizeTracker class implements ProductResizeListener class -  the constructor does the following:

WebContext wctx = WebContextFactory.get();
    ServletContext servletContext = wctx.getServletContext();
    sctx = ServerContextFactory.get(servletContext);

I have a home page called tabbed-home.jsp that onload calls dwr.engine.setActiveReverseAjax(true);

I have a js function called "function updateProductResize(product){alert("product resized!")}"

HOW do I resolve this issue?

Teresa Stone
Raytheon IIS
Sr Software Engineer
Cell 903.356.6097
Work 972.205.4629




--
Teresa Stone




--
Teresa Stone




--
Teresa Stone

Gmane