如何解决通过"schedulerService"字段表示的不满意依赖性? [英] How to resolve Unsatisfied dependency expressed through field 'schedulerService'?

查看:168
本文介绍了如何解决通过"schedulerService"字段表示的不满意依赖性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装自定义的SCDF2.5.1 (添加oracle驱动程序)到openshift中(遵循SCDF的Kubectl安装文档).我修改了deployment.yaml以从git repo中提取我的这个自定义SCDF docker镜像.现在,当我启动容器时,出现以下错误

I'm trying to install a custom built SCDF2.5.1(To add oracle Driver) into openshift (Followed the Kubectl installation doc for SCDF). I modified the deployment.yaml to pull this custom SCDF docker image of mine from git repo. Now when I start the container I get the below error

INFO  org.hibernate.dialect.Dialect.<init> - HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
INFO  org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator.initiateService - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
INFO  org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.buildNativeEntityManagerFactory - Initialized JPA EntityManagerFactory for persistence unit 'default'
INFO  org.springframework.cloud.dataflow.configuration.metadata.ApplicationConfigurationMetadataResolverAutoConfiguration.registryConfigurationMap - Final Registry Configurations: {registry-1.docker.io=RegistryConfiguration{registryHost='registry-1.docker.io', user='null', secret='****'', authorizationType=dockeroauth2, manifestMediaType='application/vnd.docker.distribution.manifest.v2+json', disableSslVerification='false', extra={registryAuthUri=https://auth.docker.io/token?service=registry.docker.io&scope=repository:{repository}:pull&offline_token=1&client_id=shell}}}
WARN  org.springframework.cloud.dataflow.server.config.features.SchedulerConfiguration.primaryTaskPlatform - TaskPlatform Kubernetes is selected as primary but has no TaskLaunchers configured
WARN  org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext.refresh - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.dataflow.server.config.features.TaskConfiguration': Unsatisfied dependency expressed through field 'schedulerService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schedulerService' defined in class path resource [org/springframework/cloud/dataflow/server/config/features/SchedulerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.dataflow.server.service.SchedulerService]: Factory method 'schedulerService' threw exception; nested exception is java.lang.IllegalStateException: No valid primary TaskPlatform configured
INFO  org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.destroy - Closing JPA EntityManagerFactory for persistence unit 'default'
INFO  com.zaxxer.hikari.HikariDataSource.close - HikariPool-1 - Shutdown initiated...
INFO  com.zaxxer.hikari.HikariDataSource.close - HikariPool-1 - Shutdown completed.
INFO  org.apache.catalina.core.StandardService.log - Stopping service [Tomcat]
ERROR 

我看到了与此帖子相关的主题,其中 fix 已提供给spring-cloud-dataflow-server-kubernetes和spring-cloud-dataflow-server-kubernetes-autoconfigure项目.但是我不确定这些更改是否可用于自定义版本2.5.1版本.另外,我检查了我的deployment.yaml,并将切换开关"SPRING_CLOUD_DATAFLOW_FEATURES_SCHEDULES_ENABLED"设置为true.

I saw a thread related to this post where the fix was provided to spring-cloud-dataflow-server-kubernetes and spring-cloud-dataflow-server-kubernetes-autoconfigure project. But I'm not sure whether thsose changes are available for the custom build 2.5.1 Release. Also I checked my deployment.yaml and the toggle "SPRING_CLOUD_DATAFLOW_FEATURES_SCHEDULES_ENABLED" was set to true.

在deployment.yaml中,我删除了数据库服务&配置,也删除了scdf-server配置,因为我在构建docker映像本身时在application.properties中添加了驱动程序属性.以下是scdf jar中内置的deployment.yaml和application.properties文件.仅供参考,从Deployment.yaml中删除scdf-server配置对故障没有影响.上面的例外保持不变.还删除了船长URI.

In deployment.yaml I have removed database service & config, removed the scdf-server config as well, as I added the driver properties in application.properties while building the docker image itself. Below are the deployment.yaml and application.properties file which built into the scdf jar. FYI, removing the scdf-server config from deployment.yaml has no effect on the the failure. The above exception remains same. Also removed the skipper URI.

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: customscdf-image
  labels:
    app: customscdf-image
spec:
  selector:
    matchLabels:
      app: customscdf-image
  replicas: 1
  template:
    metadata:
      labels:
        app: customscdf-image
    spec:
      containers:
      - name: customscdf-image
        image: docker-registry.default.svc:5000/scdfadmin/customscdf-image
        imagePullPolicy: Always
        ports:
        - containerPort: 80
        livenessProbe:
          httpGet:
            path: /management/health
            port: 80
          initialDelaySeconds: 45
        readinessProbe:
          httpGet:
            path: /management/info
            port: 80
          initialDelaySeconds: 45
        resources:
          limits:
            cpu: 1.0
            memory: 2048Mi
          requests:
            cpu: 0.5
            memory: 1024Mi
        env:
        - name: KUBERNETES_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: "metadata.namespace"
        - name: SERVER_PORT
          value: '80'
        - name: SPRING_CLOUD_CONFIG_ENABLED
          value: 'false'
        - name: SPRING_CLOUD_DATAFLOW_FEATURES_ANALYTICS_ENABLED
          value: 'true'
        - name: SPRING_CLOUD_DATAFLOW_FEATURES_SCHEDULES_ENABLED
          value: 'true'
        - name: SPRING_CLOUD_DATAFLOW_TASK_COMPOSED_TASK_RUNNER_URI
          value: 'docker://springcloud/spring-cloud-dataflow-composed-task-runner:2.6.0.BUILD-SNAPSHOT'
        - name: SPRING_CLOUD_KUBERNETES_CONFIG_ENABLE_API
          value: 'false'
        - name: SPRING_CLOUD_KUBERNETES_SECRETS_ENABLE_API
          value: 'false'
        - name: SPRING_CLOUD_KUBERNETES_SECRETS_PATHS
          value: /etc/secrets
        - name: SPRING_CLOUD_DATAFLOW_SERVER_URI
          value: '${HOST_NAME}:9393'
          # Add Maven repo for metadata artifact resolution for all stream apps
        - name: SPRING_APPLICATION_JSON
          value: "{ \"maven\": { \"local-repository\": null, \"remote-repositories\": { \"repo1\": { \"url\": \"https://repo.spring.io/libs-snapshot\"} } } }"
      serviceAccountName: scdf-sa

application.properties

spring.application.name=CUSTOMSCDF
spring.datasource.url=DATASOURCE_URL_FOR_ORACLE_DB
spring.datasource.username=user_name
spring.datasource.password=PASSWORD
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

spring.flyway.enabled=false

spring.jpa.show-sql=true
spring.jpa.hibernate.use-new-id-generator-mappings=true

logging.level.root=info
logging.file.max-size=5GB
logging.file.max-history=30 
logging.pattern.console=%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger.%M - %msg%n

Dockerfile -将作为上面使用的customcdf-image构建

Dockerfile - Which will be built as customscdf-image used above

FROM maven:3.5.2-jdk-8-alpine AS MAVEN_BUILD

COPY pom.xml /build/
COPY src /build/src/

WORKDIR /build/
RUN mvn package

FROM openjdk:8-jre-alpine

WORKDIR /app
COPY --from=MAVEN_BUILD /build/target/custom-0.0.1-SNAPSHOT.jar /app/

ENTRYPOINT ["java", "-jar", "custom-0.0.1-SNAPSHOT.jar"]

那么我在这里做错了什么或想念什么?请指教.

So what am I doing wrong or missing here? Please advice.

谢谢.

推荐答案

由于某些原因,此自定义版本无法读取server-config.yaml.即使它在server-deployment.yaml中显示为配置映射之一.因此,我将kubenetes任务平台属性移到了CustomBuild SCDF Spring引导项目的application.properties中.因此,我从该项目构建的docker映像也具有kubernetes属性.添加此文件后,server-deployment.yaml能够获取k8平台属性,并且SCDF开始成功运行.

This custom build doesn't read the server-config.yaml for some reason. Even if its shown in the server-deployment.yaml as one of the config-maps. So I moved the kubenetes task platform properties to application.properties of the CustomBuild SCDF Spring boot project. So the docker image I built from this project the kubernetes properties as well. After adding this the server-deployment.yaml able to get the k8 platform properties and SCDF started running successfully.

我的application.properties当前如下所示.

My application.properties currently looks like below.

spring.application.name=CustomSCDF
spring.datasource.url=jdbc:oracle:thin:@datasource_url
spring.datasource.username=username
spring.datasource.password=Password
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

#properties moved from server-config.yaml
spring.cloud.dataflow.task.platform.kubernetes.accounts.default.image-pull-policy= always
spring.cloud.dataflow.task.platform.kubernetes.accounts.default.entry-point-style= exec
spring.cloud.dataflow.task.platform.kubernetes.accounts.default.limits.cpu=4

我认为只有定制的应用程序会遇到此问题.但这需要更加清楚.

I think only the custom built application will face this issue. But this needs more clarity.

这篇关于如何解决通过"schedulerService"字段表示的不满意依赖性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆