Velocity
  1. Velocity
  2. VELOCITY-98

#parse / #include causing ClassCastException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3-rc1
    • Fix Version/s: 1.5
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Operating System: Linux
      Platform: All

      Description

      If caching is on, and a template has been previously cached due to a #parse or
      #include directive, subsequently using the other directive will cause a
      ClassCastException and fail.

      Example: if I have two templates, the first one loaded includes the line:
      #include( "include/header.vtl" )
      and the second one the line:
      #parse( "include/header.vtl" )

      When the second page is viewed, a ClassCastException is thrown with an error in
      the log like:

      [error] #parse() : arg = include/header.vtl. Exception :
      java.lang.ClassCastException:
      org.apache.velocity.runtime.resource.ContentResource

      A solution might be to include the resourceType as part of the key when
      caching/retrieving the resource, within the getResource() method of the
      org.apache.velocity.runtime.resource.ResourceManagerImpl class. Alternatively
      seperate caches could be used for the different types of Resource.

        Activity

        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12551820 ] jira [ 12552629 ]
        Mark Thomas made changes -
        Workflow jira [ 12324973 ] Default workflow, editable Closed status [ 12551820 ]
        Henning Schmiedehausen made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Will Glass-Husain made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Will Glass-Husain made changes -
        Bugzilla Id 11126
        Environment Operating System: Linux
        Platform: All
        Operating System: Linux
        Platform: All
        Assignee Velocity-Dev List [ velocity-dev@jakarta.apache.org ]
        Description If caching is on, and a template has been previously cached due to a #parse or
        #include directive, subsequently using the other directive will cause a
        ClassCastException and fail.

        Example: if I have two templates, the first one loaded includes the line:
          #include( "include/header.vtl" )
        and the second one the line:
          #parse( "include/header.vtl" )

        When the second page is viewed, a ClassCastException is thrown with an error in
        the log like:

        [error] #parse() : arg = include/header.vtl. Exception :
        java.lang.ClassCastException:
        org.apache.velocity.runtime.resource.ContentResource

        A solution might be to include the resourceType as part of the key when
        caching/retrieving the resource, within the getResource() method of the
        org.apache.velocity.runtime.resource.ResourceManagerImpl class. Alternatively
        seperate caches could be used for the different types of Resource.
        If caching is on, and a template has been previously cached due to a #parse or
        #include directive, subsequently using the other directive will cause a
        ClassCastException and fail.

        Example: if I have two templates, the first one loaded includes the line:
          #include( "include/header.vtl" )
        and the second one the line:
          #parse( "include/header.vtl" )

        When the second page is viewed, a ClassCastException is thrown with an error in
        the log like:

        [error] #parse() : arg = include/header.vtl. Exception :
        java.lang.ClassCastException:
        org.apache.velocity.runtime.resource.ContentResource

        A solution might be to include the resourceType as part of the key when
        caching/retrieving the resource, within the getResource() method of the
        org.apache.velocity.runtime.resource.ResourceManagerImpl class. Alternatively
        seperate caches could be used for the different types of Resource.
        Fix Version/s 1.5 [ 12310253 ]
        Jeff Turner made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 11126 12314968
        Simon Christian created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Simon Christian
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development