Can not find Driver when using generic database bundle
- by Marc
I have a project that is build up from several OSGi bundles. One of them is a generic Database bundle that defines a DataSource that can be used throughout the project. The spring bean definition of this service is:
<osgi:service interface="javax.sql.DataSource">
<bean class="org.postgresql.ds.PGPoolingDataSource">
<property name="databaseName" value="xxx" />
<property name="serverName" value="xxx" />
<property name="user" value="xxx" />
<property name="password" value="xxx" />
</bean>
</osgi:service>
Now, when using this DataSource is a different bundle, we get an error:
No suitable driver found for jdbc:postgresql://localhost/xxx
I have tried the following to add the org.postgresql.Driver to the DriverManager:
Instantiated an empty bean for that Driver in the spring context, like this:
<bean class="org.postgresql.Driver" />
Instantiated the Driver statically in one of the classes, like this:
Class.forName("org.postgresql.Driver");
Added a file META-INF\services\java.sql.Driver with the content org.postgresql.Driver
None of these solutions seems to help.