使用 docker [MySQL] 运行 keycloak 时出错

Posted

技术标签:

【中文标题】使用 docker [MySQL] 运行 keycloak 时出错【英文标题】:Error while running keycloak with docker [MySQL] 【发布时间】:2021-10-03 23:20:36 【问题描述】:

我已使用以下命令运行我的项目。

mvn 全新安装

我已经使用以下命令创建了一个数据库

创建数据库密钥斗篷;授予 keycloak 上的所有权限。* TO 'keycloak'@'%';

我已经使用下面的命令创建了一个 docker 镜像并创建了一个镜像。

docker build -t keycloak.

当我使用 Docker 运行时,

docker run -p 8080:8080 -e DB_VENDOR=mysql -e DB_ADDR=192.168.1.15 -e DB_PORT=3306 -e DB_USER=keycloak -e DB_PASSWORD=keycloak -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e JDBC_PARAMS ="useSSL=false&allowPublicKeyRetrieval=true" -e JAVA_OPTS="-Djboss.as.management.blocking.timeout=900" -e KEYCLOAK_LOGLEVEL=DEBUG -v /Users/test:/opt/jboss/test keycloak

表是在 keycloak 数据库中创建的,

+------------------------------+
| Tables_in_keycloak           |
+------------------------------+
| client                       |
| client_attributes            |
| client_default_roles         |
| client_identity_prov_mapping |
| client_node_registrations    |
| client_session               |
| client_session_note          |
| client_session_prot_mapper   |
| client_session_role          |
| composite_role               |
| credential                   |
| databasechangelog            |
| databasechangeloglock        |
| event_entity                 |
| fed_providers                |
| federated_identity           |
| identity_provider            |
| identity_provider_config     |
| identity_provider_mapper     |
| idp_mapper_config            |
| keycloak_role                |
| migration_model              |
| protocol_mapper              |
| protocol_mapper_config       |
| realm                        |
| realm_attribute              |
| realm_client                 |
| realm_default_roles          |
| realm_enabled_event_types    |
| realm_events_listeners       |
| realm_required_credential    |
| realm_smtp_config            |
| realm_supported_locales      |
| redirect_uris                |
| scope_mapping                |
| user_attribute               |
| user_consent                 |
| user_consent_prot_mapper     |
| user_consent_role            |
| user_entity                  |
| user_federation_config       |
| user_federation_provider     |
| user_required_action         |
| user_role_mapping            |
| user_session                 |
| user_session_note            |
| username_login_failure       |
| web_origins                  |
+------------------------------+
48 rows in set (0.03 sec).

但是一旦创建表就会抛出一个错误,

07:20:34,849 ERROR [org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider] (ServerService Thread Pool -- 60) Error has occurred while updating the database: liquibase.exception.MigrationFailedException: Migration failed for change set META-INF/jpa-changelog-br@redhat.com:
     Reason: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_ROLLEDBACK
        at org.liquibase//liquibase.changelog.ChangeSet.execute(ChangeSet.java:607)
        at org.liquibase//liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
        at org.liquibase//liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:79)
        at org.liquibase//liquibase.Liquibase.update(Liquibase.java:214)
        at org.liquibase//liquibase.Liquibase.update(Liquibase.java:192)
        at org.liquibase//liquibase.Liquibase.update(Liquibase.java:188)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.updateChangeSet(LiquibaseJpaUpdaterProvider.java:183)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:102)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:81)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory$2.run(DefaultJpaConnectionProviderFactory.java:341)
        at org.keycloak.keycloak-server-spi-private@12.0.4//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:228)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.update(DefaultJpaConnectionProviderFactory.java:334)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.migration(DefaultJpaConnectionProviderFactory.java:306)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lambda$lazyInit$0(DefaultJpaConnectionProviderFactory.java:182)
        at org.keycloak.keycloak-server-spi-private@12.0.4//org.keycloak.models.utils.KeycloakModelUtils.suspendJtaTransaction(KeycloakModelUtils.java:654)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lazyInit(DefaultJpaConnectionProviderFactory.java:133)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:81)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:59)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:274)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:51)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:33)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:274)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.DefaultKeycloakSession.realmLocalStorage(DefaultKeycloakSession.java:199)
        at org.keycloak.keycloak-model-infinispan@12.0.4//org.keycloak.models.cache.infinispan.RealmCacheSession.getRealmDelegate(RealmCacheSession.java:152)
        at org.keycloak.keycloak-model-infinispan@12.0.4//org.keycloak.models.cache.infinispan.RealmCacheSession.getMigrationModel(RealmCacheSession.java:145)
        at org.keycloak.keycloak-server-spi-private@12.0.4//org.keycloak.migration.MigrationModelManager.migrate(MigrationModelManager.java:99)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication.migrateModel(KeycloakApplication.java:234)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication.migrateAndBootstrap(KeycloakApplication.java:175)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:138)
        at org.keycloak.keycloak-server-spi-private@12.0.4//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:228)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:129)
        at org.keycloak.keycloak-wildfly-extensions@12.0.4//org.keycloak.provider.wildfly.WildflyPlatform.onStartup(WildflyPlatform.java:29)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:115)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:152)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2815)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:371)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:283)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:93)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:140)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:42)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:305)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:145)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:588)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:559)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:601)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_ROLLEDBACK
        at org.liquibase//liquibase.database.jvm.JdbcConnection.getURL(JdbcConnection.java:79)
        at org.liquibase//liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:66)
        at org.liquibase//liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:113)
        at org.liquibase//liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1277)
        at org.liquibase//liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1259)
        at org.liquibase//liquibase.changelog.ChangeSet.execute(ChangeSet.java:582)
        ... 68 more
Caused by: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_ROLLEDBACK
        at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrapperDataSource.checkTransactionActive(WrapperDataSource.java:272)
        at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransactionActive(WrappedConnection.java:2007)
        at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.checkStatus(WrappedConnection.java:2022)
        at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:1996)
        at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.getMetaData(WrappedConnection.java:982)
        at org.liquibase//liquibase.database.jvm.JdbcConnection.getURL(JdbcConnection.java:77)
        ... 73 more

07:20:34,852 DEBUG [org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider] (ServerService Thread Pool -- 60) Going to release database lock namespace=DATABASE
07:20:34,852 DEBUG [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (ServerService Thread Pool -- 60) Going to release database lock
07:20:34,856 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (ServerService Thread Pool -- 60) JtaTransactionWrapper rollback
07:20:34,857 WARN  [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 60) ARJUNA012077: Abort called on already aborted atomic action 0:ffffac110002:781bf3d1:6102558b:16
07:20:34,857 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (ServerService Thread Pool -- 60) JtaTransactionWrapper end
07:20:34,861 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (ServerService Thread Pool -- 60) JtaTransactionWrapper rollback
07:20:34,861 WARN  [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 60) ARJUNA012077: Abort called on already aborted atomic action 0:ffffac110002:781bf3d1:6102558b:11
07:20:34,861 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (ServerService Thread Pool -- 60) JtaTransactionWrapper end
07:20:34,861 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (ServerService Thread Pool -- 60) JtaTransactionWrapper resuming suspended
07:20:34,861 DEBUG [org.keycloak.connections.jpa.updater.liquibase.lock.LiquibaseDBLockProvider] (ServerService Thread Pool -- 60) Going to release database lock namespace=KEYCLOAK_BOOT
07:20:34,862 DEBUG [org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockService] (ServerService Thread Pool -- 60) Going to release database lock
07:20:34,867 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (ServerService Thread Pool -- 60) JtaTransactionWrapper rollback
07:20:34,867 WARN  [com.arjuna.ats.arjuna] (ServerService Thread Pool -- 60) ARJUNA012077: Abort called on already aborted atomic action 0:ffffac110002:781bf3d1:6102558b:e
07:20:34,867 DEBUG [org.keycloak.transaction.JtaTransactionWrapper] (ServerService Thread Pool -- 60) JtaTransactionWrapper end
07:20:34,868 FATAL [org.keycloak.services] (ServerService Thread Pool -- 60) Error during startup: java.lang.RuntimeException: Failed to update database
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:117)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:81)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory$2.run(DefaultJpaConnectionProviderFactory.java:341)
        at org.keycloak.keycloak-server-spi-private@12.0.4//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:228)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.update(DefaultJpaConnectionProviderFactory.java:334)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.migration(DefaultJpaConnectionProviderFactory.java:306)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lambda$lazyInit$0(DefaultJpaConnectionProviderFactory.java:182)
        at org.keycloak.keycloak-server-spi-private@12.0.4//org.keycloak.models.utils.KeycloakModelUtils.suspendJtaTransaction(KeycloakModelUtils.java:654)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.lazyInit(DefaultJpaConnectionProviderFactory.java:133)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:81)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory.create(DefaultJpaConnectionProviderFactory.java:59)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:274)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:51)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.models.jpa.JpaRealmProviderFactory.create(JpaRealmProviderFactory.java:33)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:274)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.DefaultKeycloakSession.realmLocalStorage(DefaultKeycloakSession.java:199)
        at org.keycloak.keycloak-model-infinispan@12.0.4//org.keycloak.models.cache.infinispan.RealmCacheSession.getRealmDelegate(RealmCacheSession.java:152)
        at org.keycloak.keycloak-model-infinispan@12.0.4//org.keycloak.models.cache.infinispan.RealmCacheSession.getMigrationModel(RealmCacheSession.java:145)
        at org.keycloak.keycloak-server-spi-private@12.0.4//org.keycloak.migration.MigrationModelManager.migrate(MigrationModelManager.java:99)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication.migrateModel(KeycloakApplication.java:234)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication.migrateAndBootstrap(KeycloakApplication.java:175)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication$1.run(KeycloakApplication.java:138)
        at org.keycloak.keycloak-server-spi-private@12.0.4//org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:228)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication.startup(KeycloakApplication.java:129)
        at org.keycloak.keycloak-wildfly-extensions@12.0.4//org.keycloak.provider.wildfly.WildflyPlatform.onStartup(WildflyPlatform.java:29)
        at org.keycloak.keycloak-services@12.0.4//org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:115)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:152)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2815)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:371)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:283)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:93)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:140)
        at org.jboss.resteasy.resteasy-jaxrs@3.13.2.Final//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:42)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:305)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:145)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:588)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:559)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
        at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:601)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97)
        at org.wildfly.extension.undertow@21.0.2.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at
org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set META-INF/jpa-changelog-bb@redhat.com:
     Reason: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_ROLLEDBACK
        at org.liquibase//liquibase.changelog.ChangeSet.execute(ChangeSet.java:607)
        at org.liquibase//liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
        at org.liquibase//liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:79)
        at org.liquibase//liquibase.Liquibase.update(Liquibase.java:188)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.updateChangeSet(LiquibaseJpaUpdaterProvider.java:183)
        at org.keycloak.keycloak-model-jpa@12.0.4//org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider.update(LiquibaseJpaUpdaterProvider.java:102)
        ... 61 more
Caused by: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_ROLLEDBACK
        at org.liquibase//liquibase.database.jvm.JdbcConnection.getURL(JdbcConnection.java:79)
        at org.liquibase//liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:66)
        at org.liquibase//liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:113)
        at org.liquibase//liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1277)
        at org.liquibase//liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1259)
        at org.liquibase//liquibase.changelog.ChangeSet.execute(ChangeSet.java:582)
        ... 68 more
Caused by: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_ROLLEDBACK
        at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrapperDataSource.checkTransactionActive(WrapperDataSource.java:272)
        at
org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:1996)
        at org.jboss.ironjacamar.jdbcadapters@1.4.23.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.getMetaData(WrappedConnection.java:982)
        at org.liquibase//liquibase.database.jvm.JdbcConnection.getURL(JdbcConnection.java:77)
07:20:35,562 INFO  [org.infinispan.CLUSTER] (ServerService Thread Pool -- 75) ISPN000080: Disconnecting JGroups channel ejb
07:20:35,572 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0028: Stopped deployment keycloak-server.war (runtime-name: keycloak-server.war) in 677ms
07:20:35,620 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("subsystem" => "microprofile-metrics-smallrye")]): java.lang.NullPointerException
        at org.wildfly.extension.microprofile.metrics-smallrye@21.0.2.Final//org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$2.execute(MicroProfileMetricsSubsystemAdd.java:89)
        at org.jboss.as.server@13.0.3.Final//org.jboss.as.server.ServerService.boot(ServerService.java:404)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:416)
        at java.base/java.lang.Thread.run(Thread.java:829)

07:20:35,644 ERROR [org.jboss.as.server] (ServerService Thread Pool -- 46) WFLYSRV0022: Deploy of deployment "keycloak-server.war" was rolled back with no failure message
07:20:35,688 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0050: Keycloak 12.0.4 (WildFly Core 13.0.3.Final) stopped in 793ms

【问题讨论】:

哪个 MySQL 版本?所有的表都是innodb吗(看看show create table tablename中的ENGINE?似乎有一个keycloak:14.0版本,因为这同样可能是一个keycloak编码错误。 MySQL 版本为 8.0.25。是的,所有表 ENGINE 都是 InnoDB。 您是从现有的 Keycloak 数据库升级吗? 不,我不是从现有的 Keycloak 数据库升级 可能在之前尝试启动 keycloak 容器时数据库上仍然存在锁定。在您的数据库上尝试DROP TABLE databasechangeloglock; 【参考方案1】:

问题是,所有表都没有正确创建。我很好地导入了一个 keycloak 数据库转储,然后运行,它现在工作正常。

【讨论】:

以上是关于使用 docker [MySQL] 运行 keycloak 时出错的主要内容,如果未能解决你的问题,请参考以下文章

使用 docker-compose 运行 MySQL

使用 docker [MySQL] 运行 keycloak 时出错

docker 安装运行mysql

如何使用 Docker-Compose 文件运行 Phpmyadmin、Mysql 和 Apache Tomcat?

MySQL在Docker环境下运行基础

在Docker中运行纸壳CMS并配置使用MySql