Velocity Tools
  1. Velocity Tools
  2. VELTOOLS-66

Velocity Tools gives access exception with $request reference under Tomcat security manager


    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.2
    • Fix Version/s: None
    • Component/s: VelocityView
    • Labels:


      I'm labeling this as a bug, though it's arguable whether the fault is of Tomcat or Velocity. Regardless, we should apply a workaround. I've replicated this issue with Velocity 1.4 / Tools 1.2 / JDK 1.5 / Tomcat 5.5

      The problem. When the Tomcat is run under the default security manager settings, it prohibits reflection on org.catalina classes. This means that the reference $ fails with an access violation

      INFO: Velocity [error] PROGRAMMER ERROR : PropertyExector() : access denied (java.lang.RuntimePermission

      sometimes the package given is org.apache.catalina.core, somtimes org.apache.catalina.session, depending on various factors.

      Users can alter their security policy to allow this access. But this is an obscure procedure and may not be feasible if you do not control your hosting environment. For the record, the settings for catalina.policy are (change the path to suit your webapp)

      grant codeBase "file:$

      permission java.lang.RuntimePermission
      permission java.lang.RuntimePermission
      permission java.lang.RuntimePermission

      grant codeBase "file:${catalina.home}

      permission java.lang.RuntimePermission
      permission java.lang.RuntimePermission
      permission java.lang.RuntimePermission

      As an alternative, I propose that the Velocity Tools project solve this by create a wrapper object for HttpServletRequest. (presumably the problem also exists for $response, though I haven't tried it). This object would simply pass through all calls to the server-provided HttpServletRequest. Obviously, there would need to be a parallel wrapper for HttpSession, HttpServletContext, and similar objects available from HttpServletRequest methods. The result would be that the Velocity page would never apply reflection to a Catalina class. (and hence never generate this security error).

      This issue is in reference to a problem encountered and described on the user list by Robin Mannering.


        Nathan Bubna made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]
        Nathan Bubna made changes -
        Field Original Value New Value
        Issue Type Bug [ 1 ] New Feature [ 2 ]
        Will Glass-Husain created issue -


          • Assignee:
            Will Glass-Husain
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: