Connect to Adobe Experience Manager Data from a Connection Pool in Jetty
The CData JDBC driver for Adobe Experience Manager is easy to integrate with Java Web applications. This article shows how to efficiently connect to Adobe Experience Manager data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Adobe Experience Manager in Jetty.
Configure the JDBC Driver for Salesforce as a JNDI Data Source
Follow the steps below to connect to Salesforce from Jetty.
Enable the JNDI module for your Jetty base. The following command enables JNDI from the command-line:
java -jar ../start.jar --add-to-startd=jndi
- Add the CData and license file, located in the lib subfolder of the installation directory, into the lib subfolder of the context path.
-
Declare the resource and its scope. Enter the required connection properties in the resource declaration. This example declares the Adobe Experience Manager data source at the level of the Web app, in WEB-INF\jetty-env.xml.
<Configure id='adobeexperiencemanagerdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="adobeexperiencemanagerdemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="adobeexperiencemanagerdemo"/></Arg> <Arg>jdbc/adobeexperiencemanagerdb</Arg> <Arg> <New class="cdata.jdbc.adobeexperiencemanager.AdobeExperienceManagerDriver"> <Set name="url">jdbc:adobeexperiencemanager:</Set> <Set name="URL">https://author-p12345-e67890.adobeaemcloud.com/crx/server</Set> <Set name="User">admin</Set> <Set name="Password">admin</Set> </New> </Arg> </New> </Configure>The driver connects to Adobe Experience Manager (AEM) instances that expose the JCR repository over WebDAV. It supports both on-premises AEM and AEM as a Cloud Service deployments.
To establish a connection, set the following properties:
- URL: The WebDAV-enabled JCR server URL.
- AEM as a Cloud Service: https://author-pXXXXX-eXXXXX.adobeaemcloud.com/crx/server
- Local development: http://localhost:4502/crx/server
- User: Your AEM username.
- Password: Your AEM password.
Note: Tables are dynamically generated based on the JCR repository structure. Ensure that the configured user has sufficient permissions to access the required content paths in the AEM repository.
- URL: The WebDAV-enabled JCR server URL.
-
Configure the resource in the Web.xml:
jdbc/adobeexperiencemanagerdb javax.sql.DataSource Container
-
You can then access Adobe Experience Manager with a lookup to java:comp/env/jdbc/adobeexperiencemanagerdb:
InitialContext ctx = new InitialContext(); DataSource myadobeexperiencemanager = (DataSource)ctx.lookup("java:comp/env/jdbc/adobeexperiencemanagerdb");
More Jetty Integration
The steps above show how to configure the driver in a simple connection pooling scenario. For more use cases and information, see the Working with Jetty JNDI chapter in the Jetty documentation.