使用 Oracle 数据库的 spring 云数据流中的组合任务问题

Issue with Composed task in spring cloud data flow with oracle database

我们正在尝试使用 Oracle 数据库执行来自 spring 云数据流 (1.2.3.RELEASE) 的组合任务,以存储 task/jobs 的状态。当我 运行 单个任务或工作时,它 运行 很顺利,没有任何错误。 为了 运行 文档中指定的组合任务,我已经将 composed-task-运行ner(1.1.0.RELEASE) 注册为 SCDF 中的应用程序。但是当我从 SCDF 启动组合任务时,它无法启动组合任务-运行ner 并出现以下错误:

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.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]

我什至尝试在 spring-cloud-starter-task-composedtaskrunner/pom 中添加 oracle 依赖项,就像我们在 SCDF 中所做的那样,以使其与 Oracle 一起工作,但它再次给出相同的错误。请在下面找到生成的 pom 文件:

<?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>

任何人都可以帮助我了解我遗漏或需要添加的内容以使其正常工作。

谢谢

不清楚您是如何尝试从 post description/pom 添加 Oracle 驱动程序的。如果类路径中没有它,它将因未找到驱动程序错误而失败。

我们有应用程序的修补程序。喜欢stream-apps, you'd download composed-task-runner, adjust the pom.xml with your proprietary Oracle-driver dependency, and finally adjust @Import with ComposedRunnerVisitorConfiguration

这样您就可以 build the App - 验证 uber-jar 以确认 Oracle 驱动程序在类路径中。您还可以在本地 运行 应用程序 (java -jar ..) 以确保它启动并连接到所需的 Oracle 数据库。如果它 运行 是独立的,那么当从 SCDF 编排时它也会 运行。

还有一件事。请确保 CTR、SCDF 和 CTR 图中包含的任务之间的 datasource 配置相同。除非他们共享相同的数据源,否则您将无法在 SCDF 仪表板中可视化执行情况 - 请参阅文档 here.