You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Dan Slack (JIRA)" <ji...@apache.org> on 2008/11/07 00:04:36 UTC

[jira] Commented: (WW-2796) org.apache.struts2.views.velocity.VelocityManager calling deprecated velocity's ChainedContext constructor

    [ https://issues.apache.org/struts/browse/WW-2796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44935#action_44935 ] 

Dan Slack commented on WW-2796:
-------------------------------

ChainedContext has two constructors, one that takes in an existing Context, and one that doesn't.  If we don't pass in the StrutsVelocityContext object, we lose all references to the Struts objects (ValueStack, for example, wouldn't be set, and so when we use #sproperty, and it attempts to retrieve the ValueStack, we get a NPE)  So, this line:

ChainedContext chained = new ChainedContext(getVelocityEngine(), req, res, ctx); 

Should read:

ChainedContext chained = new ChainedContext(context, getVelocityEngine(), req, res, ctx); 

And thanks for the original code, I was a bit lost on why I was getting errors in the first place.

> org.apache.struts2.views.velocity.VelocityManager calling deprecated velocity's ChainedContext constructor
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: WW-2796
>                 URL: https://issues.apache.org/struts/browse/WW-2796
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.11
>         Environment: velocity-tools-1.4.jar
> velocity-1.5.jar
> struts2.0.11.jar
>            Reporter: Flavien Binet
>            Priority: Critical
>
> Hello :)
> I'm facing a bug when trying to setup velocity's toolbox (version 1.4). 
> Here is the stack trace : 
> ----------------------------
> java.lang.NoSuchMethodError: org.apache.velocity.tools.view.context.ChainedContext.<init>(Lorg/apache/velocity/context/Context;Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;Ljavax/servlet/ServletContext;)V
>         org.apache.struts2.views.velocity.VelocityManager.createContext(VelocityManager.java:193)
>         org.apache.struts2.dispatcher.VelocityResult.createContext(VelocityResult.java:235)
>         org.apache.struts2.dispatcher.VelocityResult.doExecute(VelocityResult.java:152)
>         org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
>         com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
>         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
>         ... 
> ----------------------------
> VelocityManager object is trying to call a constructor that has been deprecated since velocity-tools-1.3 (regarding javadoc -> http://velocity.apache.org/tools/releases/1.3/javadoc/org/apache/velocity/tools/view/context/ChainedContext.html#ChainedContext(org.apache.velocity.context.Context,%20javax.servlet.http.HttpServletRequest,%20javax.servlet.http.HttpServletResponse,%20javax.servlet.ServletContext)
> It work well using velocity-tools-1.2.jar, but i need to use it under 1.4. This new constructor seems to require a VelocityEngine instance that is not available around :)
> Thank for support

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