AnsweredAssumed Answered

Root Object 'config' is not defined

Question asked by stevewickii on Dec 10, 2008
I am using Alfresco 2.9.0B build 683 community edition.

I am trying to use the Web Script Configuration documented here: http://wiki.alfresco.com/wiki/2.1_Web_Scripts#Configuring_a_Web_Script

Following the example, my files look like this:

<tomcat_home>/shared/classes/alfresco/extension/web-scripts-config-custom.xml
<alfresco-config>
   <config>
     <server>
        <errorpage>/jsp/error.jsp</errorpage>
        <loginpage>/jsp/login.jsp</loginpage>
        <guesthome enabled="true">/jsp/guesthome.jsp</guesthome>
        <url>/</url>
        <url>/alf</url>
        <url>/alfresco</url>
     </server>
   </config>
</alfresco-config>

alfresco:Company Home/Data Dictionary/Web Scripts/env-test.get.desc.xml
<webscript>
  <shortname>Test ScriptEnvProperties Root Object</shortname>
  <description>This service tests the 'env' root object.</description>
  <url>/env/test</url>
  <format default="html">extension</format>
  <authentication>guest</authentication>
</webscript>

alfresco:Company Home/Data Dictionary/Web Scripts/env-test.get.js
logger.log("env-test.get.js - start");
logger.log("login page: "+config.global.server.childrenMap["loginpage"].value);
logger.log("env-test.get.js - end");

alfresco:Company Home/Data Dictionary/Web Scripts/env-test.get.html.ftl
<h2>Global Properties:</h2>
<li>loginpage = ${config.global.server.childrenMap["loginpage"].value}<br>
</#list>

I get the following error when I invoke: http://localhost:8080/alfresco/s/env/test
500 Description: An error inside the HTTP server which prevented it from fulfilling the request.  
  
Message: Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/env-test.get.js': Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/env-test.get.js': ReferenceError: "config" is not defined. (AlfrescoScript#3) 
  
Exception: org.mozilla.javascript.EcmaError - ReferenceError: "config" is not defined. (AlfrescoScript#3) 
   
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.c2._c0(AlfrescoScript:3) 
org.mozilla.javascript.gen.c2.call(AlfrescoScript) 
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393) 
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834) 
org.mozilla.javascript.gen.c2.call(AlfrescoScript) 
org.mozilla.javascript.gen.c2.exec(AlfrescoScript) 
org.mozilla.javascript.Context.evaluateString(Context.java:1196) 
org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:516) 
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:115) 
org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:243) 
org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:108) 
org.alfresco.web.scripts.AbstractWebScript.executeScript(AbstractWebScript.java:471) 
org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:109) 
org.alfresco.repo.web.scripts.RepositoryContainer$1.execute(RepositoryContainer.java:275) 
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:236) 
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:166) 
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:286) 
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:230) 
org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:227) 
org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:130) 
org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:108) 
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.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:595) 
   
Exception: org.alfresco.error.AlfrescoRuntimeException - ReferenceError: "config" is not defined. (AlfrescoScript#3) 
   
org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:524) 
   
Exception: org.alfresco.service.cmr.repository.ScriptException - Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/env-test.get.js': ReferenceError: "config" is not defined. (AlfrescoScript#3) 
   
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:119) 
   
Exception: org.alfresco.service.cmr.repository.ScriptException - Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/env-test.get.js': Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/env-test.get.js': ReferenceError: "config" is not defined. (AlfrescoScript#3) 
   
org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:247) 
   
Server: Alfresco Community Network v2.9.0 (B 683) schema 116 
Time: Dec 10, 2008 9:55:34 AM 

Outcomes