Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker启动1.5.1版本提示'io.seata.server.console.service.BranchSessionService' that could not be found #4685

Closed
suinxinliulang opened this issue Jun 13, 2022 · 10 comments

Comments

@suinxinliulang
Copy link

suinxinliulang commented Jun 13, 2022

  • [ x ] I have searched the issues of this repository and believe that this is not a duplicate.

Ⅰ. Issue Description

docker 启动1.5.1版本seata,启动后提示
A component required a bean of type 'io.seata.server.console.service.BranchSessionService' that could not be found.

Ⅱ. Describe what happened

使用docker run之后出现如下错误:

启动命令:

docker run --name seata-server \
        -p 8091:8091 \
        -p 7091:7091 \
        -v /home/ubuntu/seata/:/seata-server/resources  \
        seataio/seata-server

报错提示:

seata-server            | ***************************
seata-server            | APPLICATION FAILED TO START
seata-server            | ***************************
seata-server            | 
seata-server            | Description:
seata-server            | 
seata-server            | A component required a bean of type 'io.seata.server.console.service.BranchSessionService' that could not be found.
seata-server            | 
seata-server            | 
seata-server            | Action:
seata-server            | 
seata-server            | Consider defining a bean of type 'io.seata.server.console.service.BranchSessionService' in your configuration.
seata-server            | 
seata-server exited with code 1

Ⅲ. Describe what you expected to happen

Seata能够正常启动

Ⅳ. How to reproduce it (as minimally and precisely as possible)

  1. 将官网中指定的seataServer.properties发布到nacos中,主要修改如下:

    store.mode=db
    store.lock.mode=db
    store.session.mode=db
    
    store.db.datasource=druid
    store.db.dbType=mysql
    store.db.driverClassName=com.mysql.cj.jdbc.Driver
    store.db.url=jdbc:mysql://xxxxxxx:3306/seata?useUnicode=true&rewriteBatchedStatements=true
    store.db.user=root
    store.db.password=root
  2. 修改application.yml

    server:
      port: 8091
    
    spring:
      application:
        name: seata-server
    
    logging:
      # config: classpath:logback-spring.xml
      file:
        path: ${user.home}/logs/seata
      # extend:
      #   logstash-appender:
      #     destination: 127.0.0.1:4560
      #   kafka-appender:
      #     bootstrap-servers: 127.0.0.1:9092
      #     topic: logback_to_logstash
    
    console:
      user:
        username: seata
        password: seata
    
    seata:
      config:
        # support: nacos 、 consul 、 apollo 、 zk  、 etcd3
        type: nacos
        nacos:
          server-addr: nacos:8848
          namespace: dev
          group: SEATA_GROUP
          username: nacos
          password: nacos
          ##if use MSE Nacos with auth, mutex with username/password attribute
          #access-key: ""
          #secret-key: ""
          data-id: seataServer.properties
      registry:
        # support: nacos, eureka, redis, zk, consul, etcd3, sofa
        type: nacos
        nacos:
          application: seata-server
          server-addr: nacos:8848
          group: SEATA_GROUP
          namespace: dev
          cluster: default
          username: nacos
          password: nacos
          ##if use MSE Nacos with auth, mutex with username/password attribute
          #access-key: ""
          #secret-key: ""
    #  server:
    #    service-port: 8091 #If not configured, the default is '${server.port} + 1000'
      security:
        secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
        tokenValidityInMilliseconds: 1800000
        ignore:
          urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login
  3. 使用docker run启动容器

    docker run --name seata-server \
         -p 8091:8091 \
         -p 7091:7091 \
         -v /home/ubuntu/seata/:/seata-server/resources  \
         seataio/seata-server

Ⅴ. Anything else we need to know?

None

Ⅵ. Environment:

  • JDK version: openjdk 11.0.15 2022-04-19
  • Seata version: 15.1
  • OS : ubuntu-server22.04LTS
  • Others:
@funky-eyes
Copy link
Contributor

应该是目录映射有问题,自行进入容器的resources目录下看下application.yml是否存在

@suinxinliulang
Copy link
Author

应该是目录映射有问题,自行进入容器的resources目录下看下application.yml是否存在

有的

docker exec -it faafa7153cc0 sh
/seata-server # cd resources/
/seata-server/resources # ls
application.yml

@funky-eyes
Copy link
Contributor

那就检查nacos的配置,可能是namespace的问题,namespace需要填写的是id,而不是name

@funky-eyes
Copy link
Contributor

建议先不要把type改成nacos,先试着file能不能跑起来

@suinxinliulang
Copy link
Author

suinxinliulang commented Jun 14, 2022

建议先不要把type改成nacos,先试着file能不能跑起来

不引用任何外部配置文件直接启动是可以的,我直接把容器里的resources目录复制出来了,然后改了下registry配置和config。但是目前会有mysql8驱动报错。

Caused by: java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:677)

并且如果我删除复制出来的非配置文件内容,又会出现缺少BranchSessionService的问题。

复制出来的文件列表:

fan@k3s-master:~/seata/config$ tree .
.
├── application.example.yml
├── application.yml
├── banner.txt
├── io
│   └── seata
│       └── server
│           ├── auth
│           ├── console
│           │   ├── controller
│           │   ├── impl
│           │   │   ├── db
│           │   │   ├── file
│           │   │   └── redis
│           │   ├── param
│           │   ├── service
│           │   └── vo
│           ├── controller
│           ├── coordinator
│           ├── env
│           ├── event
│           ├── lock
│           │   └── distributed
│           ├── logging
│           │   ├── listener
│           │   └── logback
│           │       └── appender
│           ├── metrics
│           ├── session
│           ├── storage
│           │   ├── db
│           │   │   ├── lock
│           │   │   ├── session
│           │   │   └── store
│           │   ├── file
│           │   │   ├── lock
│           │   │   ├── session
│           │   │   └── store
│           │   └── redis
│           │       ├── lock
│           │       ├── session
│           │       └── store
│           ├── store
│           ├── test
│           └── transaction
│               ├── at
│               ├── saga
│               ├── tcc
│               └── xa
├── logback
│   ├── console-appender.xml
│   ├── file-appender.xml
│   ├── kafka-appender.xml
│   └── logstash-appender.xml
├── logback-spring.xml
├── lua
│   └── redislocker
│       └── redislock.lua
├── META-INF
│   ├── services
│   │   ├── io.seata.core.rpc.RegisterCheckAuthHandler
│   │   ├── io.seata.core.store.db.DataSourceProvider
│   │   ├── io.seata.core.store.DistributedLocker
│   │   ├── io.seata.server.coordinator.AbstractCore
│   │   ├── io.seata.server.lock.LockManager
│   │   └── io.seata.server.session.SessionManager
│   ├── spring-configuration-metadata.json
│   └── spring.factories
├── README.md
└── README-zh.md

@funky-eyes
Copy link
Contributor

driverclassname改为 com.mysql.jdbc.Driver 先用下,至于你说的删除我不知道你删了哪些内容,理论上有application.yml即可

@kaze985
Copy link

kaze985 commented Jun 28, 2022

检查一下nacos的配置,我是粗心把store.mode=nacos才出现的这个错误,改成db就可以正常启动了

@Mo7Laviiin
Copy link

Mo7Laviiin commented Feb 15, 2023

你的目录挂载,-v /home/ubuntu/seata/:/seata-server/resources,宿主机目录会覆盖镜像中的目录。
直接将application.yml配置文件放在seata目录下,然后改成单文件挂载:
-v /home/ubuntu/seata/application.yml:/seata-server/resources/application.yml

@StarSky1
Copy link

你的目录挂载,-v /home/ubuntu/seata/:/seata-server/resources,宿主机目录会覆盖镜像中的目录。 直接将application.yml配置文件放在seata目录下,然后改成单文件挂载: -v /home/ubuntu/seata/application.yml:/seata-server/resources/application.yml

我也遇到这个问题,通过这个方法解决了

@greatboyzhx
Copy link

你的目录挂载,-v /home/ubuntu/seata/:/seata-server/resources,宿主机目录会覆盖镜像中的目录。 直接将application.yml配置文件放在seata目录下,然后改成单文件挂载: -v /home/ubuntu/seata/application.yml:/seata-server/resources/application.yml

解决了我的问题!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants