Wednesday, June 17, 2015

Deploying bundles/packages to different environments through Maven: Adobe AEM/Adobe CQ5

Deploying bundles/packages to different environments through Maven: Adobe AEM/Adobe CQ5

Create a folder cq-sample-all(projectname-all) under cq-sample(parent folder)
Create cq-sample-all/pom.xml and configure the environment specific properties, module dependencies and different profiles - refer the sample below

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLotrion="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
             <groupId>my-group-id</groupId> <!-- Change the groupid and artifactId of the paraent -->
             <artifactId>cq-sample</artifactId>
             <version>1.0-SNAPSHOT</version>
        </parent>

<artifactId>cq-sample-all</artifactId> <!-- Change the artifcatId -->
<packaging>content-package</packaging>
<name>${project.groupId} - ${project.artifactId}</name>

<properties>
<cq.dev.author.server>aem-dev-author</cq.dev.author.server>
<cq.dev.author.host>localhost</cq.dev.author.host>
<cq.dev.author.port>4502</cq.dev.author.port>
<cq.dev.author.protocol>http</cq.dev.author.protocol>
<cq.dev.publisher1.server>aem-dev-publisher</cq.dev.publisher1.server>
<cq.dev.publisher1.host>localhost</cq.dev.publisher1.host>
<cq.dev.publisher1.port>4503</cq.dev.publisher1.port>
<cq.dev.publisher1.protocol>http</cq.dev.publisher1.protocol>
<!-- Add the other server details-->
</properties>
<!-- Add all the  bundle/content modules as part of dependency. Change the artifactId of the modules-->

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cq-sample-content</artifactId>
<version>${project.version}</version>
<type>content-package</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cq-sample-bundle</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>maven-vault-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
<configuration>
<embeddedTarget>/apps/cq-sample/install</embeddedTarget> <!-- change the folder name(cq-sample) accordingly -->
<embeddeds>
<embedded>
<groupId>${project.groupId}</groupId>
<artifactId>cq-sample-bundle</artifactId>
<filter>true</filter>
</embedded>
<!-- Add additional bundle modules here as embedded -->
</embeddeds>
<subPackages>
<subPackage>
<groupId>${project.groupId}</groupId>
<artifactId>cq-sample-content</artifactId>
<filter>true</filter>
</subPackage>
<!-- Add additional content modules here as subPackage -->
</subPackages>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<!-- Profile for Development deployments -->
<!--Create the profile for different environments -->
<profile>
<id>Development</id>
<build>
<plugins>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<executions>
<execution>
<id>install-content-package-author</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<failOnError>true</failOnError>
<useProxy>false</useProxy>
<packageFile>${project.build.directory}/${project.build.finalName}.zip</packageFile>
<targetURL>${cq.dev.author.protocol}://${cq.dev.author.host}:${cq.dev.author.port}/crx/packmgr/service.jsp</targetURL>
<serverId>${cq.dev.author.server}</serverId>
</configuration>
</execution>
<execution>
<id>install-content-package-publisher1</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<failOnError>true</failOnError>
<useProxy>false</useProxy>
<packageFile>${project.build.directory}/${project.build.finalName}.zip</packageFile>
<targetURL>${cq.dev.publisher1.protocol}://${cq.dev.publisher1.host}:${cq.dev.publisher1.port}/crx/packmgr/service.jsp</targetURL>
<serverId>${cq.dev.publisher1.server}</serverId>
</configuration>
</execution>
<!-- Add execution for additional publisher with different id(increment the last digit)-->
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>




How to disable Geolocation feature : Adobe AEM/Adobe CQ5

How to disable Geolocation feature : Adobe AEM/Adobe CQ5

The Geolocation feature can be disabled for all the sites by renaming the following component to different name

Rename /libs/cq/personalization/components/contextstores/geolocation to /libs/cq/personalization/components/contextstores/geolocation_new




Unresolveable build extension: Error resolving version for plugin 'com.day.jcr.vault:maven-vault-plugin' / Unknown packaging: content-package while deploying through Maven : Adobe AEM/Adobe CQ5

Unresolveable build extension: Error resolving version for plugin 'com.day.jcr.vault:maven-vault-plugin' / Unknown packaging: content-package while deploying through Maven : Adobe AEM/Adobe CQ5

We are getting the below exception while deploying the package to Adobe AEM/Adobe CQ5 through Maven.

[ERROR] Unresolveable build extension: Error resolving version for plugin 'com.day.jcr.vault:maven-vault-plugin' from the repositories
[local (D:\Albin\Projects\.m2\repository), adobe (http://repo.adobe.com/nexus/content/groups/public/),
central (http://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 2]
[ERROR]     Unknown packaging: content-package @ my-group-id:cq-sample-all:[unknown-version],
D:\Albin\SW\apache-maven-3.2.2-bin\apache-maven-3.2.2\bin\cq-sample\cq-sample-all\pom.xml, line 13, column 13
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginVersionResolutionException

To resolve this issue add the vault plugin to parent pom.xml

<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>maven-vault-plugin</artifactId>
<version>0.0.10</version>
<configuration>
<verbose>true</verbose>
</configuration>
</plugin>


Friday, June 5, 2015

Enabling basic authentication for specific website in dispatcher : Adobe CQ5/Adobe AEM

Enabling basic authentication for specific website in dispatcher : Adobe CQ5/Adobe AEM

Create a file dispatcher.htaccess in dispatcher.
Create the required users by using the following commands.

htpasswd -c /etc/httpd/conf/dispatcher.htaccess user1

Add the following configurations to the httpd.conf, change the site URL and AuthUserFile accordingly:

# unsets authorization header when sending request to AEM
RequestHeader unset Authorization
SetEnvIf Request_URI ^/content/en* auth=1
AuthName "Please login to access english part"
AuthType Basic
AuthUserFile /etc/httpd/conf/dispatcher.htaccess
# first, allow everybody
Order Allow,Deny
Satisfy any
Allow from all
Require valid-user
# then, deny only if required
Deny from env=auth

This will enable the the basic authentication for the website path starts with /content/en

If the site is enabled for https then add the following content to the ssl.conf file

<Location />
# unsets authorization header when sending request to AEM
RequestHeader unset Authorization
SetEnvIf Request_URI ^/content/en* auths=1
AuthName "Please login to access english part"
AuthType Basic
AuthUserFile /etc/httpd/conf/dispatcher.htaccess
# first, allow everybody
Order Allow,Deny
Satisfy any
Allow from all
Require valid-user
# then, deny only if required
Deny from env=auths
</Location>


Monday, June 1, 2015

Performance Tuning: Adobe CQ5/Adobe AEM

Performance Tuning: Adobe CQ5/Adobe AEM



Sunday, May 31, 2015

org.springframework.a op.framework.AopConfigException: Could not generate CGLIB subclass of class [class net.sf.ehcache.CacheManager]

org.springframework.a op.framework.AopConfigException: Could not generate CGLIB subclass of class [class net.sf.ehcache.CacheManager]

While using Ehcache with spring, spring context initialization fails with the below exception

Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'com.googlecode.ehcache.annotations.impl.CacheAttributeSourceI
mpl#0': Cannot resolve reference to bean 'ehcacheManager' while setting bean pro
perty 'cacheManager'; nested exception is org.springframework.beans.factory.Bean
CreationException: Error creating bean with name 'ehcacheManager': Post-processi
ng of the FactoryBean's object failed; nested exception is org.springframework.a
op.framework.AopConfigException: Could not generate CGLIB subclass of class [cla
ss net.sf.ehcache.CacheManager]: Common causes of this problem include using a f
inal class or a non-visible class; nested exception is org.springframework.cglib
.core.CodeGenerationException: net.sf.ehcache.CacheException-->Another unnamed C
acheManager already exists in the same VM. Please provide unique names for each
CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same Cac
heManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: InputStreamConfigurationSource [stre
am=java.io.BufferedInputStream@128647a]

Configuration Details:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
     xsi:schemaLocation="
     http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring
     http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd">

<ehcache:annotation-driven cache-manager="cacheManager"/>

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
  <property name="configLocation" value="classpath:config/ehcache/ehcache.xml" />
  <property name="shared" value="true" />
</bean>
</beans>



Saturday, May 23, 2015

How to get all the configurations from a configurationFactory - Adobe CQ5/Adobe AEM

How to get all the configurations from a configurationFactory - Adobe CQ5/Adobe AEM

@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, policy = ReferencePolicy.STATIC)
private ConfigurationAdmin configAdmin;
try {
Configuration[] confArray = configAdmin.listConfigurations("(service.factoryPid= com.service.config.impl.ConfigFactoryServiceImpl)");

//Retrieve the configurations - Iterate through confArray
final Configuration conf = confArray[0];
final String property1 = (String) conf.getProperties().get("property1");

} catch (Exception e) {

}

service.factoryPid: