Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Unable to connect to Oracle Db though OCI driver

Avatar

Level 4

We have searched around and understood that the if we can add oracle path into startup parameters, we should be able to use OCI driver to connect to oracle Database.

Could anyone help us how to add this to AEM startup script?

6 Replies

Avatar

Level 10

You need to add the DataBase driver file to an OSGi bundle and deploy that to AEM.

See this article as an example - notice how we wrap MySQL Driver file into an OSGi bundle. YOu need to do the same for this Oracle database driver file.

Adobe Experience Manager Help | Querying MySQL data using an Adobe Experience Manager 6.4 DataSource...

See this section:

Add the MySQL driver file to Experience Manager

You have to deploy a bundle to Experience Manager that contains the database driver file. In this development article, the name of the database driver file is mysql-connector-java-5.1.22-bin.

To learn how to place a JDBC Driver file into an OSGi bundle, see "Add the MySQL driver file to Experience Manager" in https://helpx.adobe.com/experience-manager/using/datasourcepool.html.

Note:

If you do not add a database driver file, then the Experience Manager service cannot interact with the relational database.

Avatar

Level 4

As we are using oracle DB, we have built the below bundle and installed on the server.

the bundle is in active state on the server, but we are getting an error (org.apache.tomcat.jdbc.pool.ConnectionPool Unable to create initial connections of pool.java.sql.SQLException: The Network Adapter could not establish the connection)

ojdbc6-osgiojdbc6-osgi

Symbolic Nameojdbc6-osgi
Version11.1.0
Bundle Locationinputstream:ojdbc6-osgi-11.1.0.jar
Last ModificationWed Nov 28 09:53:39 EST 2018
VendorOracle
DescriptionOSGi wrapper bundle for Oracle JDBC driver for Java 6.
Start Level20
Exported Packagesoracle.core.lmx,version=11.1.0
oracle.core.lvf,version=11.1.0
oracle.jdbc,version=11.1.0
oracle.jdbc.aq,version=11.1.0
oracle.jdbc.connector,version=11.1.0
oracle.jdbc.dcn,version=11.1.0
oracle.jdbc.driver,version=11.1.0
oracle.jdbc.internal,version=11.1.0
oracle.jdbc.oci,version=11.1.0
oracle.jdbc.oracore,version=11.1.0
oracle.jdbc.pool,version=11.1.0
oracle.jdbc.rowset,version=11.1.0
oracle.jdbc.util,version=11.1.0
oracle.jdbc.xa,version=11.1.0
oracle.jdbc.xa.client,version=11.1.0
oracle.jpub.runtime,version=11.1.0
oracle.net.ano,version=11.1.0
oracle.net.aso,version=11.1.0
oracle.net.jdbc.TNSAddress,version=11.1.0
oracle.net.jdbc.nl,version=11.1.0
oracle.net.jdbc.nl.mesg,version=11.1.0
oracle.net.jndi,version=11.1.0
oracle.net.mesg,version=11.1.0
oracle.net.ns,version=11.1.0
oracle.net.nt,version=11.1.0
oracle.net.resolver,version=11.1.0
oracle.security.o3logon,version=11.1.0
oracle.security.o5logon,version=11.1.0
oracle.sql,version=11.1.0
oracle.sql.converter,version=11.1.0
oracle.sql.converter_xcharset,version=11.1.0
Imported Packagesjavax.crypto,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.crypto.spec,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.management,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.naming,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.naming.directory,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.naming.spi,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.net,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.net.ssl,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.security.auth,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.security.auth.callback,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.security.auth.kerberos,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.security.cert,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.sql,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.sql.rowset,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.sql.rowset.spi,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
javax.transaction.xa,version=1.1.0 from org.apache.aries.transaction.manager (27)
javax.xml.parsers,version=0.0.0.fragment_xml from org.apache.felix.framework (0)
org.ietf.jgss,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
org.w3c.dom,version=0.0.0.fragment_xml from org.apache.felix.framework (0)
org.xml.sax,version=0.0.0.fragment_xml from org.apache.felix.framework (0)
org.xml.sax.helpers,version=0.0.0.fragment_xml from org.apache.felix.framework (0)
Importing Bundlesday.commons.datasource.jdbcpool (445)
Manifest HeadersBnd-LastModified: 1537838936538
Build-Jdk: 1.8.0_181
Built-By: lidrdgx
Bundle-Description: OSGi wrapper bundle for Oracle JDBC driver for Java 6.
Bundle-License: non-free
Bundle-ManifestVersion: 2
Bundle-Name: ojdbc6-osgi
Bundle-SymbolicName: ojdbc6-osgi
Bundle-Vendor: Oracle
Bundle-Version: 11.1.0
Created-By: Apache Maven Bundle Plugin
Embed-Dependency: *; scope=compile|runtime; type=!pom; inline=true
Export-Package: oracle.core.lmx; version="11.1.0", oracle.core.lvf; version="11.1.0", oracle.jdbc; version="11.1.0"; uses:="oracle.jdbc.aq, oracle.jdbc.dcn, oracle.jdbc.driver, oracle.jdbc.internal, oracle.jdbc.pool, oracle.sql", oracle.jdbc.aq; version="11.1.0"; uses:="oracle.jdbc, oracle.sql", oracle.jdbc.connector; version="11.1.0"; uses:="javax.resource, javax.resource.spi, javax.resource.spi.endpoint, javax.security.auth, javax.sql, javax.transaction.xa", oracle.jdbc.dcn; version="11.1.0"; uses:="oracle.jdbc, oracle.sql", oracle.jdbc.driver; version="11.1.0"; uses:="javax.management, javax.transaction.xa, oracle.jdbc, oracle.jdbc.aq, oracle.jdbc.dcn, oracle.jdbc.internal, oracle.jdbc.oracore, oracle.jdbc.pool, oracle.jdbc.xa.client, oracle.net.ns, oracle.sql", oracle.jdbc.internal; version="11.1.0"; uses:="javax.transaction.xa, oracle.jdbc, oracle.jdbc.oracore, oracle.jdbc.pool, oracle.sql", oracle.jdbc.oci; version="11.1.0"; uses:="oracle.jdbc.driver", oracle.jdbc.oracore; version="11.1.0"; uses:="oracle.jdbc.internal, oracle.sql", oracle.jdbc.pool; version="11.1.0"; uses:="javax.naming, javax.naming.spi, javax.sql, javax.transaction.xa, oracle.jdbc, oracle.jdbc.driver, oracle.jdbc.internal, oracle.jdbc.oci", oracle.jdbc.rowset; version="11.1.0"; uses:="javax.sql, javax.sql.rowset, javax.sql.rowset.spi, oracle.jdbc, oracle.jdbc.internal", oracle.jdbc.util; version="11.1.0", oracle.jdbc.xa; version="11.1.0"; uses:="javax.sql, javax.transaction.xa, oracle.jdbc.pool", oracle.jdbc.xa.client; version="11.1.0"; uses:="javax.sql, javax.transaction.xa, oracle.jdbc.driver, oracle.jdbc.internal, oracle.jdbc.xa", oracle.jpub.runtime; version="11.1.0"; uses:="oracle.jdbc, oracle.jdbc.driver, oracle.jdbc.internal, oracle.sql", oracle.net.ano; version="11.1.0"; uses:="oracle.net.aso, oracle.net.ns", oracle.net.aso; version="11.1.0", oracle.net.jdbc.TNSAddress; version="11.1.0"; uses:="oracle.net.jdbc.nl", oracle.net.jdbc.nl; version="11.1.0", oracle.net.jdbc.nl.mesg; version="11.1.0", oracle.net.jndi; version="11.1.0"; uses:="javax.net, javax.net.ssl, oracle.net.ns", oracle.net.mesg; version="11.1.0", oracle.net.ns; version="11.1.0"; uses:="oracle.net.ano, oracle.net.nt", oracle.net.nt; version="11.1.0"; uses:="javax.net.ssl, oracle.net.jdbc.nl, oracle.net.ns", oracle.net.resolver; version="11.1.0"; uses:="oracle.net.jdbc.TNSAddress, oracle.net.ns, oracle.net.nt", oracle.security.o3logon; version="11.1.0", oracle.security.o5logon; version="11.1.0", oracle.sql; version="11.1.0"; uses:="oracle.jdbc, oracle.jdbc.driver, oracle.jdbc.internal, oracle.jdbc.oracore, oracle.sql.converter", oracle.sql.converter; version="11.1.0"; uses:="oracle.i18n.text.converter, oracle.jdbc.internal", oracle.sql.converter_xcharset; version="11.1.0"
Import-Package: com.sun.security.auth.module; resolution:=optional, javax.crypto; resolution:=optional, javax.crypto.spec; resolution:=optional, javax.management; resolution:=optional, javax.naming; resolution:=optional, javax.naming.directory; resolution:=optional, javax.naming.spi; resolution:=optional, javax.net; resolution:=optional, javax.net.ssl; resolution:=optional, javax.resource; resolution:=optional, javax.resource.spi; resolution:=optional, javax.resource.spi.endpoint; resolution:=optional, javax.resource.spi.security; resolution:=optional, javax.security.auth; resolution:=optional, javax.security.auth.callback; resolution:=optional, javax.security.auth.kerberos; resolution:=optional, javax.security.cert; resolution:=optional, javax.sql; resolution:=optional, javax.sql.rowset; resolution:=optional, javax.sql.rowset.spi; resolution:=optional, javax.transaction.xa; resolution:=optional, javax.xml.parsers; resolution:=optional, oracle.i18n.text; resolution:=optional, oracle.i18n.text.converter; resolution:=optional, oracle.ons; resolution:=optional, oracle.security.pki; resolution:=optional, org.ietf.jgss; resolution:=optional, org.w3c.dom; resolution:=optional, org.xml.sax; resolution:=optional, org.xml.sax.helpers; resolution:=optional
Manifest-Version: 1.0
Tool: Bnd-2.1.0.20130426-122213

Avatar

Level 10

I am going to try to wrap this and see what happens. Also checking with our team to see if there is any known issue.

I have tested AEM and relational database interaction with MySQL - which works fine.

Avatar

Level 10

I discussed this issue with our cust care team and they replied:

Tell them to provide the full stack trace. That looks like Tomcat can’t find their ODBC driver.

Likely a bundle compilation issue, driver is probably missing from the classpath.

When they compile their bundle, within the JAR that oracle driver needs to be in the WEB-INF/lib folder

Avatar

Level 4

Hi Donald,

PFB complete error trace

ERROR Snippet:

04.12.2018 10:34:31.303 *ERROR* [CM Event Dispatcher (Fire ConfigurationEvent: pid=org.apache.sling.datasource.DataSourceFactory.562debd3-59ee-4747-85c6-1a747dc6fcd0)] org.apache.sling.datasource [org.apache.sling.datasource.DataSourceFactory(5516)] The modified method has thrown an exception (java.sql.SQLException: The Network Adapter could not establish the connection)

java.sql.SQLException: The Network Adapter could not establish the connection

        at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)

        at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)

        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)

        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:480)

        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:413)

        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508)

        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)

        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)

        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)

        at org.apache.sling.datasource.internal.DriverDataSource.getConnection(DriverDataSource.java :85)

        at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDataSource(PooledConnection.java :224)

        at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:180)

        at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:713)

        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:647)

        at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:468)

        at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:145)

        at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)

        at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)

        at org.apache.sling.datasource.internal.DataSourceFactory$LazyJmxRegisteringDataSource.creat ePool(DataSourceFactory.java:364)

        at org.apache.sling.datasource.internal.DataSourceFactory.modified(DataSourceFactory.java:22 8)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:498)

        at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:224)

        at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39)

        at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:617)

        at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:501)

        at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:302)

        at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:294)

        at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeModifiedMethod(SingleCompo nentManager.java:772)

        at org.apache.felix.scr.impl.manager.SingleComponentManager.modify(SingleComponentManager.ja va:727)

        at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManag er.java:645)

        at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManag er.java:609)

        at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.configurationUpdated(Config urableComponentHolder.java:426)

        at org.apache.felix.scr.impl.manager.RegionConfigurationSupport.configurationEvent(RegionCon figurationSupport.java:277)

        at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.sendEvent(Configurat ionManager.java:1881)

        at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.run(ConfigurationMan ager.java:1849)

        at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:138)

        at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:105)

        at java.lang.Thread.run(Thread.java:745)

Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection

        at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:328)

        at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:421)

        at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:630)

        at oracle.net.ns.NSProtocol.connect(NSProtocol.java:206)

        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:966)

        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:292)

        ... 36 common frames omitted

Caused by: java.net.ConnectException: Connection refused

        at java.net.PlainSocketImpl.socketConnect(Native Method)

        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

        at java.net.Socket.connect(Socket.java:589)

        at java.net.Socket.connect(Socket.java:538)

        at java.net.Socket.<init>(Socket.java:434)

        at java.net.Socket.<init>(Socket.java:211)

        at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:127)

        at oracle.net.nt.ConnOption.connect(ConnOption.java:126)

        at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:306)

        ... 41 common frames omitted

Avatar

Level 4

Hi smacdonald2008 ,

could you please help us here, i have provided the complete stack trace here.