OSGI with Hibernate: “No suitable driver found?

If you put the Hibernate and the Postgresql JDBC jar in the same OSGi bundle, it should work. This is what BIRT does load its jdbc drivers.

Up vote 1 down vote favorite share g+ share fb share tw.

I'm getting the beloved error: java.sql. SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/acme I understand many reasons why this error usually arises: Invalid URL: This URL doesn't seem to have any errors in it and works perfectly fine in SQL Workbench. Driver Not on ClassPath: It is successfully imported (org.postgresql.

Driver) and can be instantiated either directly or by using Class. ForName("org.postgresql. Driver").

The Hibernate SessionFactory loading is initiated from a Spring-Bean but is carried out at runtime with the following properties: hibernate. Dialect = org.hibernate.dialect. PostgreSQLDialect hibernate.connection.

Driver_class = org.postgresql. Driver hibernate.connection. Url = jdbc:postgresql://localhost:5432/acme hibernate.connection.

Username = user hibernate.connection. Password = pass I understand that the Java DriverManager does not work in OSGi, so registering the driver with the DriverManager or instantiating it to force it to register has no effect. Does anyone know how I can fix this?

Is there a common solution? Thanks in advance! The Solution As pointed out by Andres Olarte, I made a mistake of adding the driver to the implementation bundle, but leaving it out of the Hibernate bundle where Hibernate's classes and dependencies reside.

Hibernate postgresql jdbc osgi equinox link|improve this question edited Nov 7 '11 at 10:57 asked Nov 4 '11 at 17:10Tony Day35019 100% accept rate.

You might be able to access classes in the Hibernate and PostgreSQL bundle from a third bundle, but that doesn't mean that the Hibernate bundle will be able to access the class in the PostgreSQL bundle. The Hibernate bundle will be able to access the class in the PostgreSQL if it's aware of it. Does it make sense?

– Andres Olarte Nov 4 '11 at 20:06 It's likely this is the problem since I don't recall making any changes to the Hibernate bundle since adding the PostgreSQL driver and as you guessed my Hibernate SessionFactory is in a third bundle! I will look at this on Monday and get back to you. – Tony Day Nov 5 '11 at 0:27 Thanks Andres, this was exactly the problem!

Can't believe that I missed something so small, it really can be a steep learning curve on OSGi. Can you also update your answer to reflect this. Thanks again.

– Tony Day Nov 7 '11 at 10:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions