AnsweredAssumed Answered

Simple webscript in MyAlfresco

Question asked by libman on Oct 29, 2008
Latest reply on Dec 8, 2008 by robain
I have a simple webscript which writes the username of the user. It is been defined as a component for MyAlfresco. When logging as admin, it works. But, other people get an error:

org.alfresco.service.cmr.repository.TemplateException - Error during processing of the template 'Expression person is undefined on line 1, column 9 in org/alfresco/sample/hello.get.html.ftl.'. Please contact your system administrator.
So person is not found. The page:

Hello ${person.properties.userName}

The full traceback:

   freemarker.core.InvalidReferenceException - Expression person is undefined on line 1, column 9 in org/alfresco/sample/hello.get.html.ftl.
   
   freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
   freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
   freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
   freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   freemarker.core.Dot._getAsTemplateModel(Dot.java:74)
   freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   freemarker.core.Expression.getStringValue(Expression.java:93)
   freemarker.core.DollarVariable.accept(DollarVariable.java:76)
   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:201)
   org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:377)
   org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:280)
   org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:173)
   org.alfresco.repo.web.scripts.RepositoryContainer$1.execute(RepositoryContainer.java:309)
   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:294)
   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:209)
   org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:320)
   org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:264)
   org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:240)
   org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)
   org.alfresco.web.scripts.jsf.UIWebScript.encodeBegin(UIWebScript.java:184)
   org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:412)
   org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChildren(RendererUtils.java:400)
   org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:417)
   org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChildren(RendererUtils.java:400)
   org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:417)
   org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:229)
   org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:101)
   javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
   javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:498)
   javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:366)
   org.apache.myfaces.shared_impl.taglib.UIComponentBodyTagBase.doEndTag(UIComponentBodyTagBase.java:57)
   org.apache.jsp.jsp.dashboards.layouts.single_002dcolumn_jsp._jspService(single_002dcolumn_jsp.java:322)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
   org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:594)
   org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:505)
   org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:965)
   org.apache.jsp.jsp.dashboards.container_jsp._jspService(container_jsp.java:487)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
   org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
   org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
   org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
   org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
   org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
   org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
   org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
   javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   org.alfresco.module.vti.VtiContextFilter.doFilter(VtiContextFilter.java:94)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
   org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
   org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
   java.lang.Thread.run(Thread.java:619)

In the documentation I read:

If you are accessing the script engine either through a rule/action (Execute a Script) in the Web Client or through the Script Command Processor then the following objects are available by default in the root scripting scope:
From http://wiki.alfresco.com/wiki/JavaScript_API#Scripting_API

How can I get the person object?

Thanks

Outcomes