docker中部署工作流项目的问题!

来源:10-14 部署工作流项目

huoqiang

2021-12-25

启动jar包后连接不上数据库

  • 我的数据库在linux里安装的。在本地可以正常连接。
    图片描述
  • 启动emos-workflow项目后,就报错。信息如下:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
01:33:00  ERROR  Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'quartzScheduler'; nested exception is org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Unknown error 1146 [See nested exception: java.sql.SQLSyntaxErrorException: Unknown error 1146]]
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
	at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:940)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
	at com.example.emos.workflow.EmosApplication.main(s:68)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Unknown error 1146 [See nested exception: java.sql.SQLSyntaxErrorException: Unknown error 1146]]
	at org.springframework.scheduling.quartz.SchedulerFactoryBean.start(SchedulerFactoryBean.java:803)
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
	... 23 common frames omitted
Caused by: org.quartz.SchedulerConfigException: Failure occured during job recovery.
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:697)
	at org.quartz.core.QuartzScheduler.start(QuartzScheduler.java:539)
	at org.quartz.impl.StdScheduler.start(StdScheduler.java:142)
	at org.springframework.scheduling.quartz.SchedulerFactoryBean.startScheduler(SchedulerFactoryBean.java:728)
	at org.springframework.scheduling.quartz.SchedulerFactoryBean.start(SchedulerFactoryBean.java:800)
	... 24 common frames omitted
Caused by: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Unknown error 1146
	at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:184)
	at org.quartz.impl.jdbcjobstore.DBSemaphore.obtainLock(DBSemaphore.java:113)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3857)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverJobs(JobStoreSupport.java:839)
	at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:695)
	... 28 common frames omitted
Caused by: java.sql.SQLSyntaxErrorException: Unknown error 1146
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1003)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:228)
	at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:123)
	... 32 common frames omitted
  • 我是采用第二种方式启动的项目,启动命令:
nohup java -jar emos-workflow.jar --spring.config.location=/root/workflow/application.yml >> out.log 2>&1 &
  • application.yml内容是:
server:
  tomcat:
    uri-encoding: UTF-8
    threads:
      max: 200
      min-spare: 30
    connection-timeout: 5000ms
  port: 9090
  servlet:
    context-path: /emos-workflow

spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://192.168.3.14:3306/emos?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
      username: root
      password: huoqiang
      initial-size: 4
      max-active: 8
      min-idle: 4
      max-wait: 60000
      test-while-idle: false
      test-on-borrow: true
      test-on-return: false
  redis:
    database: 0
    host: 192.168.3.14
    port: 6379
    jedis:
      pool:
        max-active: 1000
        max-wait: -1ms
        max-idle: 16
        min-idle: 8
  activiti:
    database-schema-update: true
    historyLevel: audit
    db-history-used: true
  quartz:
    job-store-type: jdbc

mybatis:
  mapper-locations: classpath*:mapper/*.xml
  type-aliases-package: com.example.emos.workflow.db.pojo
  configuration:
    map-underscore-to-camel-case: true

logging:
  level:
    root: info
    com.example.demo.workflow.db.dao : warn
  pattern:
    console: "%d{HH:mm:ss}  %-5level  %msg%n"

emos:
  jwt:
    secret: abc123456
    expire: 5
    cache-expire: 10

我试着将地址修改为localhost、172.17.0.1(docker0的地址)、192.168.3.14(linux的地址)都连接不上。

还有就是这里的secret内容需要跟emos-wx-api项目配置文件的一致吗?

emos:
  jwt:
    secret: abc123456
    expire: 5
    cache-expire: 10
写回答

1回答

神思者

2021-12-25

因为你自己的MySQL区分表名大小写,这个是不行的,Quartz会报错。用课程附带的MySQL,或者用手册上的办法,在Docker中安装MySQL

0
2
huoqiang
已经解决了!修改了一下数据库的配置。
2021-12-25
共2条回复

SpringBoot 在线协同办公小程序开发 全栈式项目实战

未来趋势型业务 + 前后端综合技术栈 + 惊艳的细节打磨

1798 学习 · 1915 问题

查看课程