AnsweredAssumed Answered

freemarker.core.NonStringException

Question asked by johnmukkad on Jun 30, 2009
hai alfresco ,

   iam trying to create a webcontent using my pressrelease1234.xsd form and iam using a rendering freemarker template pressrelease1234.ftl .whenever i tried to create a webcontent it shows the exception shown in below

Error generating rendition using press-release 1234.ftl: freemarker.core.NonStringException: Error on line 13, column 51 in freemarker_template
Expecting a string, date or number here, Expression press_release.title is instead a freemarker.ext.dom.NodeListModel



iam using alfresco 3.2 lab preview and the logfile is given below

10:05:39,031 ERROR [org.alfresco.web.ui.common.Utils] Expecting a string, date or number here, Expression press_release.title is instead a freemarker.ext.dom.NodeListModel
org.alfresco.web.forms.RenderingEngine$RenderingException: freemarker.core.NonStringException: Error on line 13, column 51 in freemarker_template
Expecting a string, date or number here, Expression press_release.title is instead a freemarker.ext.dom.NodeListModel
   at org.alfresco.web.forms.FreeMarkerRenderingEngine.render(FreeMarkerRenderingEngine.java:124)
   at org.alfresco.web.forms.RenderingEngineTemplateImpl.render(RenderingEngineTemplateImpl.java:332)
   at org.alfresco.web.forms.RenderingEngineTemplateImpl.render(RenderingEngineTemplateImpl.java:305)
   at org.alfresco.web.bean.wcm.CreateWebContentWizard.saveContent(CreateWebContentWizard.java:595)
   at org.alfresco.web.bean.wcm.CreateWebContentWizard$2.execute(CreateWebContentWizard.java:285)
   at org.alfresco.web.bean.wcm.CreateWebContentWizard$2.execute(CreateWebContentWizard.java:282)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:326)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:233)
   at org.alfresco.web.bean.wcm.CreateWebContentWizard.next(CreateWebContentWizard.java:293)
   at org.alfresco.web.bean.wizard.WizardManager.next(WizardManager.java:560)
   at sun.reflect.GeneratedMethodAccessor1163.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
   at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
   at javax.faces.component.UICommand.broadcast(UICommand.java:109)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
   at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
   at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
   at sun.reflect.GeneratedMethodAccessor499.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy193.doFilter(Unknown Source)
   at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
   at sun.reflect.GeneratedMethodAccessor499.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy193.doFilter(Unknown Source)
   at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:595)
Caused by: freemarker.core.NonStringException: Error on line 13, column 51 in freemarker_template
Expecting a string, date or number here, Expression press_release.title is instead a freemarker.ext.dom.NodeListModel
   at freemarker.core.Expression.getStringValue(Expression.java:126)
   at freemarker.core.Expression.getStringValue(Expression.java:93)
   at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
   at freemarker.core.Environment.visit(Environment.java:208)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:208)
   at freemarker.core.Environment.renderElementToString(Environment.java:1563)
   at freemarker.core.StringLiteral.getStringValue(StringLiteral.java:101)
   at freemarker.core.StringLiteral._getAsTemplateModel(StringLiteral.java:86)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Environment.visit(Environment.java:555)
   at freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
   at freemarker.core.Environment.visit(Environment.java:208)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:208)
   at freemarker.core.IfBlock.accept(IfBlock.java:82)
   at freemarker.core.Environment.visit(Environment.java:208)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:208)
   at freemarker.core.Environment.process(Environment.java:188)
   at freemarker.template.Template.process(Template.java:237)
   at org.alfresco.web.forms.FreeMarkerRenderingEngine.render(FreeMarkerRenderingEngine.java:119)
   … 55 more

and my pressrelease1234.xsd is below
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:pr="http://www.alfresco.org/alfresco/pr"
           targetNamespace="http://www.alfresco.org/alfresco/pr"
           elementFormDefault="qualified">

  <!– dynamically loads the company footer choices simple type –>
  <xs:include schemaLocation="/media/releases/get_company_footer_choices_simple_type.jsp"/>

  <xs:simpleType name="category">
    <xs:restriction base="xs:normalizedString">
      <xs:enumeration value="Product"/>
      <xs:enumeration value="Partnership"/>
      <xs:enumeration value="Company"/>
      <xs:enumeration value="Event"/>
      <xs:enumeration value="Training"/>
    </xs:restriction>
  </xs:simpleType>

  <!– defines the form for creating a press release –>
  <xs:element name="press_release1234">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="title" type="xs:normalizedString"/>
        <xs:element name="abstract" type="xs:normalizedString"/>
        <xs:element name="location" type="xs:normalizedString"/>
        <xs:element name="body" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
   <xs:element name="include_company_footer" type="pr:company_footer_choices" minOccurs="1" maxOccurs="unbounded"/>
   <xs:element name="include_media_contacts" type="xs:boolean" default="true"/>
   <xs:element name="keywords" type="xs:normalizedString" minOccurs="0" maxOccurs="unbounded"/>
   <xs:element name="category" type="pr:category" default="Company"/>
   <xs:element name="launch_date" type="xs:date"/>
   <xs:element name="expiration_date" type="xs:date"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

and the pressrelease1234.ftl is given below

<#– Shows Press Release content with Custom Properties, Associated Image and Files –>
<H3> gd company </H3>
<HR>
<#if document?exists>
  <table>
      <tr>
           <td valign="top">
                <#macro show_heading heading>
                    ${heading}
                    <#list 1..heading?length as index>-</#list>
                </#macro>

                 <@show_heading heading="Title: ${press_release.title}"/>

                 <@show_heading heading="Abstract: ${press_release.abstract}"/>

                 <#list press_release.body as body>
                      <#if body_index = 0>
                          ${press_release.location}–${press_release.launch_date}–
                      </#if>
                      ${body?trim}
                </#list>
                <BR><BR>
               
           </td>
           <td valign="top">
                <B> PR CONTACT :</B> <BR>
                     Contact:  <BR>
                     Email:  <BR>
                     Phone:  <BR>
                <BR>
                <B> Associated Files: </B>
                <#list press_release.include_company_footer as cf>
                       <#assign cf_document=alf.parseXMLDocument(cf)>

                       <@show_heading heading="About ${cf_document.name}"/>
                       <#list cf_document.body as body>
                          ${body?trim}
                       </#list>
                </#list>
                <#if press_release.include_media_contacts = "true">

                     <@show_heading heading="Media Contacts"/>
                     John Newton
                     Alfresco Software Inc.
                     +44 1628 860639
                     press@alfresco.com

                      Chuck Tanowitz
                      Schwartz Communications
                      +1 781 684-0770
                      alfresco@schwartz-pr.com
                 </#if>

           </td>
     </tr>
</table>
<#else>
No document found!
</#if>


and iam using a jsp  get_company_footer_choices_simple_type.jsp which is given below


<jsp:root version="1.2" 
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:pr="http://www.alfresco.org/alfresco/pr">

<!– xmlns:pr is mapped to /WEB-INF/pr.tld by web.xml –>
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
<jsp:directive.page isELIgnored="false"/>


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:alfresco="http://www.alfresco.org"
elementFormDefault="qualified">

   <xs:simpleType name="company_footer_choices">
       <xs:restriction base="xs:string">
          <xs:enumeration value="company_footer_1.xml">
            <xs:annotation>
               <xs:appinfo>
                   <alfresco:label>Company Footer 1 Name</alfresco:label>
               </xs:appinfo>
            </xs:annotation>
          </xs:enumeration>
          <xs:enumeration value="company_footer_2.xml">
             <xs:annotation>
                <xs:appinfo>
                  <alfresco:label>Company Footer 2 Name</alfresco:label>
               </xs:appinfo>
            </xs:annotation>
          </xs:enumeration>
      </xs:restriction>
   </xs:simpleType>
</xs:schema>
</jsp:root>


pls help me to solve this error. iam waiting for your response.thank you in advance

Regards,
Johnmukkad

Outcomes