Как правильно скомпилировать / упаковать задачу для Spring Cloud Data Flow - PullRequest
0 голосов
/ 14 июля 2020

Я скомпилировал следующий пример в IntelliJ Idea 2020.1.3 из примеров Spring Cloud Task, учитывая, что мне нужно использовать несколько источников данных: https://github.com/mminella/spring-cloud-task/tree/master/spring-cloud-task-samples/multiple-datasources

Затем я упаковал его в JAR с использованием mvn package, скопировал его в то место, где я запустил docker -compose (согласно официальным инструкциям SCDF (Spring Cloud Data Flow) для локального развертывания) и добавил его в SCDF, выполнив следующую команду внутри оболочки SCDF: app register --type task --name multiple-datasources --uri file://root/scdf/multiple-datasources-2.3.0-SNAPSHOT.jar.

Я добавил задачу с помощью SCDF, как показано:

Creating the multiple-datasources task in SCDF 1/2

Creating the multiple-datasources task in SCDF 2/2

When I try to run the task from the dashboard, the execution instance does not mention any start-time or end-time. Nor does it show any in the dashboard.

Consulting the log from the SCDF shell by using task execution log , many errors are shown. This seems like the most relevant part:

2020-07-14 02:38:14.403  INFO 63 --- [           main] i.spring.MultipleDataSourcesApplication  : Starting MultipleDataSourcesApplication v2.3.0-SNAPSHOT on 5856acfa7c62 with PID 63 (/root/scdf/multiple-datasources-2.3.0-SNAPSHOT.jar started by root in /tmp/289541567048/multiple-datasources-9c75a131-4ea9-40ff-ac42-44729162e6f5)
2020-07-14 02:38:14.407  INFO 63 --- [           main] i.spring.MultipleDataSourcesApplication  : No active profile set, falling back to default profiles: default
2020-07-14 02:38:17.242  INFO 63 --- [           main] o.s.j.d.e.EmbeddedDatabaseFactory        : Starting embedded database: url='jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa'
2020-07-14 02:38:18.145  INFO 63 --- [           main] o.s.j.d.e.EmbeddedDatabaseFactory        : Starting embedded database: url='jdbc:hsqldb:mem:testdb', username='sa'
2020-07-14 02:38:18.810 DEBUG 63 --- [           main] o.s.c.t.c.SimpleTaskAutoConfiguration    : Using io.spring.configuration.CustomTaskConfigurer TaskConfigurer
2020-07-14 02:38:18.823 DEBUG 63 --- [           main] o.s.c.t.c.DefaultTaskConfigurer          : No EntityManager was found, using DataSourceTransactionManager
2020-07-14 02:38:18.928 DEBUG 63 --- [           main] o.s.c.t.r.s.TaskRepositoryInitializer    : Initializing task schema for h2 database
2020-07-14 02:38:19.036 ERROR 63 --- [           main] o.s.c.t.listener.TaskLifecycleListener   : An event to end a task has been received for a task that has not yet started.
2020-07-14 02:38:19.036  WARN 63 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'taskLifecycleListener'; nested exception is java.lang.IllegalArgumentException: Invalid TaskExecution, ID 31 not found
2020-07-14 02:38:19.036  INFO 63 --- [           main] o.s.j.d.e.EmbeddedDatabaseFactory        : Shutting down embedded database: url='jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false'
2020-07-14 02:38:19.245  INFO 63 --- [           main] o.s.j.d.e.EmbeddedDatabaseFactory        : Shutting down embedded database: url='jdbc:hsqldb:mem:testdb'
2020-07-14 02:38:19.258 ERROR 63 --- [           main] o.s.c.t.listener.TaskLifecycleListener   : An event to end a task has been received for a task that has not yet started.
2020-07-14 02:38:19.264  INFO 63 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-14 02:38:19.273 ERROR 63 --- [           main] o.s.boot.SpringApplication               : Application run failed

The following errors in particular stand out to me:

2020-07-14 02:38:19.036  WARN 63 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'taskLifecycleListener'; nested exception is java.lang.IllegalArgumentException: Invalid TaskExecution, ID 31 not found
2020-07-14 02:38:19.258 ERROR 63 --- [           main] o.s.c.t.listener.TaskLifecycleListener   : An event to end a task has been received for a task that has not yet started.
2020-07-14 02:38:19.264  INFO 63 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

The example has the following lines in application.properties:

spring.application.name=Demo Multiple DataSources Task
logging.level.org.springframework.cloud.task=DEBUG`

so if I'm not mistaken, debug should already be enabled.

Concretely my questions are:

1) What might I be overlooking or doing wrong, given that this is an example and it's not running even without modifications?

2) What can I do to properly enable DEBUG?

Thank you

PS: The example from the repo already has the H2 database dependency shown as the answer in Регистрация пользовательской задачи Spring Cloud с потоком данных Spring Cloud в ее pom. xml.

Я не пытался воссоздать пример с текущим инициализатором загрузки, однако я имел пытался создать простой привет-мир с самым последним инициализатором и я получаю ту же ошибку. Я не думаю, что это ошибка инициализации.

Мне еще предстоит попробовать последнее предложение, отменяющее. Но, учитывая, что это официальный пример, действительно ли мне нужно переопределить конфигурацию по умолчанию?

PPS: Я знаю, что моя установка SCDF работает правильно, потому что я смог запустить предварительно упакованную программу меток времени из пример: https://cloud.spring.io/spring-cloud-task-app-starters/

1 Ответ

0 голосов
/ 14 июля 2020

Похоже, проблема связана с тем, что приложение задачи не использует ту же базу данных, что и Spring Cloud Data Flow. Вы должны убедиться, что

  • Конфигурация источника данных задачи такая же, как и в SCDF
  • Версия зависимости jdb c источника данных в вашем приложении задачи совместима с какой версией SCDF вы используете.

Вы можете прочитать соответствующую документацию здесь

...