AnsweredAssumed Answered

Custom search webscript error - Expression results is undefi

Question asked by shikarishambu on Nov 9, 2009
I am trying to create a custom search service that searches on specific properties that are part of my custom content model. I keep getting "Expression results is undefined" error. I am not sure how to resolve it. Any help is appreciated.

Here is the error
  <?xml version="1.0" encoding="UTF-8" ?> 
- <response>
- <status>
  500
  <name>Internal Error</name>
  <description>An error inside the HTTP server which prevented it from fulfilling the request.</description>
  </status>
  <message>10090063 Wrapped Exception (with status template): 10090062 Error during processing of the template 'Expression results is undefined on line 3, column 8 in com/stagrp/alfresco/step/search/search.get.xml.ftl.'. Please contact your system administrator.</message>
  <exception>org.alfresco.web.scripts.WebScriptException - 10090063 Wrapped Exception (with status template): 10090062 Error during processing of the template 'Expression results is undefined on line 3, column 8 in com/company/alfresco/step/search/search.get.xml.ftl.'. Please contact your system administrator.</exception>
  <callstack>freemarker.core.InvalidReferenceException: Expression results is undefined on line 3, column 8 in com/stagrp/alfresco/step/search/search.get.xml.ftl. freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) freemarker.core.IteratorBlock.accept(IteratorBlock.java:100) freemarker.core.Environment.visit(Environment.java:208) freemarker.core.MixedContent.accept(MixedContent.java:92) freemarker.core.Environment.visit(Environment.java:208) freemarker.core.Environment.process(Environment.java:188) freemarker.template.Template.process(Template.java:237) org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:202) org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:523) org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:241) org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147) org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:357) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:326) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:407) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:424) org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:288) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:262) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139) org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) java.lang.Thread.run(Thread.java:619) org.alfresco.service.cmr.repository.TemplateException: 10090062 Error during processing of the template 'Expression results is undefined on line 3, column 8 in com/stagrp/alfresco/step/search/search.get.xml.ftl.'. Please contact your system administrator. org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:206) org.alfresco.web.scripts.WebScriptException: 10090063 Wrapped Exception (with status template): 10090062 Error during processing of the template 'Expression results is undefined on line 3, column 8 in com/stagrp/alfresco/step/search/search.get.xml.ftl.'. Please contact your system administrator. org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)</callstack>
  <server>Alfresco Community v3.2.0 (2039) schema 2,019</server>
  <time>Nov 9, 2009 2:39:45 PM</time>
  </response>

The search.get.desc.xml looks like this
<webscript>
   <shortname>Custom - Search</shortname>
   <description>Search the Alfresco repository</description>
   <url>/step/search?pid={pid}&amp;sid={sid}&amp;tid={tid}&amp;category={category}&amp;createdFrom={createdFrom?}&amp;createdTo={createdTo?}&amp;modifiedFrom={modifiedFrom?}&amp;modifiedTo={modifiedTo?}&amp;start={rowsFrom?}&amp;limit={rowsTo?}&amp;sort={orderBy?}&amp;dir={orderDirection?}</url>
   <format default="xml">extension</format>
   <authentication>guest</authentication>
   <transaction allow="readonly">required</transaction>
</webscript>

The search.get.js controller looks like this
var pid = args.pid;
var sid = args.sid;
var tid = args.tid;
var category = args.category;
var createdFrom = args.createdFrom;
var createdTo = args.createdTo;
var modifiedFrom = args.modifiedFrom;
var modifiedTo = args.modifiedTo;
var query = "";

if (pid != "")
{
   query = '+@step\\:policynum:\"' + pid + '" ';
}
if (sid != "")
{
   query = '+@step\\:claimnum:\"' + sid + '" ' + query;
}

if (category != "")
{
   query = '+@step\\:category:\"' + category + '" ' + query;
}
if ((createdFrom != "") && (createdTo != ""))
{
   query = '+@step\\:created:\"[' + createdFrom + "' TO '" + createdTo +  ']" ' + query;
}
if ((modifiedFrom != "") && (modifiedTo != ""))
{
   query = '+@step\\:modified:\"[' + modifiedFrom + "' TO '" + modifiedTo +  ']" ' + query;
}

var results = search.luceneSearch(query);

if (results.length > "0")
{
   model.results = results;
}

And the search.get.xml.ftl looks like this
<?xml version="1.0" encoding="UTF-8"?>
<search>
<#list results as row>           
  <item>
   <title>${row.name}</title>
    <link>${absurl(url.serviceContext)}${row.url}</link>
   <category>${row.properties.category!""}</category>
    <description>${row.properties.description!""}</description>
    <pubDate>${xmldate(row.properties.modified)}</pubDate>
   <#if row.properties.keywords?exists>
    <keywords>${row.properties.keywords!""}</keywords>
   </#if>
   <#if row.properties.comments?exists>
    <comments>${row.properties.comments!""}</comments>
   </#if>
   <#if row.properties.policynum?exists>
    <policynum>${row.properties.policynum!""}</policynum>
   </#if>
   <#if row.properties.claimnum?exists>
    <claimnum>${row.properties.claimnum!""}</claimnum>
   </#if>
    <guid isPermaLink="false">${row.id}</guid>
  </item>
</#list>
</search>

Outcomes