title: Error in DWR 2.0.5
body: <p>I am only allowed to use DWR 2.0.5 as DWR 3 is not yet released. My servers is WAS 8.0. 
      I have 2 URLS Page1 and Page 2. Page1 will have a simple lable and an empty textbox. Page2 has nothing. First I will enter Page1 and then I will enter Page 2 in another browser. When I enter Page2, the textbox in Page1 should be filled with a Message "Hello DWR". I'm trying to achieve this using reverse ajax. Below are my code snippets and config files.</p>
  
  <pre><code>**DWR.xml**
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.ltd.uk/dwr/dwr20.dtd"&gt;
  &lt;dwr&gt;
    &lt;allow&gt;
      &lt;create creator="new" javascript="GetSession"&gt;
        &lt;param name="class" value="com.americanexpress.as.springthread.web.util.GetSession"/&gt;
       &lt;/create&gt;
      &lt;create creator="new" javascript="CallSession"&gt;
        &lt;param name="class" value="com.americanexpress.as.springthread.web.util.CallSession"/&gt;
      &lt;/create&gt;
     &lt;/allow&gt;
  &lt;/dwr&gt;
  
  
  **web.xml**
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
     &lt;display-name&gt;SpringThreadWebWAR&lt;/display-name&gt;
  
     &lt;servlet&gt;
      &lt;servlet-name&gt;dwr-invoker&lt;/servlet-name&gt;
      &lt;display-name&gt;DWR Servlet&lt;/display-name&gt;
      &lt;description&gt;Direct Web Remoter Servlet&lt;/description&gt;
      &lt;servlet-class&gt;org.directwebremoting.servlet.DwrServlet&lt;/servlet-class&gt;
  
      &lt;!-- This should NEVER be present in live --&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;debug&lt;/param-name&gt;
        &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
  
      &lt;!-- Remove this unless you want to use active reverse ajax --&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;activeReverseAjaxEnabled&lt;/param-name&gt;
        &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
  
        &lt;!-- Remove this unless you want to use active reverse ajax --&gt;
       &lt;init-param&gt;
        &lt;param-name&gt;pollAndCometEnabled&lt;/param-name&gt;
        &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt; 
  
  
  
      &lt;!-- Keep this to elimintate CSRF attack --&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;crossDomainSessionSecurity&lt;/param-name&gt;
        &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/init-param&gt; 
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;dwr-invoker&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/dwr/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
      &lt;servlet&gt;
        &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
        &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
        &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
     &lt;/servlet&gt;  
  
     &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
        &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
     &lt;/servlet-mapping&gt;
  &lt;env-entry&gt;
        &lt;env-entry-name&gt;SLConfigFile&lt;/env-entry-name&gt;
        &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;
        &lt;env-entry-value&gt;log_servicelocator.xml&lt;/env-entry-value&gt;
     &lt;/env-entry&gt;
  &lt;/web-app&gt;
  
  **dispatcher-servlet.xml**
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:task="http://www.springframework.org/schema/task"
      xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
                          http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                          http://www.springframework.org/schema/context
                          http://www.springframework.org/schema/context/spring-context-3.1.xsd
                          http://www.springframework.org/schema/mvc
                          http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
                          http://www.springframework.org/schema/tx
                          http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                          http://www.directwebremoting.org/schema/spring-dwr
                          http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"&gt;
  
      &lt;mvc:annotation-driven /&gt;       
  
      &lt;context:component-scan base-package="com.americanexpress.as.springthread.web.controller" /&gt;
      &lt;context:component-scan base-package="com.americanexpress.as.springthread.web.processor" /&gt;
      &lt;context:component-scan base-package="com.americanexpress.as.springthread.web.util" /&gt;
      &lt;mvc:view-controller path="/" view-name="index" /&gt;
  
      &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
              &lt;property name="prefix" value="/WEB-INF/" /&gt;
              &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="fileData" class="com.americanexpress.as.springthread.web.util.FileData" /&gt;
  
      &lt;bean id="schedulerTask"  class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean"&gt;
      &lt;property name="targetObject" ref="fileData" /&gt;
      &lt;property name="targetMethod" value="createFile" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="timerTask" class="org.springframework.scheduling.timer.ScheduledTimerTask"&gt;
      &lt;property name="timerTask" ref="schedulerTask" /&gt;
      &lt;property name="delay" value="600000000" /&gt;
      &lt;property name="period" value="600000000" /&gt;
      &lt;/bean&gt;
  
      &lt;bean class="org.springframework.scheduling.timer.TimerFactoryBean"&gt;
      &lt;property name="scheduledTimerTasks"&gt;
          &lt;list&gt;
              &lt;ref local="timerTask" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;/bean&gt;
  
       &lt;bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"&gt;
          &lt;property name="corePoolSize" value="1"&gt;&lt;/property&gt;
          &lt;property name="maxPoolSize" value="10"&gt;&lt;/property&gt;
          &lt;property name="WaitForTasksToCompleteOnShutdown" value="true"&gt;&lt;/property&gt;
      &lt;/bean&gt; 
  
      &lt;bean id="threadRunner" class="com.americanexpress.as.springthread.web.util.ThreadRunner"&gt;
          &lt;constructor-arg ref="taskExecutor" /&gt;
      &lt;/bean&gt;
  
  
  
  
  &lt;/beans&gt;   
  
  **Page1.jsp**
  
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;script type='text/javascript' src='&lt;%=request.getContextPath()%&gt;/dwr/engine.js'&gt;&lt;/script&gt;
  &lt;script type='text/javascript' src = '&lt;%=request.getContextPath()%&gt;/dwr/interface/GetSession.js'&gt;&lt;/script&gt;
  &lt;script type='text/javascript' src='&lt;%=request.getContextPath()%&gt;/dwr/util.js'&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;!-- &lt;input type="button" onclick="getSession();"&gt; --&gt;
  &lt;label id="label"&gt;Session Id&lt;/label&gt;
  &lt;input type="text" id="tag"&gt;
  &lt;script type="text/javascript"&gt;
  window.onload=function()
  {
      dwr.engine.setActiveReverseAjax(true); // Initiate reverse ajax polling
      addAttributeToScriptSession(); // Make a remote call to the server to add an attribute onto the ScriptSession which will be used in determining what pages receive updates!
  
  }
  
  function addAttributeToScriptSession()
  {
      alert('vamsi');
      GetSession.getSessionValue();
  }
  
  function getIt()
  {
      alert('Maaan'); 
  }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  **Page2.jsp**
  
  
  
  &lt;%@page import="com.americanexpress.as.springthread.web.util.StatMap"%&gt;
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;script type='text/javascript' src='&lt;%=request.getContextPath()%&gt;/dwr/engine.js'&gt;&lt;/script&gt;
  &lt;script type='text/javascript' src = '&lt;%=request.getContextPath()%&gt;/dwr/interface/CallSession.js'&gt;&lt;/script&gt;
  &lt;script type='text/javascript' src='&lt;%=request.getContextPath()%&gt;/dwr/util.js'&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;!-- &lt;input type="button" onclick="getSession();"&gt; --&gt;
  &lt;script type="text/javascript"&gt;
  window.onload=function()
  {
      dwr.engine.setActiveReverseAjax(true); // Initiate reverse ajax polling
       callSession(); // Make a remote call to the server to add an attribute onto the ScriptSession which will be used in determining what pages receive updates!
  }
  
  function callSession()
  {
      alert('krishna');
      CallSession.callSession();
  }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  **CallSession.java**
  
  package com.americanexpress.as.springthread.web.util;
  
  
  import org.directwebremoting.ScriptSession;
  import org.directwebremoting.ServerContext;
  import org.directwebremoting.beehive.PageFlowCreator;
  import org.directwebremoting.proxy.dwr.Util;
  
  
  public class CallSession {
  
      public void callSession() throws ClassNotFoundException{
           ScriptSession sessionId = (ScriptSession)StatMap.statMap.get("sessionId");
           System.out.println("Session id in Page2 "+sessionId);
                  /*Browser.withPage(sessionId.getPage(), new Runnable(){
              public void run() {
                  Util.setValue("tag", "Hello World");
              }
  
          });*/
          Util u = new Util(sessionId);
          System.out.println("The value of u is "+u);
          u.setValue("tag","Hello World");
          }
  }
  
  
  **GetSession.java**
  
  package com.americanexpress.as.springthread.web.util;
  
  import org.directwebremoting.ScriptSession;
  
  import org.directwebremoting.WebContextFactory;
  
  
  public class GetSession {
      public void getSessionValue(){
          ScriptSession scriptSession = WebContextFactory.get().getScriptSession();
          System.out.println("************************"+scriptSession.getId()+"************************");
          StatMap.statMap.put("sessionId",scriptSession);
  
      }
  }
  
  
  
  
  Now after I execute this, I'm always getting the below exception
  
  **Exception**
  
  [2/12/14 6:31:50:775 MST] 0000001e PollHandler   E org.directwebremoting.dwrp.PollHandler checkNotCsrfAttack A request has been denied as a potential CSRF atack.
  [2/12/14 6:31:50:781 MST] 0000001e ExceptionHand W org.directwebremoting.util.CommonsLoggingOutput warn Unhandled Exception
                                   java.lang.SecurityException: Session Error
          at org.directwebremoting.dwrp.PollHandler.checkNotCsrfAttack(PollHandler.java:252)
          at org.directwebremoting.dwrp.PollHandler.handle(PollHandler.java:99)
          at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
          at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1224)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
          at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
          at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
          at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79)
          at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
          at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
          at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3704)
          at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
          at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
          at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
          at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
          at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
          at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)
          at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
          at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
          at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
          at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
          at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
          at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
          at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
          at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
  
  [2/12/14 6:31:50:791 MST] 0000001e webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[dwr-invoker]: com.ibm.wswebcontainer.webapp.WebAppErrorReport: Error. Details logged to the console
          at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:624)
          at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:642)
          at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:1236)
          at org.directwebremoting.servlet.ExceptionHandler.handle(ExceptionHandler.java:59)
          at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:112)
          at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1224)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
          at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
          at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
          at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:79)
          at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
          at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
          at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3704)
          at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
          at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
          at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
          at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
          at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
          at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
          at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)
          at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
          at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
          at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
          at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
          at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
          at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
          at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
          at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
  
  
  Kindly let me know if any configuration or any implementation is wrong a
  
  
  Regards,
  Vamsi 
  </code></pre>