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

ViewToolManager constructor ViewToolManager(servletContext) throws NPE always

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0
    • 2.0.x, 2.x, 3.0
    • VelocityView
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: