[MAGNOLIA-5355] ELException when using TemplatingFunctions link-method Created: 02/Oct/13  Updated: 16/Oct/13  Resolved: 14/Oct/13

Status: Closed
Project: Magnolia
Component/s: templating
Affects Version/s: 5.1
Fix Version/s: 5.1.1

Type: Bug Priority: Critical
Reporter: Sigurd Rolfes Assignee: Jozef Chocholacek
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mgnl 5.1-rc1 ee
Windows 7
Tomcat 7.0.32


Issue Links:
causality
is causing MAGNOLIA-5383 Rename methods in TemplatingFunctions... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Sprint: 5.1.1

 Description   

I've got a problem using the cmsfn functions (of class TemplatingFunctions).

I get an ELException when trying to create a link in combination with nodeByPath-method:

${cmsfn.link(cmsfn.nodeByPath("/Startseite", "website"))}

This leads to ELException, because nodeByPath returns a info.magnolia.audit.MgnlAuditLoggingContentDecoratorNodeWrapper object and EL tries to use the link-method with parameter ContentMap instead of that one with Node. Seems EL has a problem recognizing that the wrapper implements JCR Node.

Using another link-method of TemplatingFunctions works fine:

${cmsfn.link("website", cmsfn.nodeByPath("/Startseite", "website").UUID)}

Note: I'm using Blossom and have cmsfn configured via spring configuration, but I don't think that makes a difference.

#######################################################

Stacktrace:

Caused by: javax.el.ELException: Cannot convert node /Startseite of type class info.magnolia.audit.MgnlAuditLoggingContentDecoratorNodeWrapper to class info.magnolia.jcr.util.ContentMap
at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:420) ~[jasper-el.jar:7.0.32]
at org.apache.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:47) ~[jasper-el.jar:7.0.32]
at javax.el.BeanELResolver.invoke(BeanELResolver.java:477) ~[el-api.jar:2.2.FR]
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:161) ~[el-api.jar:2.2.FR]
at org.apache.el.parser.AstValue.getValue(AstValue.java:173) ~[jasper-el.jar:7.0.32]
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) ~[jasper-el.jar:7.0.32]
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:986) ~[jasper.jar:7.0.32]
at org.apache.jsp.WEB_002dINF.pages.components.shoppingCart_jsp._jspService(shoppingCart_jsp.java:80) ~[na:na]
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) ~[jasper.jar:7.0.32]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) ~[servlet-api.jar:na]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) ~[jasper.jar:7.0.32]
... 186 common frames omitted



 Comments   
Comment by Sigurd Rolfes [ 07/Oct/13 ]

forgot to say: I'm using JSPs.

My Spring configuration:

<!-- Resolver for webflow jsp-Templates -->
<bean id="webflowJspResolver" class="info.magnolia.module.blossom.view.TemplateViewResolver">
<property name="order" value="1"/>
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
<property name="viewRenderer">
<bean class="info.magnolia.module.blossom.view.JspTemplateViewRenderer">
<property name="contextAttributes">
<map>
<!--entry key="cms">
<bean class="info.magnolia.rendering.renderer.ContextAttributeConfiguration">
<property name="name" value="cms"/>
<property name="componentClass" value="info.magnolia.templating.freemarker.Directives"/>
</bean>
</entry-->
<entry key="cmsfn">
<bean class="info.magnolia.rendering.renderer.ContextAttributeConfiguration">
<property name="name" value="cmsfn"/>
<property name="componentClass" value="info.magnolia.templating.functions.TemplatingFunctions"/>
</bean>
</entry>
</map>
</property>
</bean>
</property>
</bean>

Comment by Christopher Zimmermann [ 09/Oct/13 ]

Daniel might have some input on how to fix.

Comment by Eric Hechinger [ 14/Oct/13 ]

You are currently using TemplatingFunction as a JSP function. But a tag library can have only one function element that has any given name element with the same number of parameter. In TemplatingFunction we expose:
-public String link(Node content)
-public String link(ContentMap contentMap)
and the second one is taken.

So you will have either to declare and use JspTemplatingFunction
or

{cmsfn.link("website", cmsfn.nodeByPath("/Startseite", "website").UUID)}
Comment by Jozef Chocholacek [ 14/Oct/13 ]

Created a follow-up issue MAGNOLIA-5383.

Comment by Sigurd Rolfes [ 16/Oct/13 ]

Eric,

using JspTemplatingFunction leads to NoSuchComponentException, see stacktrace at the end.

I've seen in the renderer module that for the standard JspRenderer also the TemplatingFunction are defined.

If the TemplatingFunction class is not provided for using it with JSPs (Freemarker only) a hint in the javadoc would be fine.

Sigurd

#####################################################

Caused by: info.magnolia.objectfactory.NoSuchComponentException: No component configuration for type [info.magnolia.templating.jsp.cmsfn.JspTemplatingFunction] found. Please add a configuration to your module descriptor.
at info.magnolia.objectfactory.guice.GuiceComponentProvider.getComponent(GuiceComponentProvider.java:101)
at info.magnolia.objectfactory.Components.getComponent(Components.java:97)
at info.magnolia.rendering.renderer.AbstractRenderer.setupContext(AbstractRenderer.java:281)
at info.magnolia.module.blossom.view.JspTemplateViewRenderer.setupContext(JspTemplateViewRenderer.java:71)
at info.magnolia.rendering.renderer.AbstractRenderer.render(AbstractRenderer.java:147)
at info.magnolia.module.blossom.view.TemplateView.renderMergedOutputModel(TemplateView.java:74)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)
at org.springframework.webflow.mvc.servlet.ServletMvcView.doRender(ServletMvcView.java:55)
at org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:187)

Generated at Mon Feb 12 04:04:22 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.