cancel
Showing results for 
Search instead for 
Did you mean: 

Webscript worket in 2.0 not working when migrated to 3.0

pmarreddy
Champ in-the-making
Champ in-the-making
Hi, my web script worked very well in alfresco 2.0 not working when we migreated to 3.0 are ther any chages in 3.0, CAN SOMEBODY POINT ME WHERE IT WENT WRONG.

MY FTL
<name><#if test.properties["cm:name"]?exists>${test.properties["cm:name"]}</#if></name>
   <time><#if test.properties["pk:time"]?exists>${test.properties["pk:time"]}</#if></time>   
   <author><#if test.properties["pk:authoredby"]?exists>${test.properties["pk:authoredby"]}</#if></author>   


IT IS GIVING ME THIS ERROR
get(name) failed on instance of org.alfresco.repo.template.TemplateNode
The problematic instruction:
———-
==> if test.name?exists [on line 4, column 15 in sw/gettest.get.html.ftl]
———-

Java backtrace for programmers:
———-
freemarker.template.TemplateModelException: get(name) failed on instance of org.alfresco.repo.template.TemplateNode
   at freemarker.ext.beans.BeanModel.get(BeanModel.java:223)
   at freemarker.core.Dot._getAsTemplateModel(Dot.java:76)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.BuiltIn$existsBI._getAsTemplateModel(BuiltIn.java:639)
   at freemarker.core.BuiltIn$existsBI.isTrue(BuiltIn.java:650)
   at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77)
   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.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:201)
   at org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:504)
   at org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:252)
   at org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:145)
   at org.alfresco.repo.web.scripts.RepositoryContainer$1.execute(RepositoryContainer.java:307)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:294)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:209)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:318)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:340)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:262)
   at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:240)
   at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)
   at org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.alfresco.web.app.servlet.MTWebScriptAuthenticationFilter.doFilter(MTWebScriptAuthenticationFilter.java:102)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
   at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:835)
   at freemarker.ext.beans.BeanModel.invokeThroughDescriptor(BeanModel.java:276)
   at freemarker.ext.beans.BeanModel.get(BeanModel.java:183)
   … 41 more
Caused by: java.lang.UnsupportedOperationException
   at java.util.AbstractList.set(AbstractList.java:115)
   at org.alfresco.repo.template.PropertyConverter.convertProperty(PropertyConverter.java:62)
   at org.alfresco.repo.template.TemplateNode$TemplatePropertyConverter.convertProperty(TemplateNode.java:533)
   at org.alfresco.repo.template.TemplateNode.getProperties(TemplateNode.java:221)
   at org.alfresco.repo.template.TemplateNode.getName(TemplateNode.java:186)
   … 48 more
1 REPLY 1

mikeh
Star Contributor
Star Contributor
Could you post more of the FTL please? It seems like those three lines aren't the ones causing problems.

Also note you could simplify those statements to:
<name>${test.properties["cm:name"]!""}</name>

Thanks,
Mike