[Product-SP] Business rules does not support PostgresSQL datasources
CharukaK opened this issue · comments
Description:
When a PostgresSQL database is configured as the datasource for business rules it prints out the following error when trying to log into business rules
[2020-03-17 15:35:05,762] WARN {org.wso2.msf4j.internal.MSF4JHttpConnectorListener} - Unmapped exception java.lang.ExceptionInInitializerError at org.wso2.carbon.business.rules.core.datasource.QueryExecutor.<init>(QueryExecutor.java:54) at org.wso2.carbon.business.rules.core.services.TemplateManagerService.<init>(TemplateManagerService.java:75) at org.wso2.carbon.business.rules.core.bean.TemplateManagerInstance.<clinit>(TemplateManagerInstance.java:36) at org.wso2.carbon.business.rules.core.api.impl.BusinessRulesApiServiceImpl.getBusinessRules(BusinessRulesApiServiceImpl.java:197) at org.wso2.carbon.business.rules.core.api.BusinessRulesApi.getBusinessRules(BusinessRulesApi.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.wso2.msf4j.internal.router.HttpMethodInfo.invokeResource(HttpMethodInfo.java:187) at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMethodInfo.java:143) at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.dispatchMethod(MSF4JHttpConnectorListener.java:218) at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.lambda$onMessage$57(MSF4JHttpConnectorListener.java:129) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)Caused by: org.wso2.carbon.business.rules.core.exceptions.BusinessRulesDatasourceInitializationException: Error initializing connection. at org.wso2.carbon.business.rules.core.datasource.DataSourceServiceProvider.initConnection(DataSourceServiceProvider.java:82) at org.wso2.carbon.business.rules.core.datasource.DataSourceServiceProvider.<init>(DataSourceServiceProvider.java:51) at org.wso2.carbon.business.rules.core.datasource.DataSourceServiceProvider.<clinit>(DataSourceServiceProvider.java:45) ... 16 moreCaused by: org.wso2.carbon.database.query.manager.exception.QueryMappingNotAvailableException: Unable to load queries. at org.wso2.carbon.business.rules.core.datasource.QueryManager.readConfigs(QueryManager.java:70) at org.wso2.carbon.business.rules.core.datasource.QueryManager.<init>(QueryManager.java:48) at org.wso2.carbon.business.rules.core.datasource.DataSourceServiceProvider.initConnection(DataSourceServiceProvider.java:80) ... 18 moreCaused by: org.wso2.carbon.database.query.manager.exception.QueryMappingNotAvailableException: Mapping value for query: 'CHECK_FOR_BUSINESS_RULES_TABLE' not found in Deployment config Map and Component config Map for database type: 'PostgreSQL' and version '9.4.12'. at org.wso2.carbon.database.query.manager.QueryProvider.mergeMapping(QueryProvider.java:105) at org.wso2.carbon.business.rules.core.datasource.QueryManager.readConfigs(QueryManager.java:65) ... 20 more
This issue can be solved by building and replacing the business-rules.core module with the queries.yaml[1] which is present in the master branch of carbon-analytics.
After solving the business rules login issue when you try to configure a new business rule and try to save it the following error appears
[2020-03-18 10:12:57,378] ERROR {org.wso2.carbon.business.rules.core.api.impl.BusinessRulesApiServiceImpl} - Failed to load business rules org.wso2.carbon.business.rules.core.exceptions.TemplateManagerServiceException: org.wso2.carbon.business.rules.core.exceptions.BusinessRulesDatasourceException: Retrieving all the business rules from database is failed due to: Bad value for type long : \x7b0a20202272756c6554656d706c61746555554944223a2022686967685f6370755f75736167655f616c657274222c0a20202270726f70657274696573223a207b0a2020202022656d61696c223a202273616c7661746f72652e6465666964696f406e7474646174612e636f6d222c0a20202020227468726573686f6c64223a2022302e3430220a20207d2c0a20202275756964223a2022746573745f686967685f637075222c0a2020226e616d65223a2022546573745f486967685f435055222c0a20202274656d706c61746547726f757055554944223a2022486967685f5265736f757263655f55736167655f416c657274222c0a20202274797065223a202274656d706c617465220a7d at org.wso2.carbon.business.rules.core.services.TemplateManagerService.loadBusinessRulesFromDB(TemplateManagerService.java:807) at org.wso2.carbon.business.rules.core.services.TemplateManagerService.loadBusinessRules(TemplateManagerService.java:795) at org.wso2.carbon.business.rules.core.api.impl.BusinessRulesApiServiceImpl.getBusinessRules(BusinessRulesApiServiceImpl.java:205) at org.wso2.carbon.business.rules.core.api.BusinessRulesApi.getBusinessRules(BusinessRulesApi.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.wso2.msf4j.internal.router.HttpMethodInfo.invokeResource(HttpMethodInfo.java:187) at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMethodInfo.java:143) at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.dispatchMethod(MSF4JHttpConnectorListener.java:218) at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.lambda$onMessage$57(MSF4JHttpConnectorListener.java:129) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)Caused by: org.wso2.carbon.business.rules.core.exceptions.BusinessRulesDatasourceException: Retrieving all the business rules from database is failed due to: Bad value for type long : \x7b0a20202272756c6554656d706c61746555554944223a2022686967685f6370755f75736167655f616c657274222c0a20202270726f70657274696573223a207b0a2020202022656d61696c223a202273616c7661746f72652e6465666964696f406e7474646174612e636f6d222c0a20202020227468726573686f6c64223a2022302e3430220a20207d2c0a20202275756964223a2022746573745f686967685f637075222c0a2020226e616d65223a2022546573745f486967685f435055222c0a20202274656d706c61746547726f757055554944223a2022486967685f5265736f757263655f55736167655f416c657274222c0a20202274797065223a202274656d706c617465220a7d at org.wso2.carbon.business.rules.core.datasource.QueryExecutor.executeRetrieveAllBusinessRules(QueryExecutor.java:274) at org.wso2.carbon.business.rules.core.services.TemplateManagerService.loadBusinessRulesFromDB(TemplateManagerService.java:805) ... 14 moreCaused by: org.postgresql.util.PSQLException: Bad value for type long : \x7b0a20202272756c6554656d706c61746555554944223a2022686967685f6370755f75736167655f616c657274222c0a20202270726f70657274696573223a207b0a2020202022656d61696c223a202273616c7661746f72652e6465666964696f406e7474646174612e636f6d222c0a20202020227468726573686f6c64223a2022302e3430220a20207d2c0a20202275756964223a2022746573745f686967685f637075222c0a2020226e616d65223a2022546573745f486967685f435055222c0a20202274656d706c61746547726f757055554944223a2022486967685f5265736f757263655f55736167655f416c657274222c0a20202274797065223a202274656d706c617465220a7d at org.postgresql.jdbc.PgResultSet.toLong(PgResultSet.java:2873) at org.postgresql.jdbc.PgResultSet.getLong(PgResultSet.java:2099) at org.postgresql.jdbc.PgResultSet.getBlob(PgResultSet.java:419) at com.zaxxer.hikari.proxy.HikariResultSetProxy.getBlob(HikariResultSetProxy.java) at org.wso2.carbon.business.rules.core.datasource.QueryExecutor.executeRetrieveAllBusinessRules(QueryExecutor.java:239) ... 15 more
Affected Product Version:
Product-SP 4.4.0