Saturday, March 28, 2015

NullPointerException: currentDesign.getDoctype(currentStyle).toRequest(request);

We were getting the NullpoiterException while accessing the pages.

Caused by: java.lang.NullPointerException
at javax.servlet.http.HttpServlet.service(
... 117 more

NullpointerException is thrown while getting the Doctype of the page design.

if (currentDesign != null) {

This issue was getting resolved after restarting the server.

After analysis the currentDesign  and currentStyle objects are not null and getDoctype method is throwing NullpoiterException.

The currentStyle  refers to the path (currentStyle.getPath())- /etc/designs/default.

By default /etc/designs/default/jcr:content path will not have cq:doctype property specified.

To resolve the issue we have added the  cq:doctype - html_5 property to /etc/designs/default/jcr:content

Sunday, March 22, 2015

How to enable SSL debug tracing in Weblogic Server?

Add the following start up options to the start up file startWebLogic.cmd/ or startManagedWebLogic.cmd/ based on which file is used to start the server.

JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.debug.DebugSecuritySSL=tue -Dweblogic.debug.DebugSSL=true -Dweblogic.StdoutDebugEnabled=true -Dweblogic.log.StdoutSeverityLevel=Debug -Dweblogic.log.LogSeverity=Debug"

Invocation of https/SSL service is not working from OSB

We were trying to install the wildcard certificate to enable the communication from OSB to end system, but the following exception was displayed in the log file and also the communication to the end system is failing even though the certificate installation was successful;

<Jan 23, 2015 10:45:05 PM PST> <Notice> <Security> <localhost> <AdminServer> <[ACTIVE] ExecuteThread: '12' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <bac54c313ca42523:46f5522b:14b61066510:-7ffd-000000000008b798> <1423456801909> <BEA-090898> <Ignoring the trusted CA certificate "CN=*,O=Sample,L=Sample,ST=Sample,C=US". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.> 
After analysis, we found that JSSE flag should be enabled along with Custom Host Name Verification ( to support wildcard certificate.

 After enabling the JSSE flag, none of the https communication from OSB is working but https communication from BPEL is working fine even with the wildcard certificate(BPEL and OSB is running in the same server).

The following exception is thrown while invoking the https service from OSB.

<soapenv:Envelope xmlns:soapenv="">
BEA-380000: General runtime error: java.lang.NullPointerException
<con:fault xmlns:con="">
General runtime error: java.lang.NullPointerException

This is the internal OSB server issue; the cause of the issue is that the AsyncResponseHandler does not properly register JSSEFilter for JSSE SSL.
The Weblogic patch 11866509 based on the Weblogic server version (this issues is identified in Weblogic server version 10.3.4 and 10.3.5) should be installed to resolve the issue.

Saturday, March 14, 2015

How to get the UserInfo through Java API in Adobe CQ5

ResourceResolverFactory resolverFactory;

ResourceResolver adminResolver = null;
try {
       adminResolver = resolverFactory.getAdministrativeResourceResolver(null);
       final Session adminSession = adminResolver.adaptTo(Session.class);
       final UserManager userManager = adminResolver.adaptTo(UserManager.class);
       final User user = (User) userManager.getAuthorizable(adminSession.getUserID());
       Iterator<Group> itr=user.memberOf();
         Group group=(Group);
} catch (Exception e) {
} finally {
       if (adminResolver != null) adminResolver.close();

Thursday, March 12, 2015

Cookie values are not setting in IE10 and IE11

While trying to set the cookies in IE10 and IE11 through Java, the values are not stetting in the browser.

The code snippet used to set the cookie is

cookie = new javax.servlet.http.Cookie(cookieHeaderName,"Sample Cookie");

After long struggle we found the issue might be with the value of Expires is not set, IE10 and IE11 expecting the value for Expires and it is not considering the value set in Max-Age.

Fix for the issue - Use the below code to set the cookie value

int expiration = 365*24*60*60;
StringBuilder cookieString = new StringBuilder("TestCookie=Test; ");

DateFormat df = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss 'GMT'", Locale.US);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, expiration);
cookieString.append("Expires=" + df.format(cal.getTime()) + "; ");
//cookieString.append("Domain="+request.getServerName()+"; ");
cookieString.append("Version=0; ");
cookieString.append("Path=/; ");
cookieString.append("Max-Age=" + expiration + "; ");
response.addHeader("Set-Cookie", cookieString.toString());

Sunday, March 8, 2015

How to connect to oracle database using datasource pool - Adobe CQ5

This post will explain how to connect to oracle database using datasource pool(The CQ5 version referred here is 5.6.1)

Convert the JDBC driver to OSGI bundle:

In eclipse - File-->New-->Plug-in Development-->Plug-in from Existing JAR Archives
Click on Add External and Select the JDBC jar file

Click Next and enter the required details

Project name - OracleDriver
Plug-in ID -
Plug-in vendor - Oracle
Select the Execute Environment
Select an OSGi framework and select standard
Un-Select Unzip the JAR archives into the project and select Update references to the JAR files.

Click Next and click Finish

Right click the the created project and click on Export

Select Plug-in Development --> Deploying plug-ins and fragments
Specify the destination directory and make sure the plug-in is selected(

Click on Finish, this will create the OSGI bundle in the selected directory.

Install the OSGI bundle:

Login to http://localhost:4502/system/console/bundles
Click on Install/Update 
Choose the OSGI bundle 
Select Start Bundle and refresh Packages

Click on Install or Update

Configure the Datasource pool:

Login to http://localhost:4502/system/console/configMgr

Select JDBC Connection Pool and add new Connection Pool(click on plus)

Enter the required details

JDBC driver class - oracle.jdbc.OracleDriver
JDBC connection URI - jdbc:oracle:thin:@hostname:port:SID or Service Name
Validation query - SELECT 1 FROM DUAL
Pool size - 10(configure based on the requirement)
Datasource name - SampleOracleDS(provide the datasource name to uniquely identify the DS)

Save the configurations

Configure the pom client form file with the following dependency


Service class to get the database connection and to perform the operations


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.sql.DataSource;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@Component(immediate = true, metatype = true)
@Service(value = DatabaseConnectionImpl.class)
public class DatabaseConnectionImpl {

protected static final Logger log = LoggerFactory.getLogger(DatabaseConnectionImpl.class);

private DataSourcePool dataSourceService;

public Connection getDataBaseConnection(String dataSourceName) {
Connection conn = null;
try {
DataSource dataSource = (DataSource) dataSourceService.getDataSource(dataSourceName);
conn = dataSource.getConnection();
} catch (Exception e) {
return conn;

public void executeQuery() {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
con = getDataBaseConnection("SampleOracleDS");
stmt = con.createStatement();
rs = stmt.executeQuery("select empno,empname from Employee");
while ( {
System.out.println("Employee ID=" + rs.getString(1));
} catch (Exception e) {
} finally {
try {
if (rs != null)
if (stmt != null)
if (con != null)
} catch (Exception e) {


Tuesday, March 3, 2015

How to Customize/Configure the 404 error handler for multi sites in Adobe CQ5?

This post will explain how to configure the 404 error handler in multi site scenario - This will configure different 404 pages for different sites..

If the error handler is configured for first time then copy /libs/sling/servlet/errorhandler to /apps/sling/servlet (create the folder structure before copying )

Modify /apps/sling/servlet/errorhandler/404.jsp file to modify the 404 error handling rules.

//setting response code as 404
try {
    String uri = request.getRequestURI();
    } else if(uri.matches("(/content/Sample/es/)(.*)"))
    } else if(uri.matches("(/en/)(.*)"))
    else if(uri.matches("(/es/)(.*)"))
    } else

} catch (Exception e) {

        Page Not Found


The conditions can be added to handle different sites, if the sites are running on different virtual host names then get the server name from the request
(request.getServerName()) and add the condition based on the server name.

This will redirect the user to site specific 404 pages.