Expand my Community achievements bar.

SOLVED

After upgrade com.cognifide.cq doesnt work as expected.

Avatar

Level 4

After applying the upgrade from 6.5.14 to 6.5.15, com.cognifide.cq (sling-dynamic-include) stopped working as it was before the upgrade. Something in the new upgrade package is affected.

Tell me what could be, please.

It looks like the filters don't work anymore, unfortunately, I can't track down what isn't working right. The bundle is active. We are using the 2.0.4 com.cognifide.cq version.

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @aliaksandr_hvozdzeu,

Please find answer for your question below.

Why SDI 2.0.4 is not working after upgrade from AEM 6.5.14 to AEM 6.5.15?

It is because value of javax.servlet.include.servlet_path request attribute has changed. In AEM 6.5.14 you get empty string as value, in 6.5.15 it is null. Above request attribute is used in accepts(SlingHttpServletRequest request) method from com.cognifide.cq.includefilter.processor.IncludeTagWritingProcessor class. Looking into code you can see that in case above attribute is null, accepts method will always return false, so request processing will never end up successfully on SDI level.

 

public boolean accepts(SlingHttpServletRequest request) {
  Object servletPath = request.getAttribute("javax.servlet.include.servlet_path");
  Enumeration<?> params = request.getParameterNames();
  if (params.hasMoreElements()) {
    return false;
  } else if (servletPath == null) {
    return false;
  } else {
    String resourceType = request.getResource().getResourceType();
    return this.config.isSupportedResourceType(resourceType, request);
  }
}

 

https://github.com/wttech/Sling-Dynamic-Include/blob/052b530cac64a1cbcb335103fdb68d56e50cebee/src/ma...

What is the reason of above behavior after upgrade from AEM 6.5.14 to AEM 6.5.15?

Long story short, Apache Felix Http Jetty (org.apache.felix.http.jetty) version has changed from 4.1.12 on AEM 6.5.14 to 4.2.2 on AEM 6.5.15.

Solutions

  • workaround will be to downgraded version of Apache Felix Http Jetty (org.apache.felix.http.jetty) to 4.1.12 on AEM 6.5.15. This will make SDI work, of course this is not recommended approach, because you will end up with AEM version that is not supported. Nevertheless technically this is possible. For education purposes I did this change on my local machine and it worked. In case you would like to verify this on your own, remember to restart AEM after you install Apache Felix Http Jetty (org.apache.felix.http.jetty) older version. Once again, I will point out that this is not recommended way, and if you will decide go that way you're doing it on your own risk.
  • proper way, will be to upgrade SDI version. I understand that in case system is only in support mode, you would like to reduce amount of effort. In that case you can experiment with older versions of SDI, e.g. version 2.1.0 is not rely on javax.servlet.include.servlet_path request attribute, so maybe that will work. However I would consider to upgrade to the latest one, most likely this will eliminate potentially issues after future upgrades of AEM. Last but not least, SDI upgrade does not seem to be difficult, and with new version you will also get new features like regular expression support etc.
    https://sling.apache.org/documentation/bundles/dynamic-includes.html
    https://github.com/apache/sling-org-apache-sling-dynamic-include

View solution in original post

4 Replies

Avatar

Community Advisor

@aliaksandr_hvozdzeu can you please let know the reason why you are using different version other than official apache sdi?

 

https://github.com/apache/sling-org-apache-sling-dynamic-include

This is a very old code that hasn't been changed in a long time. This code is currently only supported. At the moment, we consider the option of making changes as the latest option. Maybe you have an idea what could have affected?

Until 6.5.15 there were no problems.

Avatar

Correct answer by
Community Advisor

Hi @aliaksandr_hvozdzeu,

Please find answer for your question below.

Why SDI 2.0.4 is not working after upgrade from AEM 6.5.14 to AEM 6.5.15?

It is because value of javax.servlet.include.servlet_path request attribute has changed. In AEM 6.5.14 you get empty string as value, in 6.5.15 it is null. Above request attribute is used in accepts(SlingHttpServletRequest request) method from com.cognifide.cq.includefilter.processor.IncludeTagWritingProcessor class. Looking into code you can see that in case above attribute is null, accepts method will always return false, so request processing will never end up successfully on SDI level.

 

public boolean accepts(SlingHttpServletRequest request) {
  Object servletPath = request.getAttribute("javax.servlet.include.servlet_path");
  Enumeration<?> params = request.getParameterNames();
  if (params.hasMoreElements()) {
    return false;
  } else if (servletPath == null) {
    return false;
  } else {
    String resourceType = request.getResource().getResourceType();
    return this.config.isSupportedResourceType(resourceType, request);
  }
}

 

https://github.com/wttech/Sling-Dynamic-Include/blob/052b530cac64a1cbcb335103fdb68d56e50cebee/src/ma...

What is the reason of above behavior after upgrade from AEM 6.5.14 to AEM 6.5.15?

Long story short, Apache Felix Http Jetty (org.apache.felix.http.jetty) version has changed from 4.1.12 on AEM 6.5.14 to 4.2.2 on AEM 6.5.15.

Solutions

  • workaround will be to downgraded version of Apache Felix Http Jetty (org.apache.felix.http.jetty) to 4.1.12 on AEM 6.5.15. This will make SDI work, of course this is not recommended approach, because you will end up with AEM version that is not supported. Nevertheless technically this is possible. For education purposes I did this change on my local machine and it worked. In case you would like to verify this on your own, remember to restart AEM after you install Apache Felix Http Jetty (org.apache.felix.http.jetty) older version. Once again, I will point out that this is not recommended way, and if you will decide go that way you're doing it on your own risk.
  • proper way, will be to upgrade SDI version. I understand that in case system is only in support mode, you would like to reduce amount of effort. In that case you can experiment with older versions of SDI, e.g. version 2.1.0 is not rely on javax.servlet.include.servlet_path request attribute, so maybe that will work. However I would consider to upgrade to the latest one, most likely this will eliminate potentially issues after future upgrades of AEM. Last but not least, SDI upgrade does not seem to be difficult, and with new version you will also get new features like regular expression support etc.
    https://sling.apache.org/documentation/bundles/dynamic-includes.html
    https://github.com/apache/sling-org-apache-sling-dynamic-include