Getting "java.lang.UnsupportedOperationException: Not supported by BasicDataSource" when trying to use a JDBC DataSource in JBoss Fuse
Issue
We deploy two OSGi bundles.
In one bundle we define a JDBC DataSource using commons-dbcp and export it as an OSGI service.
In the other bundle we import the JDBC DataSource and try to use it in a Camel route.
The DataSource definition of the first bundle is similar to this example:
<bean id="MSSqlServer" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value>
</property>
<property name="url">
<value>jdbc:sqlserver://localhost;databaseName=test</value>
</property>
</bean>
<service id="service-MSSqlServer" interface="javax.sql.DataSource" ref="MSSqlServer">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/MSSqlServer" />
<entry key="datasource.name" value="MSSQLServer" />
</service-properties>
</service>
However at runtime the call to DataSource.getConnection() fails with
java.lang.UnsupportedOperationException: Not supported by BasicDataSource
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1062)
at org.tranql.connector.jdbc.AbstractLocalDataSourceMCF.getPhysicalConnection(AbstractLocalDataSourceMCF.java:72)
at org.tranql.connector.jdbc.AbstractLocalDataSourceMCF.createManagedConnection(AbstractLocalDataSourceMCF.java:66)
at org.apache.geronimo.connector.outbound.MCFConnectionInterceptor.getConnection(MCFConnectionInterceptor.java:48)
at org.apache.geronimo.connector.outbound.LocalXAResourceInsertionInterceptor.getConnection(LocalXAResourceInsertionInterceptor.java:41)
at org.apache.geronimo.connector.outbound.SinglePoolConnectionInterceptor.internalGetConnection(SinglePoolConnectionInterceptor.java:70)
at org.apache.geronimo.connector.outbound.AbstractSinglePoolConnectionInterceptor.getConnection(AbstractSinglePoolConnectionInterceptor.java:80)
at org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor.getConnection(TransactionEnlistingInterceptor.java:49)
at org.apache.geronimo.connector.outbound.TransactionCachingInterceptor.getConnection(TransactionCachingInterceptor.java:109)
at org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.getConnection(ConnectionHandleInterceptor.java:43)
at org.apache.geronimo.connector.outbound.TCCLInterceptor.getConnection(TCCLInterceptor.java:39)
at org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.getConnection(ConnectionTrackingInterceptor.java:66)
at org.apache.geronimo.connector.outbound.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:81)
at org.tranql.connector.jdbc.TranqlDataSource.getConnection(TranqlDataSource.java:62)
at org.apache.karaf.jdbc.internal.JdbcServiceImpl.info(JdbcServiceImpl.java:368)
at Proxyea9f8073_24bc_4547_8b35_91ac2a100ae5.info(Unknown Source)
at org.apache.karaf.jdbc.command.DataSourcesCommand.doExecute(DataSourcesCommand.java:44)
at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
at sun.reflect.GeneratedMethodAccessor759.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)[:1.8.0_91]
at java.lang.reflect.Method.invoke(Unknown Source)[:1.8.0_91]
at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54)[19:org.apache.aries.proxy.impl:1.0.5]
at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119)[19:org.apache.aries.proxy.impl:1.0.5]
at org.apache.karaf.shell.console.commands.$BlueprintCommand1836742640.execute(Unknown Source)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
at org.apache.karaf.shell.console.jline.Console.run(Console.java:197)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
at org.apache.karaf.shell.console.jline.DelayedStarted.run(DelayedStarted.java:79)[38:org.apache.karaf.shell.console:2.4.0.redhat-630187]
Environment
- JBoss Fuse 6.3
- JBoss Fuse 6.2.1
connectorOSGi feature installed
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
