AnsweredAssumed Answered

'people' not defined - creating new users from external site

Question asked by gawabe on Oct 4, 2010
Latest reply on Oct 19, 2010 by marcoq82
Hi…
I am using alfresco community edition 3.3g… I created a new website using springsurf with alfresco as my repository. Now I need to have a registration page in that website. For that I planned to go with webscripts - javascripts API… Connected my website and alfresco by updating the surf.xml (http://www.tumblr.com/tagged/Spring+Roo)

Created new directory with the name registration under webscripts directory of my website..
Created 3 files: registration.get.desc.xml, registration.get.js and registration.get.html.ftl
registration.get.desc.xml
<webscript>
  <shortname>Registration Page</shortname>
  <description>Registration Page</description>
  <url>/registrationPage</url>
</webscript>

registration.get.js
var firstName = args.firstName;
var lastName = args.lastName;
var emailId = args.emailId;
var newUser = people.createPerson(firstName,lastName,emailId, true ,true);
newUser.save();

registration.get.html.ftl
<form accept-charset="UTF-8" method="post" action="${url.context}/dologin">
<table>
   <tr>
      <td>
         <h1>Registeration Form </h1>
      </td>
   </tr>
   <tr>
      <td>
         <table>
            <tr>
               <td><b>First Name:</b></td>
               <td><input name="firstName" type="text" /></td>
            </tr>
            <tr>
               <td><b>Last Name:</b></td>
               <td><input name="lastName" type="text"/></td>
            </tr>
            <tr>
               <td><b>Email Id</b></td>
               <td><input name="emailId" type="text" /></td>
            </tr>
         </table>
      </td>
   </tr>
   <tr>
      <td>
         <input type="submit" value="Register" />
         <input name="success" type="hidden" value="${url.context}" />
         <input name="failure" type="hidden" value="${url.context}/registration" />
      </td>
   </tr>
</table>
</form>

I can deploy and view my website in http://localhost:8081/mysite and I am  running alfresco in the port 8080..  I can retrieve the alfresco user details successfully and view them in my website. But there is some problem in creating new alfresco users..

When I click registration tab, I am getting an error as "people" is not defined..

The Web Script /mysite/service/registrationPage has responded with a status of 500 - Internal Error.

500 Description:    An error inside the HTTP server which prevented it from fulfilling the request.

Message:   09040003 Failed to load script 'org.springframework.extensions.webscripts.ResourceStore$WebApplicationStoreScriptContent@c74fe': 09040002 ReferenceError: "people" is not defined. (/WEB-INF/webscripts/registration/registration.get.js#4)

Exception:   org.mozilla.javascript.EcmaError - ReferenceError: "people" is not defined. (/WEB-INF/webscripts/registration/registration.get.js#4)

org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3413)
org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1612)
org.mozilla.javascript.gen.c5._c0(/WEB-INF/webscripts/registration/registration.get.js:4)
org.mozilla.javascript.gen.c5.call(/WEB-INF/webscripts/registration/registration.get.js)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
org.mozilla.javascript.gen.c5.call(/WEB-INF/webscripts/registration/registration.get.js)
org.mozilla.javascript.gen.c5.exec(/WEB-INF/webscripts/registration/registration.get.js)
org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScriptImpl(JSScriptProcessor.java:292)
org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:178)
org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:952)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:69)
org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:182)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:307)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:178)
org.springframework.extensions.webscripts.WebScriptProcessor.executeBody(WebScriptProcessor.java:275)
org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:79)
org.springframework.extensions.surf.render.RenderService.processComponent(RenderService.java:468)
org.springframework.extensions.surf.render.RenderService.renderRawComponent(RenderService.java:970)
org.springframework.extensions.surf.render.RenderService.renderRawComponent(RenderService.java:957)
org.springframework.extensions.surf.taglib.ComponentIncludeTag.doStartTag(ComponentIncludeTag.java:39)
org.springframework.extensions.surf.render.TagService.execute(TagService.java:214)
org.springframework.extensions.surf.render.TagService.execute(TagService.java:148)
org.springframework.extensions.webscripts.FreemarkerTagSupportDirective.executeTag(FreemarkerTagSupportDirective.java:92)
org.springframework.extensions.webscripts.GenericFreemarkerTagDirective.execute(GenericFreemarkerTagDirective.java:121)
freemarker.core.Environment.visit(Environment.java:261)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
freemarker.core.Environment.visit(Environment.java:208)
freemarker.core.Environment.process(Environment.java:188)
freemarker.template.Template.process(Template.java:237)
org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:156)
org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:312)
org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:79)
org.springframework.extensions.surf.render.RenderService.processRenderable(RenderService.java:390)
org.springframework.extensions.surf.render.bean.ChromeRenderer.body(ChromeRenderer.java:49)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:131)
org.springframework.extensions.surf.render.bean.ComponentRenderer.body(ComponentRenderer.java:107)
org.springframework.extensions.surf.render.RenderService.renderRegionComponents(RenderService.java:827)
org.springframework.extensions.surf.taglib.RegionIncludeTag.doStartTag(RegionIncludeTag.java:36)
org.springframework.extensions.surf.render.TagService.execute(TagService.java:214)
org.springframework.extensions.surf.render.TagService.execute(TagService.java:148)
org.springframework.extensions.webscripts.FreemarkerTagSupportDirective.executeTag(FreemarkerTagSupportDirective.java:92)
org.springframework.extensions.webscripts.GenericFreemarkerTagDirective.execute(GenericFreemarkerTagDirective.java:121)
freemarker.core.Environment.visit(Environment.java:261)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
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.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:156)
org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:312)
org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:79)
org.springframework.extensions.surf.render.RenderService.processRenderable(RenderService.java:390)
org.springframework.extensions.surf.render.bean.ChromeRenderer.body(ChromeRenderer.java:49)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:131)
org.springframework.extensions.surf.render.bean.RegionRenderer.body(RegionRenderer.java:114)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:131)
org.springframework.extensions.surf.render.RenderService.startRegionRenderer(RenderService.java:779)
org.springframework.extensions.surf.render.RenderService.renderRegion(RenderService.java:723)
org.springframework.extensions.surf.render.PresentationUtil.renderRegion(PresentationUtil.java:134)
org.springframework.extensions.surf.taglib.RegionTag.doStartTag(RegionTag.java:101)
org.springframework.extensions.surf.render.TagService.execute(TagService.java:214)
org.springframework.extensions.surf.render.TagService.execute(TagService.java:148)
org.springframework.extensions.webscripts.FreemarkerTagSupportDirective.executeTag(FreemarkerTagSupportDirective.java:92)
org.springframework.extensions.webscripts.RegionFreemarkerTagDirective.execute(RegionFreemarkerTagDirective.java:122)
freemarker.core.Environment.visit(Environment.java:261)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
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.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:156)
org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:312)
org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:79)
org.springframework.extensions.surf.render.RenderService.processTemplate(RenderService.java:582)
org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.body(TemplateInstanceRenderer.java:124)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:131)
org.springframework.extensions.surf.render.bean.PageRenderer.body(PageRenderer.java:70)
org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:131)
org.springframework.extensions.surf.render.RenderService.startPageRenderer(RenderService.java:664)
org.springframework.extensions.surf.render.RenderService.renderPage(RenderService.java:641)
org.springframework.extensions.surf.render.PresentationUtil.renderPage(PresentationUtil.java:95)
org.springframework.extensions.surf.mvc.PageView.dispatchPage(PageView.java:349)
org.springframework.extensions.surf.mvc.PageView.renderView(PageView.java:290)
org.springframework.extensions.surf.mvc.AbstractWebFrameworkView.renderMergedOutputModel(AbstractWebFrameworkView.java:136)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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:127)
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:298)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
java.lang.Thread.run(Unknown Source)

Exception:   org.springframework.extensions.webscripts.WebScriptException - 09040002 ReferenceError: "people" is not defined. (/WEB-INF/webscripts/registration/registration.get.js#4)

org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScriptImpl(JSScriptProcessor.java:302)

Exception:   org.springframework.extensions.webscripts.WebScriptException - 09040003 Failed to load script 'org.springframework.extensions.webscripts.ResourceStore$WebApplicationStoreScriptContent@c74fe': 09040002 ReferenceError: "people" is not defined. (/WEB-INF/webscripts/registration/registration.get.js#4)

org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:182)

Server:   Alfresco - v1.0.0 (Milestone 3 349) schema 1,000
Time:   Oct 4, 2010 2:18:40 PM

Diagnostics:   Inspect Web Script (webscripts/registration/registration.get)

Why it is so? If I need to create an alfresco users from an external website, do I need to configure anywhere in alfresco? and is the dologin action in the ftl is correct?
Thanks…

Outcomes