Tiles
  1. Tiles
  2. TILES-286

TilesAccess won't set context attributes in Jetty 5.1.10

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.6
    • Fix Version/s: 2.0.7
    • Labels:
      None
    • Environment:

      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04), Jetty 5.1.11, SUSE Linux Enterprise 10, 64 bit

      Description

      The code for setting a context attribute in the TilesAccess class is as follows:

      private static void setAttribute(Object context, String name, Object value)
      throws TilesException {
      try

      { Class<?> contextClass = context.getClass(); Method attrMethod = contextClass.getMethod("setAttribute", String.class, Object.class); attrMethod.invoke(context, name, value); }

      catch (Exception e)

      { throw new TilesException("Unable to set attribute for specified context: '" + context + "'"); }


      }

      The line
      attrMethod.invoke(context, name, value);
      throws an IllegalAccessException if Tiles are used inside a Jetty 5.1.11. This happens because Jetty's implementation of the javax.servlet.ServletContext interface is an inner class without the public modifier.

      I.e., Jetty's org.mortbay.jetty.servlet.ServletHandler$Context is not public although it's setAttribute() is.

      The same applies to getAttribute() and removeAttribute() methods.

      One of the possible solutions is to reflect the method not only from the class itself, but from all its superclasses and interfaces as well.

        Issue Links

          Activity

            People

            • Assignee:
              Antonio Petrelli
              Reporter:
              Dmitry
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development