siddhiwso2-streaming-integrator

Unable to connect to postgres using Wso2sp


I'm trying to connect to a Postgres Db using Wso2Sp.

I have tried making changes in deployment.yaml file found in SP_Home/conf/worker/.

As mentioned in the documentation, this is the section I added to the wso2.datasources section.

# Postgres
    -  name: WSO2_TEST_DB
       description: The datasource used for test database
       jndiConfig: 
         name: jdbc/WSO2_TEST_DB
       definition:
         type: RDBMS
         configuration:
           jdbcUrl: jdbc:postgresql://<host>:<port>/<db>
           username: <user>
           password: <password>
           driverClassName: org.postgresql.Driver
           maxPoolSize: 10
           idleTimeout: 60000
           connectionTestQuery: SELECT 1
           validationTimeout: 30000
           isAutoCommit: false

When I restart my worker container and check the logs, this is what I get.

JAVA_HOME environment variable is set to /opt/java/openjdk
CARBON_HOME environment variable is set to /home/wso2carbon/wso2sp-4.4.0
RUNTIME_HOME environment variable is set to /home/wso2carbon/wso2sp-4.4.0/wso2/worker
osgi> [2019-08-20 12:31:20,714]  INFO {org.wso2.msf4j.internal.websocket.WebSocketServerSC} - All required capabilities are available of WebSocket service component is available.
[2019-08-20 12:31:20,757]  INFO {org.wso2.carbon.metrics.core.config.model.JmxReporterConfig} - Creating JMX reporter for Metrics with domain 'org.wso2.carbon.metrics'
[2019-08-20 12:31:20,780]  INFO {org.wso2.msf4j.analytics.metrics.MetricsComponent} - Metrics Component is activated
[2019-08-20 12:31:20,787]  INFO {org.wso2.carbon.databridge.agent.internal.DataAgentDS} - Successfully deployed Agent Server
[2019-08-20 12:31:24,617] ERROR {org.wso2.carbon.kernel.internal.startupresolver.StartupComponentManager} - Runtime Exception occurred while calling onAllRequiredCapabilitiesAvailable of component carbon-datasource-service java.lang.RuntimeException: Unable to get driver instance for jdbcUrl=jdbc:postgresql://<host>:<port>/<db>
        at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:88)
        at com.zaxxer.hikari.pool.PoolElf.initializeDataSource(PoolElf.java:157)
        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:113)
        at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:73)
        at org.wso2.carbon.datasource.rdbms.hikari.HikariRDBMSDataSource.getDataSource(HikariRDBMSDataSource.java:56)
        at org.wso2.carbon.datasource.rdbms.hikari.HikariDataSourceReader.createDataSource(HikariDataSourceReader.java:74)
        at org.wso2.carbon.datasource.core.DataSourceBuilder.buildDataSourceObject(DataSourceBuilder.java:79)
        at org.wso2.carbon.datasource.core.DataSourceBuilder.buildDataSourceObject(DataSourceBuilder.java:60)
        at org.wso2.carbon.datasource.core.DataSourceBuilder.buildCarbonDataSource(DataSourceBuilder.java:44)
        at org.wso2.carbon.datasource.core.DataSourceManager.initDataSources(DataSourceManager.java:153)
        at org.wso2.carbon.datasource.core.internal.DataSourceListenerComponent.onAllRequiredCapabilitiesAvailable(DataSourceListenerComponent.java:125)
        at org.wso2.carbon.kernel.internal.startupresolver.StartupComponentManager.lambda$notifySatisfiableComponents$7(StartupComponentManager.java:266)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at org.wso2.carbon.kernel.internal.startupresolver.StartupComponentManager.notifySatisfiableComponents(StartupComponentManager.java:252)
        at org.wso2.carbon.kernel.internal.startupresolver.StartupOrderResolver$1.run(StartupOrderResolver.java:204)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)
Caused by: java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getDriver(DriverManager.java:315)
        at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:81)
        ... 16 more

[2019-08-20 12:32:20,489]  WARN {org.wso2.carbon.kernel.internal.startupresolver.StartupOrderResolver} - Startup component carbon-deployment-service from bundle(org.wso2.carbon.deployment.engine:5.2.0) is in the pending state until Capability org.wso2.carbon.deployment.engine.Deployer from bundle(org.wso2.carbon.event.simulator.core:2.1.22) is available as an OSGi service. Refer the Startup Order Resolver documentation for information.

What am I missing here?


Solution

  • You have to add the OSGi compatible postgresql connectors to {SP_HOME}/lib folder.

    Please see https://docs.wso2.com/display/SP4xx/Adding+Third+Party+Non+OSGi+Libraries for more details