Uploaded image for project: 'Velocity Tools'
  1. Velocity Tools
  2. VELTOOLS-130

ViewToolManager constructor ViewToolManager(servletContext) throws NPE always

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.x, 2.x, 3.0
    • Component/s: VelocityView
    • Labels:
      None
    • Environment:
      Ubuntu 10.10, JDK 1.6.21, Tomcat 6.0.20

      Description

      Invoking the constructor ViewToolManager(servletContext) always fails with an NPE. The reason for this is, that it invokes super(true, true) before setting the member variable servletContext with the provided servletContext.

      The parent class' constructor invokes autoConfigure(true) which invokes ServletUtils.getConfiguration(servletPath). At this moment servletPath can only be null as it is not set yet. And that finally leads to a NPE in the first line of the getConfiguration method:

      Object obj = application.getAttribute(CONFIGURATION_KEY);

      Workaround: Use a constructor without autoconfiguration and invoke autoConfigure(true) afterwards.

      ViewToolManager vm = new ViewToolmanager(servletContext, false, false);
      vm.autoConfigure(true);

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rbra Robert Brandner
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: