Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Styles not replicating to publish instance

Avatar

Level 3

Hi there,

We have an annoying problem in which all styles are not being published to the publish instances - It works well on author.

Let me explain it. Our team is working in a brand new website, and in our last release (that we haven't deployed yet because of this problem), we started using AEM Styles, that was introduced in Adobe AEM version 6.3.

We declare a class in a given CSS file and then create a Policy using the template authoring environment. Then, we open some page, click in the component and select the style that was configured.

Everything works fine in the author instance. But the styles are not being published correctly to the publish instance.

We tried everything and it didn't work.

Analysing the problem, the CSS classes are being generated correctly. But the style classes (that are the reference) are not being inserted in the component's HTML class attribute.

We are using AEM 6.4.4, but the problem, as we have tested, happens in version 6.4.0 and 6.4.1 too.

I have compared css files, js files and html/htl files of both instances, and the only difference, as I mentioned above, is in the HTML/HTL output, which are missing the styles classes. CSS and JS have the same in both instances.

Anyone knows a solution for this?

1 Accepted Solution

Avatar

Correct answer by
Level 3

Hi there people,

Thanks for your help. We've been able to solve the problem by doing the following:

1) First, in `ui.content`'s folder `pom.xml` file, we had to add the `properties` configuration to the Vault Package Plugin. We are using `Overwrite` here, but `MergePreserve` may be a better option:

<build>

  ...

  <plugins>

      ...

      <plugin>

         <groupId>com.day.jcr.vault</groupId>

         <artifactId>content-package-maven-plugin</artifactId>

         ...

         <configuration>

            <properties>

               <acHandling>Overwrite</acHandling>

            </properties>

         </configuration>

         ...

      </plugin>

   ...

   </plugins>

   ...

</build>

2) Second, we had to create a `_rep_policy.xml` file for each of the following paths:

  • /conf/oursite/settings/wcm/policies/_rep_policy.xml

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:crx="http://www.day.com/crx/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"

    jcr:primaryType="rep:ACL">

    <allow

        jcr:primaryType="rep:GrantACE"

        rep:principalName="everyone"

        rep:privileges="{Name}[jcr:read]"/>

    <allow1

        jcr:primaryType="rep:GrantACE"

        rep:principalName="content-authors"

        rep:privileges="{Name}[crx:replicate]"/>

    <allow2

        jcr:primaryType="rep:GrantACE"

        rep:principalName="template-authors"

        rep:privileges="{Name}[jcr:versionManagement,crx:replicate,rep:write,jcr:lockManagement]"/>

</jcr:root>

  • /conf/oursite/settings/wcm/template-types/_rep_policy.xml

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"

    jcr:primaryType="rep:ACL">

    <allow

        jcr:primaryType="rep:GrantACE"

        rep:principalName="template-authors"

        rep:privileges="{Name}[jcr:read]"/>

</jcr:root>

  • /conf/oursite/settings/wcm/template/_rep_policy.xml

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"

    jcr:primaryType="rep:ACL">

    <allow

        jcr:primaryType="rep:GrantACE"

        rep:principalName="anonymous"

        rep:privileges="{Name}[jcr:read]"/>

    <allow1

            jcr:primaryType="rep:GrantACE"

            rep:principalName="everyone"

            rep:privileges="{Name}[jcr:read]"/>

    <allow2

            jcr:primaryType="rep:GrantACE"

            rep:principalName="content-authors"

            rep:privileges="{Name}[crx:replicate]"/>

    <allow3

            jcr:primaryType="rep:GrantACE"

            rep:principalName="template-authors"

            rep:privileges="{Name}[jcr:versionManagement,crx:replicate,rep:write,jcr:lockManagement]"/>

</jcr:root>

3) After changing the pom and adding the code above, just build your project normally and install it at your author's instance. Then, go to Package Manager and replicate the installed packages as normal;

3) And finally, you have to go to the authoring environment:

a) Go to Templates section, choose the desired template, do some change in any of the policies for any of the components (or just add a fake one);

b) Publish the changes.

4) That's what we had to do.

It is a little bit pain in the a*s, because we didn't find any documentation available, and we tried to get some idea looking at the We Retail code.

I also don't know if there is a better way doing it, but it worked for us.

View solution in original post

5 Replies

Avatar

Employee Advisor

Have you ensured that the templates and associated policies have been published as well? There are also permissions associated with templates that need to be set on the publish environment so that it can be read by the anonymous user...

Avatar

Level 10

There is something missing on the Pub instance. If everything is the same as exists on the Auth instance - you will get the same results

Avatar

Correct answer by
Level 3

Hi there people,

Thanks for your help. We've been able to solve the problem by doing the following:

1) First, in `ui.content`'s folder `pom.xml` file, we had to add the `properties` configuration to the Vault Package Plugin. We are using `Overwrite` here, but `MergePreserve` may be a better option:

<build>

  ...

  <plugins>

      ...

      <plugin>

         <groupId>com.day.jcr.vault</groupId>

         <artifactId>content-package-maven-plugin</artifactId>

         ...

         <configuration>

            <properties>

               <acHandling>Overwrite</acHandling>

            </properties>

         </configuration>

         ...

      </plugin>

   ...

   </plugins>

   ...

</build>

2) Second, we had to create a `_rep_policy.xml` file for each of the following paths:

  • /conf/oursite/settings/wcm/policies/_rep_policy.xml

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:crx="http://www.day.com/crx/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"

    jcr:primaryType="rep:ACL">

    <allow

        jcr:primaryType="rep:GrantACE"

        rep:principalName="everyone"

        rep:privileges="{Name}[jcr:read]"/>

    <allow1

        jcr:primaryType="rep:GrantACE"

        rep:principalName="content-authors"

        rep:privileges="{Name}[crx:replicate]"/>

    <allow2

        jcr:primaryType="rep:GrantACE"

        rep:principalName="template-authors"

        rep:privileges="{Name}[jcr:versionManagement,crx:replicate,rep:write,jcr:lockManagement]"/>

</jcr:root>

  • /conf/oursite/settings/wcm/template-types/_rep_policy.xml

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"

    jcr:primaryType="rep:ACL">

    <allow

        jcr:primaryType="rep:GrantACE"

        rep:principalName="template-authors"

        rep:privileges="{Name}[jcr:read]"/>

</jcr:root>

  • /conf/oursite/settings/wcm/template/_rep_policy.xml

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"

    jcr:primaryType="rep:ACL">

    <allow

        jcr:primaryType="rep:GrantACE"

        rep:principalName="anonymous"

        rep:privileges="{Name}[jcr:read]"/>

    <allow1

            jcr:primaryType="rep:GrantACE"

            rep:principalName="everyone"

            rep:privileges="{Name}[jcr:read]"/>

    <allow2

            jcr:primaryType="rep:GrantACE"

            rep:principalName="content-authors"

            rep:privileges="{Name}[crx:replicate]"/>

    <allow3

            jcr:primaryType="rep:GrantACE"

            rep:principalName="template-authors"

            rep:privileges="{Name}[jcr:versionManagement,crx:replicate,rep:write,jcr:lockManagement]"/>

</jcr:root>

3) After changing the pom and adding the code above, just build your project normally and install it at your author's instance. Then, go to Package Manager and replicate the installed packages as normal;

3) And finally, you have to go to the authoring environment:

a) Go to Templates section, choose the desired template, do some change in any of the policies for any of the components (or just add a fake one);

b) Publish the changes.

4) That's what we had to do.

It is a little bit pain in the a*s, because we didn't find any documentation available, and we tried to get some idea looking at the We Retail code.

I also don't know if there is a better way doing it, but it worked for us.

Avatar

Level 2

To add one more data point, we had this issue when installing content packages from one environment A to another environment B. We expected style classes installed via the package in environment B to carry through to the publish instance on environment B, but that wasn't the case. We were able to see the styles render correctly in both author editor mode and "view as published" in environment B, but not in the actual published environment post-publishing, because the classes weren't being added to the HTML in publish.

 

We solved the issue by going into the template, clicking on the style policy for the component whose styles were not populating, clicked "Done," then rolled out the page that used that style and published it. Then, the styles populated correctly. It seems that you need to manually do this before the publish instance will recognize the style, despite rolling out and publishing the page containing that style.