1
votes

We are trying to execute the composed task from spring cloud data flow(1.2.3.RELEASE) with Oracle database for storing the status of the task/jobs. When I run the individual task or jobs it runs smoothly with out any error. To run the conposed task as specified in the documentation I have registered composed-task-runner(1.1.0.RELEASE) as an app in the SCDF. But when I launch the composed task from SCDF it fails to launch the composed-task-runner with following error:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration': Unsatisfied dependency expressed through field 'dataSources'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.driver.OracleDriver
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar!/:1.5.8.RELEASE]
at org.springframework.cloud.task.app.composedtaskrunner.ComposedtaskrunnerTaskApplication.main(ComposedtaskrunnerTaskApplication.java:29) [classes!/:1.1.0.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_121]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [composedtaskrunner-task-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [composedtaskrunner-task-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [composedtaskrunner-task-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [composedtaskrunner-task-1.1.0.RELEASE.jar:1.1.0.RELEASE]

Even I have tried adding oracle dependency in the spring-cloud-starter-task-composedtaskrunner/pom as we do in case of SCDF to make it work with Oracle but it again gives the same error. Please find the resultant pom file below:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-cloud-starter-task-composedtaskrunner</artifactId>
<packaging>jar</packaging>
<name>Spring Cloud Starter Task Composed Task Runner</name>
<description>Contains the app for the Composed Task Starter</description>

<parent>
    <groupId>org.springframework.cloud.task.app</groupId>
    <artifactId>composedtaskrunner-task-app-starters-build</artifactId>
    <version>1.1.0.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-task</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-batch</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dataflow-rest-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dataflow-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-app-starter-doc-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.springframework.cloud.stream.app.plugin</groupId>
            <artifactId>spring-cloud-stream-app-maven-plugin</artifactId>
            <configuration>
                <generatedProjectHome>${session.executionRootDirectory}/apps</generatedProjectHome>
                <generatedProjectVersion>${project.version}</generatedProjectVersion>
                <bom>
                    <name>scs-bom</name>
                    <groupId>org.springframework.cloud.task.app</groupId>
                    <artifactId>composedtaskrunner-task-app-dependencies</artifactId>
                    <version>${project.version}</version>
                </bom>
                <generatedApps>
                    <composedtaskrunner-task>
                        <autoConfigClass>org.springframework.cloud.task.app.composedtaskrunner.ComposedTaskRunnerConfiguration.class</autoConfigClass>
                    </composedtaskrunner-task>
                </generatedApps>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

Can anyone help me understand what I have missed or need to add to make it work.

Thanks

1

1 Answers

1
votes

Not clear how you attempted to add the Oracle-driver from the post description/pom. Without that in the classpath, it will fail with driver-not-found errors.

We have a patching procedure for the Apps. Like stream-apps, you'd download composed-task-runner, adjust the pom.xml with your proprietary Oracle-driver dependency, and finally adjust @Import with ComposedRunnerVisitorConfiguration.

With that you'd be able to build the App - verify the uber-jar to confirm the Oracle-driver is in the classpath. You can also locally run the App (java -jar ..) to make sure it starts and connects to the desired Oracle DB. If it runs standalone, it will run when orchestrated from SCDF, too.

One other thing. Please make sure the datasource configurations are same between CTR, SCDF and the Tasks included in the CTR-graph. Unless they share the same datasource, you won't be able to visualize the executions in SCDF Dashboard - see docs here.