rejimathews opened a new issue #892: Defining datasource in groovy and using in XML routes URL: https://github.com/apache/camel-k/issues/892 Hello ! Just need a quick help here. Since Camel k doesn't understand <beans>.. fragment, I tried adding a data-source bean via groovy script as follows ```groovy import org.apache.commons.dbcp.BasicDataSource; context { registry { mysqlDataSource = { org.apache.commons.dbcp.BasicDataSource mysqlDataSource = new org.apache.commons.dbcp.BasicDataSource() mysqlDataSource.url = 'jdbc:mysql://10.213.96.182/test' mysqlDataSource.username = 'testuser' mysqlDataSource.password = '******' mysqlDataSource.driverClassName = 'com.mysql.jdbc.Driver' return mysqlDataSource } } } ``` My route looks like ```xml <?xml version="1.0" encoding="UTF-8"?> <routes xmlns="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <route streamCache="true"> <from uri="jetty:http://0.0.0.0:9090/address" /> <log message="Received request to query table" /> <to uri="sql:SELECT * FROM address?dataSource=mysqlDataSource" /> <log message="Received records ${body}" /> <convertBodyTo type="java.lang.String" /> </route> </routes> ``` But looks like Camel-K doesn't detect this registry entry. ```text [1] 2019-07-31 19:29:12.984 INFO [main] DefaultCamelContext - Apache Camel 2.23.2 (CamelContext: camel-k) is shutdown in 0.013 seconds [1] Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[sql:SELECT * FROM address?dataSource=mysqlDataSource] <<< in route: Route(route1)[[From[jetty:http://0.0.0.0:9090/address]] -> [... because of Failed to resolve endpoint: sql://SELECT%20*%20FROM%20address?dataSource=mysqlDataSource due to: DataSource must be configured [1] at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1352) ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
