Search code examples
javaapache-karaf

java.lang.ClassNotFoundException: javax.sql.DataSource cannot be found


I'm using Karaf 4.4.3 with Postgres JDBC 42.6.0 and trying to create PGSimpleDataSource PGSimpleDataSource dataSource = new PGSimpleDataSource(); but get exception while Karaf starting java.lang.ClassNotFoundException: javax.sql.DataSource cannot be found by ***. What might be the reason and how can I fix it?

I have installed the following features but it didn't help

jdbc/1.5.5, \
pax-jdbc/1.5.5, \
pax-jdbc-postgresql/1.5.5, \
pax-jdbc-config/1.5.5, \

Solution

  • I have solved my problem. I added javax.sql to Karaf config.properties file.

    org.osgi.framework.bootdelegation = \
        com.sun.*, \
        javax.sql, \
        javax.naming, \
        javax.transaction, \
        javax.transaction.xa, \
        # other default stuff goes here