Tuesday, December 4, 2018

How to use Index Connector in Adobe Search and Promote

How to use Index Connector in Adobe Search and Promote


This tutorial explains the details on how to use Index Connector in Adobe Search and Promote.


Index Connector


Index Connector enable us to define additional input sources for indexing XML pages or any kind of feed.

Search and Promote allows us to add the website URL’s as an entry point to crawl the pages for indexing, the URL’s also can be crawled and indexed through Index Connector.(the URL entry points and Index Connectors can be defined together for crawling and indexing)

For example, the Index Connector can be used to index the large number of product data from eCommerce systems to reduce the crawling and indexing time. Index Connector approach provides better crawling/indexing performance.

A XML data feed consists of records corresponds to the individual documents that can be added to the index

A text data feed contains new-line-delimited records corresponds to the individual documents that can be added to the index

Mapping can be enabled to map the feed data to the metadata fields in the resulting index

Multiple protocols can be used to connect to the input feed sources from Index Connector — HTTP(S)/FTP/SFTP/FILE



The IndexConnector is not enabled by default in S&P account, the same should be enabled by Adobe S&P account team.

Define Index Connector



After enabling the Index Connector to the account, the same can be accessed from Settings →Crawling →Index Connector




As a first step add a Index Connector



Sample product feed file(XML)

<feed xmlns:xs=”http://www.w3.org/2001/XMLSchema" version=”2.0">
<channel>
<title>Product Feed</title>
<Item>
<title>
<![CDATA[product-title]]>
</title>
<pubDate>05/09/2011</pubDate>
<pubYear>2011</pubYear>
<description>
<![CDATA[<p>product description</p>]]>
</description>
<productType>Research</productType>
<category>
<![CDATA[Financial Planning|Financial Planners|Research]]>
</category>
<ProductId>123</ProductId>
<imageUrl>/content/dam/Images/product/123.jpg</imageUrl>
</Item>
<Item>
<title>
<![CDATA[product-title]]>
</title>
<pubDate>05/09/2011</pubDate>
<pubYear>2011</pubYear>
<description>
<![CDATA[<p>product description</p>]]>
</description>
<productType>Research</productType>
<category>
<![CDATA[Financial Planning|Financial Planners|Research]]>
</category>
<ProductId>1234</ProductId>
<imageUrl>/content/dam/Images/product/1234.jpg</imageUrl>
</Item>
<Item>
<link>https:/www.example.com/product-title/p/12345</link>
<title>
<![CDATA[product-title]]>
</title>
<pubDate>05/09/2011</pubDate>
<pubYear>2011</pubYear>
<description>
<![CDATA[<p>product description</p>]]>
</description>
<productType>Research</productType>
<category>
<![CDATA[Financial Planning|Financial Planners|Research]]>
</category>
<ProductId>12345</ProductId>
<imageUrl>/content/dam/Images/product/12345.jpg</imageUrl>
</Item>
</channel>
</feed>

The feed file is available through HTTP(S) URL — www.example.com/product/feed.xml, the Index Connector can also access the feed through FTP, SFTP and FILE protocol’s.

Enter a name for the Index Connector

Select Type as Feed

Select Enabled

Configure Host Address and File Path

Select the appropriate Protocol

Configure the Timeout and Retries as required

Itemtag — tag represents the individual records



Enable the mapping for the fields from feed file to metadata defined, define a primary key value that will identify each record uniquely.



The configurations can be previewed before adding the Index Connector, click on Preview button



The Index Connector configuration is now ready, enable the Index Connector as URL entry point for crawling and indexing Setting → Crawling → URL Entrypoints



Select the Index Connector defined in the above step from the drop down “ — Add Index Connector Configurations — “



Now the configurations are ready, run a full live index so the new records will be reflected in the search result.

The Index Connector will provide the easy option to index the documents from feed data, this provides better performance during crawling and indexing. The Index connector can be used to index large volume of data for eCommerce systems.

Monday, September 17, 2018

How to Enable Custom Validation on multifield Touch UI — Adobe Experience Manager(AEM)

How to Enable Custom Validation on multifield Touch UI — Adobe Experience Manager(AEM)


This tutorial explains the approach to enable custom validation on multifield Touch UI. 

We are going to enable the email validation for the email filed defined inside multifield through custom script. 

Define Dialog 


As a first step, define a dialog with multi fields. The XML structure of the sample dialog is below
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="" xmlns:cq="" xmlns:jcr="" xmlns:nt=""
jcr:primaryType="nt:unstructured"
jcr:title="63 Collapsible Multifield"
sling:resourceType="cq/gui/components/authoring/dialog"
extraClientlibs="[customvalidation]">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<products
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
composite="{Boolean}true"
eaem-show-on-collapse="EAEM.showProductName"
fieldLabel="Products">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./products">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<product
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="Name of Product"
fieldLabel="Product Name"
name="./product"/>
<email
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="Email"
name="./email"/>
</items>
</column>
</items>
</field>
</products>
</items>
</column>
</items>
</content>
</jcr:root>

aem-touch-ui-multi-field-validation



Enable the validation for Email


Let us now enable the validation for email fields — the email id field is validated for valid email id. The form should not be submitted if there are at least one email filed is entered with invalid email address.

The email fields should be highlighted in different style for easy identification of validation errors.

Define a cq:ClientLibraryFolder node under the component with the name clientlibs and add the below properties.

categories (String[]) — <define category name> e.g customvalidation

aem-touch-ui-multi-field-validation


Create a folder with name js and add a file with name js.txt under it. Also, Add a file with name validation.js under clientlibs folder.

aem-touch-ui-multi-field-validation

Add the below script in validation.js
(function (document, $, ns) {
"use strict";
$(document).on("click", ".cq-dialog-submit", function (e) {
e.stopPropagation();
e.preventDefault();
var $form = $(this).closest("form.foundation-form"),
$inputs = $form.find("[name$='./email']"),
$input=null,
emailid,
isError=false,
patterns = {
emailadd: /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i
};
$inputs.each(function(index, input) {$input = $(input);
emailid=$input.val();
if(emailid != "" && !patterns.emailadd.test(emailid) && (emailid != null)) {
isError=true;
$input.css("border", "2px solid #FF0000");
ns.ui.helpers.prompt({
title: Granite.I18n.get("Invalid Input"),
message: "Please Enter a valid Email Address",
actions: [{
id: "CANCEL",
text: "CANCEL",
className: "coral-Button"
}],
callback: function (actionId) {
if (actionId === "CANCEL") {
}
}
});
}else
{
$input.css("border", "");
}
});

if(!isError){
$form.submit();
}
});

})(document, Granite.$, Granite.author);

Add the below content inside js.txt


js/validation.js

Add the below property in cq:dialog node

extraClientlibs String[] —customvalidation(the client library defined in the previous step)

aem-touch-ui-multi-field-validation


Author the component to a page

The error message will be displayed if the email address is invalid in the email fields also the email fields will be marked in red border on error, the form will be submitted on correcting all the email issues.

aem-touch-ui-multi-field-validation


aem-touch-ui-multi-field-validation



This concludes enabling the custom email validation to the multifield in touch UI dialog’s. The extraClientlibs dialog property can be used to load the custom java script to the dialog’s, the script can handle the appropriate events and handle the filed validation. The script can be customized as required to handle different validation scenarios.

Saturday, September 15, 2018

Improve the performance of the Adobe Experience Manager(AEM) websites

Improve the performance of the Adobe Experience Manager(AEM) websites


This post explains my experience on improving the Adobe Experience Manager(AEM) website performance

"Cache as much as possible" - CDN layer:


The caching is the important thing to be considered for improving the performance, in AEM setup the dispatcher will be used for caching the static content.
The CDN can be added on top of dispatcher to distributed caching to support the caching in different region to provide better performance. As the CDN is distributed at least by region the user will be served from nearby region to improve the performance. in this setup publishers will be only receive the initial request and subsequent request will be served by CDN and dispatcher.

There are multiple CDN options like Akamai and AWS Cloud Front. The request flow diagram below

network_flow_aem

Cache-Control max-age header:


Specify the cache control header with required max-age value to control the amount of time the files are cached by browser.

Add higher max-age values for static resources so that the browser caching can be used optimaly for bettwr performance.

The max-age can be be added as part of the virtual host configuration. e.g

<filesMatch ".(css|js|)$">
Header set Cache-Control "max-age=2628000"
</filesMatch>

<filesMatch ".(jpg|jpeg|png|gif|html|ico)$">
Header set Cache-Control "max-age=900"
</filesMatch>


Versioning of CSS and JS files:


The performance gain is achieved through browser caching static files for specified time(max-age). The browser cache busting is important to update the modified static files in browser, say the browser has the CSS file cached for one month and you want to change the CSS. You need a strategy for breaking the cache and forcing the browser to download a new copy of the CSS.

Change the version number of the static files upon modification so that the browser cache will be updated with new file irrespective of the max-age configuration. 

The versioning of static resources can be enabled in AEM through "ACS Commons Versioned Clientlibs" - https://adobe-consulting-services.github.io/acs-aem-commons/features/versioned-clientlibs/index.html

Wednesday, September 12, 2018

java.lang.UnsupportedOperationException: Deserialization not allowed for class [Ljava.lang.Object; - Adobe Experience Manager(AEM)

java.lang.UnsupportedOperationException: Deserialization not allowed for class [Ljava.lang.Object; - Adobe Experience Manager(AEM)

We were receiving the following exception while deserializing the objects in AEM

java.lang.UnsupportedOperationException: Deserialization not allowed for class com.test.Test; (on Wed Sep 12 16:32:50 CDT 2018)
        at org.kantega.notsoserial.DefaultNotSoSerial.preventDeserialization(DefaultNotSoSerial.java:256)
        at org.kantega.notsoserial.DefaultNotSoSerial.onBeforeResolveClass(DefaultNotSoSerial.java:248)
        at org.kantega.notsoserial.ObjectInputStreamClassVisitor.onBeforeResolveClass(ObjectInputStreamClassVisitor.java:48)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1819)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1713)
        at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1874)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1529)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2231)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2155)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2231)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2155)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)

The issue is due to the class name was not white listed in "Deserialization Firewall Configuration",Deserialization Firewall  help as to mitigation the deserialization attacks in Java
It gives you complete control over which classes your application should be allowed to deserialize.

deserialization_firewall_aem
The error got changed to the below one after white listing the custom package name in "Deserialization Firewall Configuration".

java.lang.UnsupportedOperationException: Deserialization not allowed for class [Ljava.lang.Object; (on Wed Sep 12 16:32:50 CDT 2018)
        at org.kantega.notsoserial.DefaultNotSoSerial.preventDeserialization(DefaultNotSoSerial.java:256)
        at org.kantega.notsoserial.DefaultNotSoSerial.onBeforeResolveClass(DefaultNotSoSerial.java:248)
        at org.kantega.notsoserial.ObjectInputStreamClassVisitor.onBeforeResolveClass(ObjectInputStreamClassVisitor.java:48)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1819)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1713)
        at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1874)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1529)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2231)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2155)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2231)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2155)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2013)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)

The class name "[Ljava.lang.Object" should be white listed as the deserialization type is array of custom objects, the "Deserialization Firewall Configuration" already enabled with default value "[" so that all the arrray type should be white listed.

In our case unfortunately the default "[" value was removed from the configuration and due to that the serialization for array types are rejected. The issue got resolved after adding the default value "["

Please make sure the default value "["  is not removed from white list to support array type.

deserialization_firewall_aem

This is for my reference but i am happy if this help someone.

Thursday, September 6, 2018

Adobe Experience Manager(AEM) On-Premises to Adobe Managed Service(AMS) Cloud Migration

Adobe Experience Manager(AEM) On-Premises to Adobe Managed Service(AMS) Cloud Migration


This post explains the different things that should be considered while migrating On-Premises Adobe Experience Manager(AEM) platform to the AWS cloud managed through AMS.

AMS cloud migration provides lot of benefits -

  • Extend the server capacity based on the demand
  • Quick spinning up of new servers
  • Less management and initial setup cost
  • Better security and monitoring of platform
  • Streamlined process
  • Higher availability

We have to consider this option based on the how much control we require on the production environment - AMS environments will be restricted for client access.

AMS_deployment_model

Below are some of the important items need attention while migrating the On-Premises AEM platform to AMS Cloud.

Deployment options:


There is different deployment options available based on the SLA

AMS_deployment_by_SLA

Tuesday, September 4, 2018

How to use Luke(Lucene Index Toolbox) to analyze Lucene Index in AEM(Adobe Experience manager)

How to use Luke(Lucene Index Toolbox) to analyze Lucene Index in AEM(Adobe Experience manager)


This post will explain the details on analyzing the created Lucene index in AEM(Adobe Experience Manager)

Retrieve the Lucene Index:


By default in Oak the Lucene Index files are stored in NodeStore and will not be accessible directly but if the following configurations("Enable CopyOnRead" or "Enable CopyOnWrite" ) are enabled in "Apache Jackrabbit Oak LuceneIndexProvider" the Lucene Index will be copied to Local files system path, If the "Local index storage path" not specified then indexes would be stored under 'index' dir under Repository Home (localIndexDir)

Lucene_index_provider

Index_on_local_file_system_aem

Index_on_local_file_system_aem

If the index is copied to loacl file system this can be directly accessed,the index is stored in the file name starts with segments

Index_on_local_file_system_aem
The mapping between local path and the index can be found here - localhost:4502/system/console/jmx/org.apache.jackrabbit.oak%3Aname%3DIndexCopier+support+statistics%2Ctype%3DIndexCopierStats(this URL will available only if the above mentioned properties are enabled)

Index_status_oak_aem


The below steps can be be followed to retrieve the indexing files if the index files are not stored in local.

Download oak-run-x.x.x.jar that corresponds to AEM Oak version, the AEM Oak version can be identified from CRXDE(the oak-run version 1.4.1 was not working and i downloaded 1.8.0 version - https://repository.apache.org/service/local/artifact/maven/redirect?r=releases&g=org.apache.jackrabbit&a=oak-run&v=1.8.0)

Execute java -jar oak-run-1.8.0.jar index <Node Store Path> e.g. java -jar oak-run-1.8.0.jar index C:\Albin\Development\AEM\6.2\crx-quickstart\repository\segmentstore to identify the available indexes, the index stats and index definitions under the folder from where the command is executed

The index is stored in the file name starts with segments


oak_run_available_index

The indexing status and the definitions can be accessed from the following URL also - http://localhost:4502/system/console/jmx/org.apache.jackrabbit.oak%3Aname%3DLucene+Index+statistics%2Ctype%3DLuceneIndex

Friday, August 17, 2018

How to Enable Cross Origin Resource Sharing(CORS) support in AEM(Adobe Experience Manager)

How to Enable Cross Origin Resource Sharing(CORS) support in AEM(Adobe Experience Manager)


Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served.

Sometimes we may have scenarios to expose the AEM services to be invoked from cross origins, this post explains the different approaches to enable the Cross Origin Resource Sharing Supports.

The CORS support is introduced OOB in AEM 6.3 version, refer https://helpx.adobe.com/experience-manager/kt/platform-repository/using/cors-security-article-understand.html for more details.


Enabling CORS for older AEM versions(<6.3)


The request is failed with below exception in browser console while trying to invoke cross origin(service hosted in different domains) services through Ajax.

"Failed to load http://localhost:4503/bin/sampleJSONPService: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access".

There are two approaches to enable the Cross Origin Requests

  • JSONP
  • CORS Headers

JSONP


JSONP stands for JSON with Padding, JSONP is a method for sending JSON data without worrying about cross-domain issues.
JSONP supports only the GET request method, JSONP works on legacy browsers.

Enable the service to rerun the JSON response with Padding


@SuppressWarnings("serial")
@SlingServlet(
   selectors = "json",
   paths = "/bin/sampleJSONPService",
   methods = "GET")
public class SimpleServlet extends SlingSafeMethodsServlet {

    @Override
    protected void doGet(final SlingHttpServletRequest req,
            final SlingHttpServletResponse resp) throws ServletException, IOException {
    resp.setHeader("Content-Type", "application/json");
    resp.setHeader("X-Content-Type-Options", "");
    String callback=req.getParameter("callback");
       
    JSONObject response = new JSONObject();
    try {
response.put("test1", "testvalue1");
response.put("test2", "testvalue2");
response.put("test3", "testvalue3");
response.put("test4", "testvalue4");
} catch (JSONException e) {
e.printStackTrace();
}
   
    if(callback!=null && !callback.trim().equals("")) {
    resp.getWriter().write( callback + "("+response.toString()+ ")");
    }else
    {
    resp.getWriter().write(response.toString());
    }   
   
    }
}

The above service return the JSON response with padding

Invoke the JSONP service from Ajax


<html>
<head>
<script
  src="https://code.jquery.com/jquery-3.3.1.min.js"  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="  crossorigin="anonymous">
</script>
</head>
<body>

Test Data (<span class="testData">Default</span>)

<script>
var dataUrl = 'http://localhost:4503/bin/sampleJSONPService.json?callback=?';

$.ajax({
url: dataUrl,
dataType: 'jsonp',
success: function(data) {
jQuery('.testData').html('').text(data.test1)
}});
</script>
</body>
</html>


This will provide the response without any issue

test({"test1":"testvalue1","test2":"testvalue2","test3":"testvalue3","test4":"testvalue4"})


CORS Headers


Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell a browser to let a web application running at one origin (domain) have permission to access selected resources from a server at a different origin. CORS also supports other types(other than GET) of HTTP requests, CORS is supported by most modern web browsers.

The Access-Control-Allow-Origin response header indicates whether the response can be shared with resources with the given origin.

e.g.
Access-Control-Allow-Origin "*"   supports the Cross Origin requests from all domains
Access-Control-Allow-Origin "https://example.com" supports Cross Origin requests only from https://example.com

Enabling Access-Control-Allow-Origin header


The header can be enabled directly in the service response or thorough apache configuration

Though Service response - Add Access-Control-Allow-Origin header with required value in the service response


@SuppressWarnings("serial")
@SlingServlet(
   selectors = "json",
   paths = "/bin/sampleJSONPService",
   methods = "GET")
public class SimpleServlet extends SlingSafeMethodsServlet {
    @Override
    protected void doGet(final SlingHttpServletRequest req,
            final SlingHttpServletResponse resp) throws ServletException, IOException {

Monday, July 9, 2018

How to display custom site specific error(404,403 and 500) pages in multi site Adobe Experience Manager(AEM) setup?

How to display custom site specific error(404,403 and 500) pages in multi site Adobe Experience Manager(AEM) setup?


This post explains the approach to handle custom site specific error handling for Adobe Experience Manager(AEM) sites in a multi site environment

Sling Model to identify the error page:


Create a Sling model ErrorHandlerRequestModel.java in core module withe the below code - This will help to identify the site specific error page path specific to the error code.

package com.errorhandler.core.models;

import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.PageManager;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.Self;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

@Model(adaptables = SlingHttpServletRequest.class)
public class ErrorHandlerRequestModel {

    private static final String DEFAULT_ERROR_PAGE = "/content/geometrixx-outdoors";
    private static final String ERROR_CODE_404 = "404";
    private static final int MAX_DEPTH = 2;
    private static final String PATH_SEPERATOR = "/";

    @Self
    private SlingHttpServletRequest slingRequest;

    @Inject
    @Default(values = ERROR_CODE_404)
    private String errorCode;

    private String pagePath;
 
    @PostConstruct
    protected void init() {
    pagePath = DEFAULT_ERROR_PAGE + errorCode;
        final String requestURI = slingRequest.getRequestPathInfo().getResourcePath();
        if (requestURI!=null && !requestURI.equals("")) {
          pagePath = getErrorPageFromRequestedUrl(errorCode, requestURI);
    }
    }

    private String getErrorPageFromRequestedUrl(final String errorCode, final String requestURI) {
        final Page resolvedPage = getPageFromPath(requestURI);
        if (resolvedPage != null) {
            return getErrorPathFromPage(errorCode, resolvedPage);
        }
        return null;
    }

    private Page getPageFromPath(String requestURI) {
        final PageManager pageManager = slingRequest.getResourceResolver().adaptTo(PageManager.class);
        while (requestURI.contains(PATH_SEPERATOR)) {
            Page page = pageManager.getContainingPage(requestURI);
            if (page != null) {
                return page;
            } else {
                requestURI = requestURI.substring(0, requestURI.lastIndexOf(PATH_SEPERATOR));
            }
        }
        return null;
    }

    private String getErrorPathFromPage(final String errorCode, final Page resolvedPage) {
    if (resolvedPage.hasChild(errorCode)) {
        return resolvedPage.getPath() + PATH_SEPERATOR + errorCode;
        }
        if (resolvedPage.getParent() != null && resolvedPage.getDepth() >= MAX_DEPTH) {
            return getErrorPathFromPage(errorCode, resolvedPage.getParent());
        }
        return null;
    }

    public String getPagePath() {
        return pagePath;
    }
}

Configure the DEFAULT_ERROR_PAGE(the content folder in which the default 404, 403 and 500 error pages are available) in the above code  - the error pages that will be displayed if the the site specific 404, 403 and 500 pages are missing.
Add the below instruction into core module pom.xml - to notify the package in which the sling models are available for registration

<Sling-Model-Packages>com.errorhandler.core.models</Sling-Model-Packages>


<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>                   
<Import-Package>javax.inject;version=0.0.0,*</Import-Package>
<Sling-Model-Packages>com.errorhandler.core.models</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>

Configure Error Handlers:


Create 403.html, 404.html and Exception.html(error handler to handle all the Internal Server Exceptions) under /apps/sling/servlet/errorhandler

aem-error-handler-scripts


Add the below contents to 403.html, 404.html and Exception.html respectively

403.html

<sly data-sly-use.errorPage="${'com.errorhandler.core.models.ErrorHandlerRequestModel'@ errorCode='403'}"/>
<sly data-sly-resource="${errorPage.pagePath}.html"/>

404.html

<sly data-sly-use.responseStatus="apps.sling.servlet.errorhandler.ResponseStatus">
    <sly data-sly-use.errorPage="${'com.errorhandler.core.models.ErrorHandlerRequestModel'@ errorCode='404'}"/>
    <sly data-sly-resource="${errorPage.pagePath}.html"/>
</sly>

Exception.html

<sly data-sly-use.errorPage="${'com.errorhandler.core.models.ErrorHandlerRequestModel'@ errorCode='500'}"/>
<sly data-sly-resource="${errorPage.pagePath}.html"/>


Create ResponseStatus.java under /apps/sling/servlet/errorhandler and add the below content

package apps.sling.servlet.errorhandler;

import com.adobe.cq.sightly.WCMUse;

public class ResponseStatus extends WCMUse {
 
    @Override
    public void activate() throws Exception {
        getResponse().setStatus(404);
    }
}


Configure Error Pages:


Create site specific error files 403, 404 and 500(the files can be created in any level - the minimum depth should be 2 i.e under /content/sitename), the files will be taken based on the level where the exception occurred.

aem-site-specific-error-pages


Exception directly under /content/geometrixx-outdoors consider the error pages under /content/geometrixx-outdoors
Exception under /content/geometrixx-outdoors/en consider the error pages under /content/geometrixx-outdoors/en

Configure the local error pages - 404, 403 and 500 for all the required sites.

Now the user will be displayed the corresponding error file content based on the error code.


This implementation has been tested in AEM 6.2 version.

Monday, July 2, 2018

HTTPS URL is resulting with 404 - Adobe Experience Manager

HTTPS URL is resulting with 404 - Adobe Experience Manager


Recently, we have faced the issue with https URL's, the URL's with masked path (/en/test.html) is not working with https protocol.

However, the unmasked (/content/site/en/test.html) URL is working, also http URL is working without any issues.

Based on our analysis, it looks to be the system is not honoring the /etc/map.publish/https mapping for https request and due to that the content path(without full path - /en/test.html) is not accessible and 404 is displayed

Our case the request is https from browser and the Load Balancer terminate the SSL and forward the request to dispatcher - Load Balancer notify the dispatcher that the initial request is https via header X-Forwarded-Proto (this header value differs based on the load balancer)

The dispatcher send the request to publisher with required headers and publisher consider the request as https based on the above header and match the Resource Mapping accordingly - /etc/map.publish/https

The 404 will be displayed for masked URL's if publisher not able to match the /etc/map.publish/https for incoming request.

How to resolve?


Option1:


  • Match the SSL Filter settings to those expected from the entity where SSL is terminated (Load Balancer). You can check these values forwarded in the dispatcher.log file and make sure they match to those of the SSL Filter. Configure the SSL Filter (Apache Felix Http Service SSL Filter) in Publisher with SSL forward header and value
SSL_Filter_https_aem

  • Allow the following headers in dispatcher farm file /clientheaders section, if /clientheaders section is not set to allow all

          X-Forwarded-Proto (this header value change based on the Load balancer)
               - other known values X-FORWARDED-SSL, X-Forwarded-Protocol and Front-End-Https
          X-Forwarded-Port
  • White list the SSL headers mentioned above in CDN, if CDN is enabled in the flow.

Option2:


Disallow the SSL forward headers in dispatcher farm file /clientheaders section; disallow the following header - X-Forwarded-Proto in /clientheaders section, review the "Apache Felix Http Service SSL Filter" in publisher to identify the exact header value used to identify the forwarded SSL request.

This allow the publisher to consider the request as http and match the /etc/map.publish/http node for incoming requests. 

In cases the SSL is terminated at the Web server, follow the below steps:


At the bottom of the httpd.conf add the following configuration: RequestHeader set X-Forwarded-Port "-1"

Allow the X-Forwarded-Port header in dispatcher farm file if /clientheaders section is not set to allow all 

Wednesday, June 13, 2018

Resolving the issues while migrating the packages between Adobe Experience Manager instances(AEM)

Resolving the issues while migrating the packages between Adobe Experience Manager instances(AEM)


This is a common scenario to migrate the packages between AEM instances, some times we may face issues while building or uploading the big packages.

This post explains the details to resolve the issues observed while building or uploading the big packages between AEM instances

java.io.IOException: No space left on device while building the package:


The "java.io.IOException: No space left on device" error will be thrown while building big packages in AEM server without having sufficient space available in /tmp folder.

java.io.IOException: No space left on device
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:326)
at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253)
at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:211)
at java.util.zip.ZipOutputStream.write(ZipOutputStream.java:331)
at org.apache.commons.io.output.ProxyOutputStream.write(ProxyOutputStream.java:90)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1793)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
at org.apache.jackrabbit.vault.fs.io.JarExporter.writeFile(JarExporter.java:128)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:216)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:214)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:214)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:214)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:214)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:214)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:214)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:214)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:214)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:214)
at org.apache.jackrabbit.vault.fs.io.AbstractExporter.export(AbstractExporter.java:184)
at org.apache.jackrabbit.vault.packaging.impl.PackageManagerImpl.assemble(PackageManagerImpl.java:142)
at org.apache.jackrabbit.vault.packaging.impl.PackageManagerImpl.assemble(PackageManagerImpl.java:96)
at org.apache.jackrabbit.vault.packaging.impl.JcrPackageManagerImpl.assemble(JcrPackageManagerImpl.java:594)
at org.apache.jackrabbit.vault.packaging.impl.JcrPackageManagerImpl.assemble(JcrPackageManagerImpl.java:574)
at com.day.crx.packaging.impl.J2EEPackageManager.consoleBuild(J2EEPackageManager.java:291)
at com.day.crx.packaging.impl.J2EEPackageManager.doPost(J2EEPackageManager.java:176)
at com.day.crx.packaging.impl.PackageManagerServlet.doPost(PackageManagerServlet.java:156)

no_space_left_on_device_aem_package

Wednesday, May 30, 2018

Exceptions/Issues while configuring SAML Authentication Handler - Adobe Experience Manager(AEM)

Exceptions/Issues while configuring SAML Authentication Handler - Adobe Experience Manager(AEM)


This post explains the Exceptions/Issues received while configuring the SAML authentication handler and the fixes to overcome the issues.

Issue1:


Problem accessing /saml_login. Reason:
com.adobe.granite.keystore.KeyStoreNotInitialisedException: Uninitialised system trust store.

uninitialized-system-trust-store


14.05.2018 11:24:39.988 *WARN* [qtp1134377453-62] org.eclipse.jetty.servlet.ServletHandler /saml_login
com.adobe.granite.keystore.KeyStoreNotInitialisedException: Uninitialised system trust store.
at com.adobe.granite.keystore.internal.KeyStoreServiceImpl.internalGetTrustStore(KeyStoreServiceImpl.java:462)
at com.adobe.granite.keystore.internal.KeyStoreServiceImpl.getTrustStore(KeyStoreServiceImpl.java:151)
at com.adobe.granite.auth.saml.SamlAuthenticationHandler.handleLogin(SamlAuthenticationHandler.java:577)
at com.adobe.granite.auth.saml.SamlAuthenticationHandler.extractCredentials(SamlAuthenticationHandler.java:348)
at org.apache.sling.auth.core.impl.AuthenticationHandlerHolder.doExtractCredentials(AuthenticationHandlerHolder.java:75)
at org.apache.sling.auth.core.impl.AbstractAuthenticationHandlerHolder.extractCredentials(AbstractAuthenticationHandlerHolder.java:60)
at org.apache.sling.auth.core.impl.SlingAuthenticator.getAuthenticationInfo(SlingAuthenticator.java:709)
at org.apache.sling.auth.core.impl.SlingAuthenticator.doHandleSecurity(SlingAuthenticator.java:461)
at org.apache.sling.auth.core.impl.SlingAuthenticator.handleSecurity(SlingAuthenticator.java:446)
at org.apache.sling.engine.impl.SlingHttpContext.handleSecurity(SlingHttpContext.java:121)
at org.apache.felix.http.base.internal.context.ServletContextImpl.handleSecurity(ServletContextImpl.java:339)
at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:334)
at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:297)
at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:93)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:50)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:31)
at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:129)


Problem accessing /saml_login. Reason:
com.adobe.granite.keystore.KeyStoreNotInitialisedException: Uninitialised key store for user authentication-service

Uninitialised-Keystore-authentication-service

Thursday, May 3, 2018

io.jsonwebtoken,version=[0.7,1) -- Cannot be resolved - Adobe Experience Manager(AEM)

io.jsonwebtoken,version=[0.7,1) -- Cannot be resolved - Adobe Experience Manager(AEM) 

I was getting the below exception while using the io.jsonwebtoken dependency in the bundle and the bundle was in Installed state.

org.osgi.framework.BundleException: Unresolved constraint in bundle com.test [452]: Unable to resolve 452.5: missing requirement [452.5] osgi.wiring.package; (&(osgi.wiring.package=io.jsonwebtoken)(version>=0.7.0)(!(version>=1.0.0)))
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4095)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2114)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:977)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:964)
at org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:93)
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.doExecuteTasks(OsgiInstallerImpl.java:847)
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:689)
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:265)
at java.lang.Thread.run(Unknown Source)

The below dependency is added into pom.xml

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>


Steps to fix:


Configure the maven-bundle-plugin as shown below

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
<configuration>
<instructions>
<Import-Package>
!android.util;resolution:=optional,
!com.fasterxml.jackson.core;resolution:=optional,
!com.fasterxml.jackson.databind;resolution:=optional,
!org.bouncycastle.jce;resolution:=optional,
!org.bouncycastle.jce.spec;resolution:=optional,
javax.inject;version=0.0.0,*
</Import-Package>
<Embed-Dependency>jjwt;inline=true</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
    </configuration>
</plugin>

Tuesday, April 24, 2018

How to handle the request parameter encoding(charset) in Adobe Experience Manager(AEM)

How to handle the request parameter encoding(charset) in Adobe Experience Manager(AEM)


The default value for the parameter encoding in AEM is UTF8 — The default request parameter encoding used to decode request parameters into strings.

The configured parameter encoding value e.g UTF8 is used to decode the request parameters to string.

Sometimes we may need to change the default parameter encoding in Adobe Experience Manager(AEM) to handle different language characters.

This tutorial explains the approach to change the default parameter encoding to required values e.g UTF8, ISO-8859–1 etc

The request parameter can be changed by following either one of the below approach
  • Apache Sling Request Parameter Handling
  • Change the encoding for specific form

Apache Sling Request Parameter Handling


The request parameter encoding can be changed through the following OSGI configuration — “Apache Sling Request Parameter Handling”. This is the global configurations and impact all the request parameter handling(decoding)

“Default Parameter Encoding” — The default request parameter encoding used to decode request parameters into strings. If this property is not set the default encoding is ‘ISO-8859–1’ as mandated by the Servlet API spec. This default encoding is used if the ‘_charset_’ request parameter is not set to another (supported) character encoding. Applications being sure to always use the same encoding (e.g. UTF-8) can set this default here and may omit the ‘_charset_’ request parameter (sling.default.parameter.encoding)

The AEM server configures UTF-8 as the default parameter, ‘ISO-8859–1’ is considered as default encoding if this field is empty.



Change the value of “Default Parameter Encoding” to required values — e.g UTF-8/ISO-8859–1

Change the encoding for specific form


The request parameter can be changed to specific form by following the below steps

Add the parameter “_charset_” as a hidden field with required encoding value inside the form.

<form role=”form” id=”test” action=”xxxxx” method=”POST” accept-charset=”ISO-8859–1" onsubmit=”document.charset = ‘ISO-8859–1’”>
<input type=”hidden” id=”_charset_” name=”_charset_” value=”ISO-8859–1"/>
……..
……..
</form>

accept-charset=”ISO-8859–1" — specifies the character encoding that to be used for the form submission(non IE browsers)

“document.charset = ‘ISO-8859–1’” — specifies the character encoding that to be used for the form submission(Configuration for IE browser)

This will change the encoding of this particular form, different encoding can be specified page level and form level only to handle the data.

Wednesday, April 18, 2018

How to implement extension-less URL's in Adobe Experience Manager(AEM)

How to implement extension-less URL's in Adobe Experience Manager(AEM)

As per the SEO best practices it is better to define extension less URL's to boost the ranking, AEM require the extension to understand and serve incoming request.

This post explains the approach to achieve the extension less URL in Adobe Experience Manager(AEM)

There are two steps

- Rule Configuration Dispatcher
       Remove .html extension from incoming URL with /
Append the .html while invoking the publisher for the URL's ending with /

- AEM etc/map configuration
      Reverse mapping to rewrite the html URL in the pages to extension less
      Forward mapping to map the incoming request to resource

This is tested in AEM 6.2 version

Apache configurations:


#Handle the landing page
RewriteRule ^/$ /en/ [R=301,L]
#Mask the /content/geometrixx-outdoors path
RewriteRule ^/content/geometrixx-outdoors/(.*)(\.html)?$ /$1 [NE,L,R=301]

#Replace the .html with /
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^/(.*).html$ /$1/ [R=301,L,QSA]

#Append the .html for those URL's ending with / before sending to publisher
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^/(.*)/$ /$1.html [PT,L,QSA]

Publisher etc/map configurations:


Create a node localhost.8080(replace with required DNS and port) of type sling:Mapping under /etc/map/http or /etc/map/https based on the protocol used

Add the following property

sling:internalRedirect[] - /content/geometrixx-outdoors

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="sling:Mapping"
    sling:internalRedirect="[/content/geometrixx-outdoors]">
    <redirect/>
    <reverse/>
</jcr:root>

AEM-extension-less-URL


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