title: Struts 2 on GAE : Unable to set session values inside interceptor
body: <p>I am writing a Struts 2 interceptor in which I check if the user is valid or not. If not valid, the user is redirected to the Login page. But before that I'm trying to retrieve the URL, which the user has accessed to come here, and put it in a session variable, so that I could redirect him back there when logging in is done. But when I try to put a value inside the session its throwing me the following exception :</p>
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class freemarker.template.Configuration
      at org.apache.struts2.views.freemarker.FreemarkerManager.createConfiguration(FreemarkerManager.java:322)
      at org.apache.struts2.views.freemarker.FreemarkerManager.init(FreemarkerManager.java:273)
      at org.apache.struts2.views.freemarker.FreemarkerManager.getConfiguration(FreemarkerManager.java:260)
      at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:865)
      at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:574)
      at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
      at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:368)
      at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:351)
      at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      at org.mortbay.jetty.handler.ContextHandler.__handle(ContextHandler.java:765)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
      at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:485)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:326)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
  </code></pre>
  <p>Note : It says class not found, but I can see the Configuration class inside the list of libraries in the buildpath.
  The piece of code from interceptor :</p>
  <pre><code>public String intercept(ActionInvocation actionInvocation)
          throws Exception {
      System.out.println(&quot;inside auth interceptor&quot;);
      //just to make sure session is created the first time
      HttpSession session = ServletActionContext.getRequest().getSession(true);
      Map&lt;String, Object&gt; sessionAttributes = ActionContext.getContext().getSession();
  
      User user = (User) sessionAttributes.get(&quot;user&quot;);
  
      ActionProxy proxy = actionInvocation.getProxy();
      String namespace =  proxy.getNamespace();
      String actionName = proxy.getActionName();
  
      sessionAttributes.put(&quot;returnUrl&quot;,  namespace+(actionName == null || actionName.equals(&quot;/&quot;) ?&quot;&quot;:(&quot;/&quot;+actionName)));
      //even tried this, but getting same error : 
      //session.setAttribute(&quot;returnUrl&quot;,  namespace+(actionName == null || actionName.equals(&quot;/&quot;) ?&quot;&quot;:(&quot;/&quot;+actionName)));
      System.out.println(namespace+(actionName == null || actionName.equals(&quot;/&quot;) ?&quot;&quot;:(&quot;/&quot;+actionName)));
  
      if(user == null){
          //no user exist. redirect to Login page
          return Action.LOGIN;
  
      }else
          return actionInvocation.invoke();
  }
  </code></pre>
  <p>As you see, i even tried <code>session.setAttribute()</code> to get the same error. Without putting anything into the session variable, the code runs as expected. So what is that I'm doing wrong?</p>
  <p><strong>Update 1</strong> : I do have the required <code>freemarker-2.3.19</code> in <code>web-inf/lib</code> and it is added to the build path.</p>