How to create OSGI Teradata Database Connection using driver and config jar ?

Solution Verified - Updated -

Issue

  • User is trying to connect to a Teradata database from an OSGI bundle.
  • User has created test-teradata-connnection which contains a Spring file that sets up a org.apache.commons.dbcp.BasicDataSource bean and a bean which attempts to connect using it.
  • The bean is able to connect fine when running as a Java Application from the Main class.
  • However, when installed in JBoss Fuse, user get the error java.lang.NoClassDefFoundError: Could not initialize class com.teradata.tdgss.jtdgss.TdgssManager.
  • User has created a wrapper bundle which embeds the Teradata driver jars and exports all packages under com.teradata.
  • User has also created a fragment for org.apache.servicemix.bundles.commons-dbcp to tell dbcp to import every package under com.teradata.
  • Following are the logs.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myBean' defined in URL [bundle://327.15:0/META-INF/spring/bundle-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.teradata.tdgss.jtdgss.TdgssManager
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)[121:org.apache.servicemix.bundles.spring-context:3.2.8.RELEASE_1]
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[146:org.springframework.osgi.core:1.2.1]
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[146:org.springframework.osgi.core:1.2.1]
    at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[146:org.springframework.osgi.core:1.2.1]
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[146:org.springframework.osgi.core:1.2.1]
    at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[145:org.springframework.osgi.extender:1.2.1]
    at java.lang.Thread.run(Thread.java:745)[:1.7.0_67]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.teradata.tdgss.jtdgss.TdgssManager
    at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getTDgssVersion(GenericTeraEncrypt.java:640)
    at com.teradata.jdbc.jdbc_4.parcel.ClientConfigParcel.toStream(ClientConfigParcel.java:54)
    at com.teradata.jdbc.jdbc_4.io.TDPacket.addParcel(TDPacket.java:98)
    at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonController.java:94)
    at com.teradata.jdbc.jdbc_4.TDSession.<init>(TDSession.java:208)
    at com.teradata.jdbc.jdk6.JDK6_SQL_Connection.<init>(JDK6_SQL_Connection.java:35)
    at com.teradata.jdbc.jdk6.JDK6ConnectionFactory.constructSQLConnection(JDK6ConnectionFactory.java:25)
    at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:179)
    at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:169)
    at com.teradata.jdbc.TeraDriver.doConnect(TeraDriver.java:233)
    at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:159)
    at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
    at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
    at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
    at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
    at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
    at com.menards.test.test_teradata_connection.osgi.Bean.init(Bean.java:12)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_67]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_67]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_67]
    at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_67]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1638)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1579)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)[124:org.apache.servicemix.bundles.spring-beans:3.2.8.RELEASE_1]
    ... 14 more

Environment

  • Red Hat JBoss Fuse
    • 6.1.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.