Tuesday, June 14, 2016

Drill in an OSGi container inside a bundle

I was getting the error:
14 Jun 2016 15:36:21,906 ERROR activator.ContextLoaderListener - Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=drill-datasource-provider, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'drillProvider' defined in URL [bundleentry://14.fwk1254526270/META-INF/spring/drill-beans.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/drill/jdbc/impl/DriverImpl
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)
    at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)
    at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
    at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)
    at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoClassDefFoundError: org/apache/drill/jdbc/impl/DriverImpl
    at org.apache.drill.jdbc.Driver.(Driver.java:66)
    at edu.emory.cci.bindaas.datasource.provider.drill.DrillProvider.getDatabaseDriver(DrillProvider.java:50)
    at edu.emory.cci.bindaas.datasource.provider.drill.DrillProvider.getDatabaseDriver(DrillProvider.java:13)
    at edu.emory.cci.bindaas.datasource.provider.genericsql.AbstractSQLProvider.init(AbstractSQLProvider.java:31)
    at edu.emory.cci.bindaas.datasource.provider.drill.DrillProvider.init(DrillProvider.java:21)
    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:483)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1614)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485)
    ... 14 more
14 Jun 2016 15:36:21,920 ERROR startup.DependencyWaiterApplicationContextExecutor - Unable to create application context for [drill-datasource-provider], unsatisfied dependencies: none
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'drillProvider' defined in URL [bundleentry://14.fwk1254526270/META-INF/spring/drill-beans.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/drill/jdbc/impl/DriverImpl
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)
    at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)
    at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
    at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)
    at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoClassDefFoundError: org/apache/drill/jdbc/impl/DriverImpl
    at org.apache.drill.jdbc.Driver.(Driver.java:66)
    at edu.emory.cci.bindaas.datasource.provider.drill.DrillProvider.getDatabaseDriver(DrillProvider.java:50)
    at edu.emory.cci.bindaas.datasource.provider.drill.DrillProvider.getDatabaseDriver(DrillProvider.java:13)
    at edu.emory.cci.bindaas.datasource.provider.genericsql.AbstractSQLProvider.init(AbstractSQLProvider.java:31)
    at edu.emory.cci.bindaas.datasource.provider.drill.DrillProvider.init(DrillProvider.java:21)
    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:483)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1614)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485)
    ... 14 more
14 Jun 2016 15:36:22,068 DEBUG util.DynamicProperties - Loaded default properties


I am sure the DriverImpl class exists inside the drill-java-1.6.0.jar. I had a bunch of jars in the class path, with the relevant entries in the beans.xml.
drill-common-1.6.0.jar
drill-java-exec-1.6.0.jar
drill-jdbc-1.6.0.jar
drill-logical-1.6.0.jar
drill-memory-base-1.6.0.jar
drill-protocol-1.6.0.jar
drill-rpc-1.6.0.jar


I just had to replace all of these with the drill-jdbc-all-1.6.0.jar to the class path and beans.xml to fix this weird error. Probably there is a better fix. But this worked for me. :)

No comments:

Post a Comment

You are welcome to provide your opinions in the comments. Spam comments and comments with random links will be deleted.