Sunday, April 1, 2018

Different approaches to perform Vanity/Redirect URL management in Adobe Experience Manager(AEM)

Different approach to perform Vanity/Redirect URL management in Adobe Experience Manager(AEM)

In Adobe Experience Manager there is no centralized management UI to manage the Vanity/Redirect URL's also the vanity/Redirects are added into multiple places like Apache and AEM.

This post will explain the different approach to manage the Vanity/Redirect URL through centralized management UI.

Option1: Manage the Vanity URL's through VanityPath page property

  • Build a UI application to read vanityPath properties from the repository content nodes and enable management options - Add, Delete, Modification
  • Refer the following URL for details on this approach - https://helpx.adobe.com/experience-manager/using/vanitypath.html(only working in 6.1)
  • Whitelist vanity paths in dispatcher - https://helpx.adobe.com/experience-manager/dispatcher/using/dispatcher-configuration.html#EnablingAccesstoVanityURLsvanityurls
The same approach can be followed to manage the redirect path enabled in AEM

Vanity URL's are handled in AEM so all the request reaches AEM publisher

Option2 - Manage the Vanity/redirects through AEM UI on XML and redirect through Java Filter


VanityURL_Redirect_Java_Filter


Store the vanity and redirects mapping in a XML file with in AEM repository

<rules>
<rule>
<siteName></siteName>
<code></code>
<sourcePath></sourcePath>
<target></target>

</rule>
<rules>

  • Build a UI application to manage the redirects in the file - modify/remove and add new rules
  • Replicate the mapping XML to publisher on every modification through replication API
  • Build a Java filter that will redirect to the target URL if the vanity path is defined in the XML file(the filter should be restricted only required path)
  • Whitelist the vanitypaths in Apache – Expose the vanitypaths through custom URL(Servlet expose the list of vanity URLs by parsing the XML) and configure the URL in Apache for whitelisting(Refer https://helpx.adobe.com/experience-manager/dispatcher/using/dispatcher-configuration.html#EnablingAccesstoVanityURLsvanityurls for apache configuration, the vanity list URL should be custom)

Vanity/Redirects are handled in AEM so all the request reaches AEM publisher



Wednesday, March 21, 2018

How to resolve Adobe Experience Manager(AEM) pointing to Search and Promote(S&P) Stage environment?

How to resolve Adobe Experience Manager(AEM) pointing to Search and Promote(S&P) Stage environment?


Recently i have faced a issues on AEM publisher pointing to Search and Promote(S&P) stage environment irrespective of the environment configuration in OSGI configuration( Adobe Search&Promote Integration )

Search_and_Promote_integration_config

How to confirm AEM is pointing to S&P stage environment:


Check the content of searchformxml property from /etc/cloudservices/search-promote/<<S&P Config Name>>/jcr:content and check the <action> URL

Stage - <action>http://stage.xxxxx.guided.ss-omtrdc.net</action>
Live - <action>http://xxxxx.guided.ss-omtrdc.net</action>

Search_and_Promote_cloud_config_searchformxml


The following steps can be followed as a workaround:


Decode the data if it is already encoded(HTML Decoder) - searchformxml property from /etc/cloudservices/search-promote/<<S&P Config Name>>/jcr:content

Remove <input type="hidden" name="sp_staged" value="1" />

Change the following URLs to point to live configuration

//content.atomz.com/xxxxx/stage/autocomplete_data.js to //content.atomz.com/xxxxx/publish/autocomplete_data.js
//content.atomz.com/xxxxx/stage/autocomplete_styles.css to //content.atomz.com/xxxxx/publish/autocomplete_styles.css

Change the action to point to live URL

<action>http://stage.xxxxx.guided.ss-omtrdc.net</action> to <action>http://xxxxx.guided.ss-omtrdc.net</action>


e.g - this will be different based on your S&P configuration

<searchform>
<autocomplete>
<enabled>1</enabled>
<css><![CDATA[<link rel="stylesheet" type="text/css" href="//content.atomz.com/xxxxxx/publish/autocomplete_styles.css?sp_css_param=1" />]]></css>
<form-content><![CDATA[<div id="autocomplete"></div>]]></form-content>
<javascript><![CDATA[<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/yui/2.8.0r4/build/utilities/utilities.js" ></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/yui/2.8.0r4/build/datasource/datasource-min.js" ></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/yui/2.8.0r4/build/autocomplete/autocomplete-min.js"></script>
<script type="text/javascript" src="//content.atomz.com/xxxxxx/publish/autocomplete_data.js?sp_js_param=5"></script>]]></javascript>
</autocomplete> <tnt> <enabled>0</enabled> <form-content><![CDATA[<div id="tntMBox"></div>]]></form-content> <javascript><![CDATA[<script type="text/javascript">
(function(){var searchTextBoxId='q';var mboxContainerId='tntMBox';var mboxName='searchParamMbox';function removeEventSimple(obj,evt,fn)
{if(obj.removeEventListener)
obj.removeEventListener(evt,fn,false);else if(obj.detachEvent)
obj.detachEvent('on'+evt,fn);}
function addEventSimple(obj,evt,fn)
{if(obj.addEventListener)
obj.addEventListener(evt,fn,false);else if(obj.attachEvent)
obj.attachEvent('on'+evt,fn);}
function setSearchFormMbox()
{mboxDefine(mboxContainerId,mboxName);mboxUpdate('searchParamMbox');removeEventSimple(el,'keydown',setSearchFormMbox);}
var el=document.getElementById(searchTextBoxId);if(el)
addEventSimple(el,'keydown',setSearchFormMbox);})();</script>
]]></javascript> </tnt> <form>
<name>searchform</name>
<id>searchform</id>
<action>http://xxxxxx.guided.ss-omtrdc.net</action>
<inputs>
<input>
<type><![CDATA[text]]></type>
<id><![CDATA[q]]></id>
<name>q</name>
<value></value>
</input>
<input>
<type><![CDATA[submit]]></type>
<value><![CDATA[Search]]></value>
</input>
</inputs>
</form>
</searchform>

If the same S&P configuration with live option is enabled in any other server then copy and replace the value of searchformxml in /etc/cloudservices/search-promote/<<S&P Config Name>>/jcr:content

I have faced this issue in Adobe Experience Manager(AEM) 6.2 version


Tuesday, March 20, 2018

Different approaches to calculate content/DAM folders size in Adobe Experience Manager(AEM)

Different approaches to calculate content/DAM folders size in Adobe Experience Manager(AEM)

In Adobe Experience Manager(AEM), there is no direct approach to get the size of the specific content node or DAM.

This post explains the different approach to calculate the size for specific content or DAM path

Creating package through package manager:


Create the package through package manager for specific content/DAM path.
Build and download the package and calculate the size.

AEM_create_package_calculate_size


AEM_create_package_calculate_size

This approach will create space issue in server while creating the packages.

Calculate size through WebDav client:


Use any WebDav client to calculate the size of the DAM folders, I have used WinScp tool for size calculation

AEM_Webdav_client_calculate_size


AEM_Webdav_client_calculate_size


AEM_Webdav_client_calculate_size


This approach
- Can be only used for DAM assets as HTML contents are mapped as folders in WedbDav(AEM configuration)
- Can be only used in WebDav enabled AEM instances


Monday, March 12, 2018

Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;Jcr2davRepositoryFactory

I was getting the below exception while connecting to AEM JCR repository through Java API(JCR webdav) using Jcr2davRepositoryFactory.

Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;
at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:229)
at org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory$RepositoryConfigImpl.getCacheBehaviour(Jcr2spiRepositoryFactory.java:272)
at org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory$RepositoryConfigImpl.<init>(Jcr2spiRepositoryFactory.java:229)
at org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory.getRepository(Jcr2davRepositoryFactory.java:104)
at org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory.getRepository(Jcr2davRepositoryFactory.java:87)
at workarea.core.GetRepositorySize.main(GetRepositorySize.java:25)

To fix the issue add the slf4j-log4j12 with lower version and also exclude jcl-over-slf4j from jackrabbit-jcr2dav dependency.

<dependency>
<groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.5.0</version>
</dependency>
 
<!-- https://mvnrepository.com/artifact/org.apache.jackrabbit/jackrabbit-jcr2dav -->
<dependency>
    <groupId>org.apache.jackrabbit</groupId>
    <artifactId>jackrabbit-jcr2dav</artifactId>
    <version>2.17.1</version>
    <scope>provided</scope>
    <exclusions>     
        <exclusion>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>



Wednesday, February 21, 2018

Caused by: java.lang.NoClassDefFoundError: javax/management/InstanceAlreadyExistsException while connecting to Oracle Database from OSGI - Adobe Experience Manager(AEM)

Caused by: java.lang.NoClassDefFoundError: javax/management/InstanceAlreadyExistsException while connecting to Oracle Database from OSGI - Adobe Experience Manager(AEM)

I was getting the below exception while connecting to the Oracle 11g database using ojbdc6.jar from OSGI in Adobe Experience Manager(AEM)

20.02.2018 15:43:39.259 *INFO* [CM Event Dispatcher (Fire ConfigurationEvent: pid=com.day.commons.datasource.jdbcpool.JdbcPoolService.c26da860-d7f1-4e63-9b2c-1138a6bafaeb)] day.commons.datasource.jdbcpool Configuring and activating data source with name=SampleOracleDS
20.02.2018 15:43:39.260 *ERROR* [CM Event Dispatcher (Fire ConfigurationEvent: pid=com.day.commons.datasource.jdbcpool.JdbcPoolService.c26da860-d7f1-4e63-9b2c-1138a6bafaeb)] day.commons.datasource.jdbcpool [com.day.commons.datasource.jdbcpool.JdbcPoolService(2238)] The activate method has thrown an exception (java.lang.IllegalArgumentException: Cannot initialize driver 'oracle.jdbc.driver.OracleDriver')
java.lang.IllegalArgumentException: Cannot initialize driver 'oracle.jdbc.driver.OracleDriver'
at com.day.commons.datasource.jdbcpool.JdbcPoolService.initalizeDriver(JdbcPoolService.java:301)
at com.day.commons.datasource.jdbcpool.JdbcPoolService.setupDataSource(JdbcPoolService.java:227)
at com.day.commons.datasource.jdbcpool.JdbcPoolService.activate(JdbcPoolService.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:222)
at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)
at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:615)
at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:499)
at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:295)
at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:302)
at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:113)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:832)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:799)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:749)
at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:343)
at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:243)
at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:357)
at org.apache.felix.framework.Felix.getService(Felix.java:3671)
at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:470)
at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72)
at org.apache.felix.scr.impl.helper.BindMethod.getServiceObject(BindMethod.java:576)
at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2037)
at org.apache.felix.scr.impl.manager.DependencyManager.invokeUnbindMethod(DependencyManager.java:1712)
at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeUnbindMethod(SingleComponentManager.java:392)
at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:372)
at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:303)
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1518)
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1413)
at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.untrack(ServiceTracker.java:1273)
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1452)
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:987)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)
at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4547)
at org.apache.felix.framework.Felix.access$000(Felix.java:106)
at org.apache.felix.framework.Felix$1.serviceChanged(Felix.java:436)
at org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:165)
at org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:140)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:883)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:857)
at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:140)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.unregisterService(AbstractComponentManager.java:925)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.doDeactivate(AbstractComponentManager.java:774)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.deactivateInternal(AbstractComponentManager.java:757)
at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:601)
at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:552)
at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.configurationUpdated(ConfigurableComponentHolder.java:419)
at org.apache.felix.scr.impl.config.ConfigurationSupport.configurationEvent(ConfigurationSupport.java:297)
at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.sendEvent(ConfigurationManager.java:2032)
at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.run(ConfigurationManager.java:2002)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:103)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: javax/management/InstanceAlreadyExistsException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.day.commons.datasource.jdbcpool.JdbcPoolService.initalizeDriver(JdbcPoolService.java:299)
... 54 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.management.InstanceAlreadyExistsException not found by com.jdbc.oracle [446]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1557)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1998)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 59 common frames omitted

Based on the analysis the classes required by the ojdbc.jar is missing in the generated bundle.

Steps to fix the issue -

Refer the following post for complete steps to integrate Adobe Experience Manager(AEM) with Oracle Database - https://www.albinsblog.com/2015/03/how-to-connect-to-oracle-database-using.html

Add the below Import-Package in META-INF\MANIFEST.MF file

Import-Package: javax.sql, javax.naming, javax.management, org.ietf.jgss


import-package-oracle-osgi-driver


  • Generate the bundle by adding the above configuration(Export --> Deployable plug-ins and fragments)
  • Delete the bundle if already exist in the server
  • Install the updated bundle
  • Restart the server
  • Test the integration