AnsweredAssumed Answered

Javascript Controller Fails

Question asked by mduduzi on Jun 27, 2013
Latest reply on Jun 28, 2013 by scouil
Hi,

I am executing a script in the javascript console and it works. When I use the very same script in a web script and deploy it in web script extension folder it compains. Pasted below is the part of the script that fails and the error log:


var ctx =Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var qname = Packages.org.alfresco.service.namespace.QName;
var def = Packages.org.alfresco.service.cmr.dictionary;
var ns = Packages.org.alfresco.service.namespace.NamespaceService;
var iterator = Packages.java.util.Iterator;
//var ListOfValuesConstraint = new Packages.org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
var dictionaryService = ctx.getBean("DictionaryService");


error log


The Web Script /alfresco/service/sita/projserv/projservregister/ 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:   05280246 Wrapped Exception (with status template): 05281343 Failed to execute script '/Project And Service Register/projservregister.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': 05281342 ReferenceError: "Packages" is not defined. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Project And Service Register/projservregister.get.js#1)

Exception:   org.mozilla.javascript.EcmaError - ReferenceError: "Packages" is not defined. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Project And Service Register/projservregister.get.js#1)

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.c66._c0(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Project And Service Register/projservregister.get.js:1)
org.mozilla.javascript.gen.c66.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Project And Service Register/projservregister.get.js)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
org.mozilla.javascript.gen.c66.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Project And Service Register/projservregister.get.js)
org.mozilla.javascript.gen.c66.exec(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Project And Service Register/projservregister.get.js)
org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:492)
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:198)
org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:212)
org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:174)
org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)
org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1305)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:417)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:401)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:479)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:517)
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:333)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
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.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
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:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
java.lang.Thread.run(Thread.java:662)

Exception:   org.alfresco.error.AlfrescoRuntimeException - 05281342 ReferenceError: "Packages" is not defined. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Project And Service Register/projservregister.get.js#1)

org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:516)

Exception:   org.alfresco.scripts.ScriptException - 05281343 Failed to execute script '/Project And Service Register/projservregister.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': 05281342 ReferenceError: "Packages" is not defined. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Project And Service Register/projservregister.get.js#1)

org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:202)

Exception:   org.springframework.extensions.webscripts.WebScriptException - 05280246 Wrapped Exception (with status template): 05281343 Failed to execute script '/Project And Service Register/projservregister.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': 05281342 ReferenceError: "Packages" is not defined. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Project And Service Register/projservregister.get.js#1)

org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1067)


THanks!

Outcomes