1 Reply Latest reply: Nov 28, 2012 8:34 AM by PHCharbonneau RSS

    MemorySessionData returned instead of custom session object when 404 error

    851855
      WebLogic Server Version: 12.1.1.0
      weblogic.servlet.internal.session.MemorySessionData returned instead of our custom session object when 404 error comes. How can I ensure that custom session object is returned?

      We have implemented HttpSession in our application com.web.failover.ReplicatedSession implements HttpSession, Serializable.
      We store attrbites as "AttributeWrapper implements Externalizable" in com.web.failover.ReplicatedSession

      This session is used in all the places in our app.
      When we call, HttpSession session = request.getSession(false);
      It returns an object of type: com.web.failover.ReplicatedSession

      Except for one place 'VirtualLinkHandler' where it returns weblogic.servlet.internal.session.MemorySessionData.
      This servlet is called when 404 error occurs in our app.
      This results in ClassCast Exception when we try to get any attribute value in this servlet.

      Please note that session ID is same in all the cases. I checked in the filters as well before the request reaches 'VirtualLinkHandler' and
      the session object is always of type com.web.failover.ReplicatedSession

      These are the settings:

      web.xml::
      <servlet>
           <servlet-name>VirtualLinkHandler</servlet-name>
           <servlet-class>com.web.virtuallink.VirtualLinkHandler</servlet-class>
      </servlet>
      <servlet-mapping>
           <servlet-name>VirtualLinkHandler</servlet-name>
           <url-pattern>/VirtualLinkHandler</url-pattern>
      </servlet-mapping>
      <error-page>
           <error-code>404</error-code>
           <location>/VirtualLinkHandler</location>
      </error-page>

      Code Flow:
      Connect.java sends a response.sendRedirect("/abc/Administrator/test.doc") where /abc is the context-path of my application
      This results in 404 and the request goes to VirtualLinkHandler service() method.


      Exception::
      java.lang.ClassCastException: com.web.failover.AttributeWrapper cannot be cast to java.lang.String
           at com.web.virtuallink.VirtualLinkHandler.service(VirtualLinkHandler.java:80)
           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)

      Logs:
      In connect.java Session is com.web.failover.ReplicatedSession@38a5b7
      In connect.java Session ID 4Q5mQ1tfC3fBn2pRJh1YFbl2G99xQtPjhWZzDHq6YdTLNY14DxRG!331366247!1354083839188
      FILTER Session is com.web.failover.ReplicatedSession@38a5b7
      VirtualLinkHandler Session weblogic.servlet.internal.session.MemorySessionData@1256ca7
      VirtualLinkHandler Session ID 4Q5mQ1tfC3fBn2pRJh1YFbl2G99xQtPjhWZzDHq6YdTLNY14DxRG!331366247!1354083839188

      Edited by: 848852 on Nov 27, 2012 11:53 PM
        • 1. Re: MemorySessionData returned instead of custom session object when 404 error
          PHCharbonneau
          Hi,

          I have seen a lot of problems with client implementations attempting to override the HttpSession object with a custom implementation.

          weblogic.servlet.internal.session.MemorySessionData is the inner & default Weblogic HttpSession implementation class so it looks like, as you mentioned, that your override method is not working for this particular Servlet.

          At this point my recommendation is for you to create an SR with Oracle, share your code & configuration so they can determine if Weblogic 12 is fully supporting what you are trying to achieve.

          Thanks.
          P-H
          http://javaeesupportpatterns.blogspot.com