April 27, 2020
Estimated Post Reading Time ~

Caused by: java.lang.NoClassDefFoundError: javax/management/InstanceAlreadyExistsException while connecting to Oracle Database from OSGI

I was getting the below exception while connecting to the Oracle 11g database using ojbdc6.jar from OSGI in AEM

20.02.2018 15:43:39.259 *INFO* [CM Event Dispatcher (Fire ConfigurationEvent: pid=com.day.commons.datasource.jdbcpool.JdbcPoolService.c26da860-d7f1-4e63-9b2c-1138a6bafaeb)] day.commons.datasource.jdbcpool Configuring and activating data source with name=SampleOracleDS
20.02.2018 15:43:39.260 *ERROR* [CM Event Dispatcher (Fire ConfigurationEvent: pid=com.day.commons.datasource.jdbcpool.JdbcPoolService.c26da860-d7f1-4e63-9b2c-1138a6bafaeb)] day.commons.datasource.jdbcpool [com.day.commons.datasource.jdbcpool.JdbcPoolService(2238)] The activate method has thrown an exception (java.lang.IllegalArgumentException: Cannot initialize driver 'oracle.jdbc.driver.OracleDriver')
java.lang.IllegalArgumentException: Cannot initialize driver 'oracle.jdbc.driver.OracleDriver'
at com.day.commons.datasource.jdbcpool.JdbcPoolService.initalizeDriver(JdbcPoolService.java:301)
at com.day.commons.datasource.jdbcpool.JdbcPoolService.setupDataSource(JdbcPoolService.java:227)
at com.day.commons.datasource.jdbcpool.JdbcPoolService.activate(JdbcPoolService.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:222)
at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)
at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:615)
at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:499)
at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:295)
at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:302)
at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:113)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:832)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:799)
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:749)
at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:343)
at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:243)
at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:357)
at org.apache.felix.framework.Felix.getService(Felix.java:3671)
at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:470)
at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:72)
at org.apache.felix.scr.impl.helper.BindMethod.getServiceObject(BindMethod.java:576)
at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2037)
at org.apache.felix.scr.impl.manager.DependencyManager.invokeUnbindMethod(DependencyManager.java:1712)
at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeUnbindMethod(SingleComponentManager.java:392)
at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:372)
at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:303)
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1518)
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1413)
at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.untrack(ServiceTracker.java:1273)
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1452)
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:987)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)

at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4547)
at org.apache.felix.framework.Felix.access$000(Felix.java:106)
at org.apache.felix.framework.Felix$1.serviceChanged(Felix.java:436)
at org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:165)
at org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:140)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:883)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.unregister(AbstractComponentManager.java:857)
at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:140)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.unregisterService(AbstractComponentManager.java:925)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.doDeactivate(AbstractComponentManager.java:774)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.deactivateInternal(AbstractComponentManager.java:757)
at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:601)
at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:552)
at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.configurationUpdated(ConfigurableComponentHolder.java:419)
at org.apache.felix.scr.impl.config.ConfigurationSupport.configurationEvent(ConfigurationSupport.java:297)
at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.sendEvent(ConfigurationManager.java:2032)
at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.run(ConfigurationManager.java:2002)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:103)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: javax/management/InstanceAlreadyExistsException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.day.commons.datasource.jdbcpool.JdbcPoolService.initalizeDriver(JdbcPoolService.java:299)
... 54 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.management.InstanceAlreadyExistsException not found by com.jdbc.oracle [446]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1557)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1998)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 59 common frames omitted

Based on the analysis the classes required by the ojdbc.jar are missing in the generated bundle.

Steps to fix the issue -
Refer the following post for complete steps to integrate Adobe Experience Manager(AEM) with Oracle Database - https://www.albinsblog.com/2015/03/how-to-connect-to-oracle-database-using.html

Add the below Import-Package in META-INF\MANIFEST.MF file
Import-Package: javax.sql, javax.naming, javax.management, org.ietf.jgss



Generate the bundle by adding the above configuration(Export --> Deployable plug-ins and fragments)
Delete the bundle if already exist in the server
Install the updated bundle
Restart the server
Test the integration


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.