alfrescoaikau

Alfresco Aikau service load error, why isn't the service javascript file properly found or loaded?


I am having problem with adding custom widgets and services to an aikau webscript-based page. It seems to me it cannot load the model properly. But I cannot understand the reason for it. It is properly included (from what I can see..?), and it is syntactically correct javascript (I've more or less copied and shaved down a tutorial), and called from an otherwise working Aikau page. Why isn't it working? :(

The project resides in an All-In-One SDK project. I've followed the instructions on the alfresco page for Aikau widgets: https://docs.alfresco.com/5.2/concepts/dev-extensions-share-aikau-widgets.html

that is, defining a .js file, placed it in the correct folder (, and created an extension module to point to its location.

The actual content (the file serves the purpose of an Aikau Service) is based on the placeholder Service from the Aikau github tutorials: https://github.com/Alfresco/Aikau/blob/master/tutorial/chapters/Tutorial7.md

The extension module

<module>
            <id>Company Aikau Widgets</id>
            <version>1.0.1</version>
            <auto-deploy>true</auto-deploy>
            <configurations>
                <config evaluator="string-compare" condition="WebFramework"
                    replace="false">
                    <web-framework>
                        <dojo-pages>
                            <packages>
                                <package name="example"
                                    location="js/company" />
                            </packages>
                        </dojo-pages>
                    </web-framework>
                </config>
            </configurations>
        </module>

The page (helloworld2.get.js) content, works fine as long as ProcessService isn't included.

model.jsonModel = {
    services: [
        "alfresco/services/ActionService",
        "company/services/ProcessService"
   ],
    widgets: [
        {
            id: "SET_PAGE_TITLE",
            name: "alfresco/header/SetTitle",
            config: {
                title: "Process\u00F6versikt"
            }
        },
        {
            name: "alfresco/buttons/AlfButton",
            config: {
                label: "HELLO BUTTON",
                iconClass: "alf-folder-up-icon",
                publishTopic: "SEARCH_BUTTON_PRESS"
            }
        }
    ]
}; 

The ProcessService.js, located in share-jar-project/src/main/resources/alfresco/web-extension/site-data/extensions/js/company/services/

define(["dojo/_base/declare",
        "alfresco/core/Core",
        "dojo/_base/lang"],
        function(declare, Core, lang) {   
        return declare([Core], {    

            constructor: function tutorial_UserAndGroupService__constructor(args) {
            lang.mixin(this, args);
            this.alfSubscribe("SEARCH_BUTTON_PRESS", lang.hitch(this, this.runWebscript));
        },

        runWebscript: function tutorial_UserAndGroupService__getGroups(payload) {
            console.log("service works.");
        },
    });
});

The outcome puzzles me. Firstly, regardless if the service is actually included or not in the page, I get an error message saying (during login-page-load):

2019-08-02 09:22:46,737  WARN  [surf.persister.AbstractStoreObjectPersister] [http-bio-8080-exec-8] Failure to load model object for path: extensions/js/company/services/ProcessService.js
org.springframework.extensions.surf.exception.ModelObjectPersisterException: Failure to load model object for path: extensions/js/company/services/ProcessService.js
        at org.springframework.extensions.surf.persister.ReadOnlyStoreObjectPersister.getObjectByPath(ReadOnlyStoreObjectPersister.java:628)
        at org.springframework.extensions.surf.persister.AbstractStoreObjectPersister.getObjectsFromPaths(AbstractStoreObjectPersister.java:374)
        at org.springframework.extensions.surf.persister.AbstractStoreObjectPersister.getAllObjects(AbstractStoreObjectPersister.java:311)
        at org.springframework.extensions.surf.persister.MultiObjectPersister.getAllObjects(MultiObjectPersister.java:399)
        at org.springframework.extensions.surf.ObjectPersistenceService.getAllObjects(ObjectPersistenceService.java:452)
        at org.springframework.extensions.surf.ModelObjectService.getAllObjects(ModelObjectService.java:616)
        at org.springframework.extensions.surf.ModuleDeploymentService.getExtensionModules(ModuleDeploymentService.java:368)
        at org.springframework.extensions.surf.ModuleDeploymentService.getAllConfiguredExtensionModules(ModuleDeploymentService.java:353)
        at org.springframework.extensions.surf.ModuleDeploymentService.getDeployedModules(ModuleDeploymentService.java:471)
        at org.springframework.extensions.surf.extensibility.impl.BasicExtensibilityModuleHandler.evaluateModules(BasicExtensibilityModuleHandler.java:191)
        at org.springframework.extensions.surf.support.AbstractRequestContext.getEvaluatedModules(AbstractRequestContext.java:1008)
        at org.springframework.extensions.surf.support.AbstractRequestContext.getExtendingModuleFiles(AbstractRequestContext.java:1221)
        at org.springframework.extensions.webscripts.WebTemplateProcessor.executeScriptBodyExtensions(WebTemplateProcessor.java:237)
        at org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:348)
        at org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:58)
        at org.springframework.extensions.surf.render.RenderService.processTemplate(RenderService.java:724)
        at org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.calculateComponentDependencies(TemplateInstanceRenderer.java:77)
        at org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.body(TemplateInstanceRenderer.java:136)
        at org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:78)
        at org.springframework.extensions.surf.render.bean.PageRenderer.body(PageRenderer.java:86)
        at org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:78)
        at org.springframework.extensions.surf.render.RenderService.renderPage(RenderService.java:770)
        at org.springframework.extensions.surf.mvc.PageView.dispatchPage(PageView.java:412)
        at org.springframework.extensions.surf.mvc.PageView.renderView(PageView.java:251)
        at org.springframework.extensions.surf.mvc.AbstractWebFrameworkView.renderMergedOutputModel(AbstractWebFrameworkView.java:321)
        at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1216)
        at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1001)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:842)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:827)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.springframework.extensions.webscripts.servlet.SecurityHeadersFilter.doFilter(SecurityHeadersFilter.java:177)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.springframework.extensions.webscripts.servlet.CSRFFilter.doFilter(CSRFFilter.java:322)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:474)
        at org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:443)
        at org.springframework.extensions.webscripts.servlet.BeanProxyFilter.doFilter(BeanProxyFilter.java:80)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.dom4j.DocumentException: Error on line 1 of document  : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
        at org.dom4j.io.SAXReader.read(SAXReader.java:482)
        at org.dom4j.DocumentHelper.parseText(DocumentHelper.java:278)
        at org.springframework.extensions.surf.util.XMLUtil.parse(XMLUtil.java:221)
        at org.springframework.extensions.surf.util.XMLUtil.parse(XMLUtil.java:237)
        at org.springframework.extensions.surf.persister.ReadOnlyStoreObjectPersister.getObjectByPath(ReadOnlyStoreObjectPersister.java:602)
        ... 67 more

Secondly, when I try to load the actual page, I get the error messages

2019-08-02 09:32:32,706  ERROR [extensions.surf.DependencyAggregator] [http-bio-8080-exec-2] Could not find compressed file: /company/services/ProcessService.js

I must have missed something, but what?


Solution

  • Seeing as posts cannot be deleted and I found the cause(s) of this error, I thought should answer my own question.

    There are several causes of this problem. Firstly, the extension module widget location value is wrong. At least for me, the tutorials specified it wrongly. Were they wanted something like

    <package name="example" location="js/company" />
    

    should be something like

    <package name="company" location="resources/maven-sdk-tutorial-share-jar/js/company"/>
    

    Notice I changed the package name. This is the second cause. When I checked the active packages, there was already a package named example, with another location. Always make sure you change the name as well, don't do like I do and lazily stick with "example" or "tutorial".

    The third cause was that I put the widget files in the wrong location.

    The ProcessService.js, located in

    share-jar-project/src/main/resources/alfresco/web-extension/site-data/extensions/js/company/services/
    

    should actually be located in

    /share-jar-project/src/main/resources/META-INF/resources/share-jar-project/js/omicron/services/
    

    This was just me reading too fast. In the documentation pages it is specified where things should be deployed https://docs.alfresco.com/5.2/concepts/dev-extensions-share-aikau-widgets.html I placed the widget in the path for the extension module instead, which obviously is wrong.

    So to conclude;

    1. make sure you have the right specified location
    2. make sure you give everything a unique name
    3. make sure you put the files where the documentation specifies

    phew. I think that was all of it. Hopefully the next person can find this useful.