groovy
  1. groovy
  2. GROOVY-432

Groovy Reflection problem for unknown classes

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0-JSR-3
    • Component/s: Groovlet / GSP
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Groovy can't reflect classes which are unknown to the its ClassLoader when using MetaClass.setUseReflection(false) even if it could cast to a known interface.

      For example Tomcat will replace System.out with a custom PrintStream instead of the default and when you try to use System.out and setUseReflection is set to false every call to System.out will fail with:

      java.lang.NoClassDefFoundError: org/apache/tomcat/util/log/SystemLogHandler
      gjdk.org.apache.tomcat.util.log.SystemLogHandler_GroovyReflector.invoke(SystemLogHandler_GroovyReflector.java)
      groovy.lang.MetaMethod.invoke(MetaMethod.java:110)
      groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:996)

      I packaged a complete war file to show the behaviour.

      It can be found at http://home.mx4k.com/test.war

      You should be able to call: http://yourhost/test/test.groovy to see the problem. If you use the default groovy.servlet.GroovyServlet the example works but I couldn't come up with an "easier" test to show this behaviour.

        Issue Links

          Activity

          Hide
          Thomas Heller added a comment -

          Sorry, the .war file got lost in a hd-crash. I know I should have attached it.

          Show
          Thomas Heller added a comment - Sorry, the .war file got lost in a hd-crash. I know I should have attached it.
          Hide
          A.J. added a comment -

          Hi,

          Just to let you know that I have similar problem with groovy-1.0-beta-6.
          I loaded some groovy script within my webapp and for some reason, I can't get access to the HttpServletRequest (CoyoteRequestFacade implementation from Tomcat) :

          InvocationTargetException
          Caused by: java.lang.NoClassDefFoundError: org/apache/coyote/tomcat4/CoyoteRequestFacade
          at gjdk.org.apache.coyote.tomcat4.CoyoteRequestFacade_GroovyReflector.invoke(CoyoteRequestFacade_GroovyReflector.java)

          In fact, I'm just trying to set an attribute in the HTTP request (request.setAttribute("xxx", "xxx)).

          I've solved the problem by using the workaround (groovy.lang.MetaClass.setUseReflection(true)).

          Cheers,
          A.J.

          Show
          A.J. added a comment - Hi, Just to let you know that I have similar problem with groovy-1.0-beta-6. I loaded some groovy script within my webapp and for some reason, I can't get access to the HttpServletRequest (CoyoteRequestFacade implementation from Tomcat) : InvocationTargetException Caused by: java.lang.NoClassDefFoundError: org/apache/coyote/tomcat4/CoyoteRequestFacade at gjdk.org.apache.coyote.tomcat4.CoyoteRequestFacade_GroovyReflector.invoke(CoyoteRequestFacade_GroovyReflector.java) In fact, I'm just trying to set an attribute in the HTTP request (request.setAttribute("xxx", "xxx)). I've solved the problem by using the workaround (groovy.lang.MetaClass.setUseReflection(true)). Cheers, A.J.
          Hide
          blackdrag blackdrag added a comment -
          Show
          blackdrag blackdrag added a comment - this should be fixed now, for details see http://cvs.codehaus.org/changelog/groovy?cs=MAIN:blackdrag:20050630161205&csize=2
          Hide
          Christian Stein added a comment -

          blackdrag fixed it.

          Show
          Christian Stein added a comment - blackdrag fixed it.

            People

            • Assignee:
              blackdrag blackdrag
              Reporter:
              Thomas Heller
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: