ICEfaces
  1. ICEfaces
  2. ICE-1967

Wrapping session objects in anonymous classes kills calls by introspection

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.6.1
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      All.

      Description

      The problem was found in a Seam environment, but is not strictly limited to Seam.

      The following code in ServletExternalContext wraps the ProxyHttpSession object in a new anonymous wrapper class that overrides the invalidate method:

      this.session = new ProxyHttpSession(this.request.getSession()) {
             public void invalidate() {
                    sessionMonitor.shutdown();
             }
      };

      This works fine if you call the method normally, but calling the invalidate method by introspection throws the following exception:

      2007-08-09 10:03:03,140 ERROR [STDERR] java.lang.RuntimeException: java.lang.IllegalAccessException: Class org.jboss.seam.contexts.FacesLifecycle can not access a member of class com.icesoft.faces.webapp.http.servlet.ServletExternalContext$1 with modifiers "public"

      2007-08-09 10:03:03,140 ERROR [STDERR] at org.jboss.seam.contexts.FacesLifecycle.invalidateSession(FacesLifecycle.java:170)

      2007-08-09 10:03:03,140 ERROR [STDERR] at org.jboss.seam.contexts.FacesLifecycle.endRequest(FacesLifecycle.java:121)

      2007-08-09 10:03:03,140 ERROR [STDERR] at org.jboss.seam.jsf.SeamPhaseListener.afterRenderResponse(SeamPhaseListener.java:497)

      2007-08-09 10:03:03,140 ERROR [STDERR] at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:230)

      2007-08-09 10:03:03,140 ERROR [STDERR] at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:184)

      2007-08-09 10:03:03,140 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)

      2007-08-09 10:03:03,140 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)

      2007-08-09 10:03:03,140 ERROR [STDERR] at com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:26)

      2007-08-09 10:03:03,140 ERROR [STDERR] at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:126)

      2007-08-09 10:03:03,156 ERROR [STDERR] at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)

      2007-08-09 10:03:03,156 ERROR [STDERR] at com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:31)

      2007-08-09 10:03:03,156 ERROR [STDERR] at com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:46)

      .
      .
      .

        Issue Links

          Activity

          Hide
          Greg Dick added a comment -

          Potential fix that works for this instance. I just replaced the anonymous wrapper class with a top level class definition for the Seam introspection call, and it works. I'm a little concerned about other anonymous wrapped implementations, though. The notation is concise and explicit, and doesn't require a lot of similarly named class files, but we have to ensure that introspective calls to the public API will still work.

          And replace this code in ServletExternalContext.java, (line 42-46)

          this.session = new ProxyHttpSession(this.request.getSession()) {
          public void invalidate()

          { sessionMonitor.shutdown(); }

          };

          with this:

          this.session = new ProxyHttpSessionWrapper(this.request.getSession(), sessionMonitor);

          Show
          Greg Dick added a comment - Potential fix that works for this instance. I just replaced the anonymous wrapper class with a top level class definition for the Seam introspection call, and it works. I'm a little concerned about other anonymous wrapped implementations, though. The notation is concise and explicit, and doesn't require a lot of similarly named class files, but we have to ensure that introspective calls to the public API will still work. And replace this code in ServletExternalContext.java, (line 42-46) this.session = new ProxyHttpSession(this.request.getSession()) { public void invalidate() { sessionMonitor.shutdown(); } }; with this: this.session = new ProxyHttpSessionWrapper(this.request.getSession(), sessionMonitor);
          Hide
          Mircea Toma added a comment -

          Make intercepting class public since anonymous classes have 'package' access.

          Show
          Mircea Toma added a comment - Make intercepting class public since anonymous classes have 'package' access.

            People

            • Assignee:
              Unassigned
              Reporter:
              Greg Dick
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: