You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Nathan Bubna (JIRA)" <de...@velocity.apache.org> on 2010/10/15 22:47:33 UTC

[jira] Resolved: (VELTOOLS-130) ViewToolManager constructor ViewToolManager(servletContext) throws NPE always

     [ https://issues.apache.org/jira/browse/VELTOOLS-130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nathan Bubna resolved VELTOOLS-130.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.x
                   2.0.x

Nice catch.  I'm sorry to admit, i've never tried ViewToolManager with autoconfig as true.  I just committed a fix.  You can build from the trunk or wait for the next release.  And no, i don't know when that will be. :)

> ViewToolManager constructor ViewToolManager(servletContext) throws NPE always
> -----------------------------------------------------------------------------
>
>                 Key: VELTOOLS-130
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-130
>             Project: Velocity Tools
>          Issue Type: Bug
>          Components: VelocityView
>    Affects Versions: 2.0
>         Environment: Ubuntu 10.10, JDK 1.6.21, Tomcat 6.0.20
>            Reporter: Robert Brandner
>            Priority: Minor
>             Fix For: 2.0.x, 2.x
>
>
> 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);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org