• Categories

  • Solving a Common Problem with AEM and Windows Services

    By Scott Ross

    You decided to take the plunge and invested in a full stack AEM development environment.  To keep things compact, AEM author, publisher, and dispatcher are installed on a single server.  Because you care, you have taken the extra time to set AEM to run as Windows services. 

     

    Great job.

     

    Everything is working as expected.  Development workflow has improved and best of all your team can finally test client libraries and caching behaviour in a real world setting.

     

    But something isn’t quite right. One day, after restarting the AEM Author service you get an error message that looks like this:

     

     

    After a bit of experimentation, you manage to get the Author service started again, but it only works when the AEM Publish service is stopped.  Similarly (and frustratingly) the Publish service only runs when the Author service is stopped.  Getting both Author and Publish services to run at the same time seems impossible.

     

    What is going on?

     

    This is a very common problem, and today we are going to answer that question.  We will explain what is happening, how to get Author and Publish working together again, and how to avoid the problem in the first place.

     

    DIAGNOSIS

     

    When troubleshooting, logs are a valuable tool.  In AEM, log files are located under “crx-quickstart\logs.”  For service start issues, “startup.log” is the ideal starting point.

     

    Here is what it contains:

     

     

    Based on the details it might be tempting to think this is a licensing issue (ERR: Wrong Key), but it’s not. 

     

    The more significant clue comes from the last line, “Sling already active.” Windows uses a control port to manage AEM when run as a service.  The problem here is we have used the same control port for both the Author and Publish services.  Here is how to fix it.

     

    REUNITING AUTHOR AND PUBLISH

     

    Step 1. Stop Author and Publish Services

    Use the Services Console to stop both services.  When done, the Services Console will look similar to this:

     

     

    Step 2. Remove Author and Publish Services

    You can do this using the uninstall option of the “instsrv.bat” helper.

     

     

    You can also use the “SC” Windows command, like this:

     

     

    Step 3. Delete “controlport” Files

    These files located under “crx-quickstart\conf” on both Author and Publish.  This file stores control port detail used by the system.  There is no need to worry this file will be automatically recreated for you.

     

     

    Step 4.  Update the “instsrv.bat” Helper

    This step only needs to happen on Author or on Publish.  We’ve chosen to leave the author instance alone, and have made configuration changes on Publish only.

     

    The “instsrv.bat” file lives under “crx-quickstart\opt\helpers” and it is editable using a text editor.  The formatting of the file content is an issue, making Notepad a poor choice for the job.  We have used Wordpad here but other editors will work too.

     

    Find the control port section and change the port number to something other than the default 63000.  We chose 63001.  Make sure to use a high range port not already in use.

     

     

    Save your changes.

     

    Step 5.  Recreate AEM Author and Publisher Services

    In an administrative command prompt, navigate to “crx-quickstart\opt\helpers” and run “instsrv.bat” first on Author and then on Publish.  Provide a meaningful service name as this will show up in the Services list in Windows.  We ran the following commands:

     

    ·        Instsrv.bat AEM-6.2-Author, and

    ·        Instsrv.bat AEM-6.2-Publish

     

    Once done, we have successfully registered our two services. 

     

     

    Before moving on, start both services.  Both services should start now.

     

    Step 6. Verify Control Port Settings

    If you look under “crx-quickstart\conf” you will notice the “controlport” file will have been recreated for you.  Confirming the port settings is as simple as opening this file up in Notepad.

     

    Our configuration file for Author looks like this:

     

     

    And on Publish, we can see our new port (63001) is now being used.

     

     

    WRAPPING UP

     

    At this point your development environment is back on track, and Author and Publish are happily reunited.

     

    If you haven’t set your development environment up yet, join in at Step 4 and work your way through until the end.

     

     

    Need a hand?
    Contact Us