4 Replies Latest reply: Feb 15, 2010 8:26 AM by Rafael Costa RSS

    Getting java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to javax.servlet.http.HttpServletRequest

    Ravi Kanth Newbie

      Hi,

       

      When I add the

      javax.servlet.http.HttpSession;

      HttpSession userSession = ServletActionContext.getRequest()
                       .getSession();
               userSession.invalidate();

       

      I am getting below exception, I have migrated form JBoss4.2.3 GA to JBoss5.1.0GA and using Struts2.1.8.1

       

      Please help me, I have tryied all the possible ways but no luck.

       

      Thanks in advance.

       

      Regards,

      Ravikanth

       

      Code:

      --------

       

      import javax.servlet.http.HttpSession;

       

      import org.apache.struts2.ServletActionContext;

       

      import com.opensymphony.xwork2.ActionSupport;

       

      public class Logout extends ActionSupport {
          private static final long serialVersionUID = 1L;

       

          public String execute() throws Exception {
              HttpSession userSession = ServletActionContext.getRequest()
                      .getSession();
              userSession.invalidate();

       

              return SUCCESS;
          }

       

      }

       

      Exception:

      --------------

       

      12:46:26,515 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
      java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot
      be cast to javax.servlet.http.HttpServletRequest
              at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
      .doFilter(StrutsPrepareAndExecuteFilter.java:73)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
      lter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
      alve.java:235)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
      alve.java:191)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
      yAssociationValve.java:190)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
      torBase.java:433)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
      e.java:92)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.proce
      ss(SecurityContextEstablishmentValve.java:126)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invok
      e(SecurityContextEstablishmentValve.java:70)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
      onnectionValve.java:158)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
      a:330)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
      :829)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
      ss(Http11Protocol.java:598)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
      7)
              at java.lang.Thread.run(Thread.java:619)
      12:46:39,921 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
      java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot
      be cast to javax.servlet.http.HttpServletRequest
              at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
      .doFilter(StrutsPrepareAndExecuteFilter.java:73)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
      lter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
      alve.java:235)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
      alve.java:191)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
      yAssociationValve.java:190)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
      torBase.java:433)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
      e.java:92)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.proce
      ss(SecurityContextEstablishmentValve.java:126)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invok
      e(SecurityContextEstablishmentValve.java:70)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
      onnectionValve.java:158)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
      a:330)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
      :829)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
      ss(Http11Protocol.java:598)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
      7)
              at java.lang.Thread.run(Thread.java:619)