Keycloak - 无法启动嵌入式服务器:WFLYEMB0022:无法在嵌入式进程上调用“start”:参数“abstractPath”不能为空

Posted

技术标签:

【中文标题】Keycloak - 无法启动嵌入式服务器:WFLYEMB0022:无法在嵌入式进程上调用“start”:参数“abstractPath”不能为空【英文标题】:Keycloak - cannot start embedded server: WFLYEMB0022: Cannot invoke 'start' on embedded process: Parameter 'abstractPath' must not be empty 【发布时间】:2021-08-26 20:41:02 【问题描述】:

我有一个 Keycloak 实例通过容器注册表在 Heroku PM dyno 上独立运行。最近,此应用程序因以下日志而崩溃。自 5 月 25 日以来,我没有更改代码,此时一切正常。 heroku dyno 没有接近任何限制。我的本地版本很好。因此,我认为一定发生了以下情况之一。

基于独立设置的部署数据的一些损坏 底层镜像-keycloak/11.0.2的变化 我的容器注册表中的损坏的图像正在覆盖内容

我尝试过的调试:

已验证 db 设置是否正确 - 没有问题 已验证数据库上的查询是否按预期工作 - 也很好 重新启动应用程序,部署应用程序,重建映像 - 都是相同的错误消息 使用新映像 12.0.0 重新部署应用 - 相同的错误消息 通过按钮部署了此图像的简单版本 (https://github.com/mieckert/keycloak-heroku) - 这在首次部署时有效,并按预期连接到数据库。但是,当我重新推送并重新发布完全相同的代码时,出现了同样的错误。

接下来我应该尝试什么?

日志:

Jun 09 08:50:28 Release v66 created by user [EMAIL]
Jun 09 08:50:28 Deployed web (c19fbf3aed30) by user [EMAIL]
Jun 09 08:50:39 Starting process with command `-b 0.0.0.0`
Jun 09 08:50:40  Found database configuration in [CORRECT DETAILS WERE HERE]
Jun 09 08:50:43  Added [EMAIL] to '/opt/jboss/keycloak/standalone/configuration/keycloak-add-user.json', restart server to load user
Jun 09 08:50:43  -b 0.0.0.0
Jun 09 08:50:43  =========================================================================
Jun 09 08:50:43    Using PostgreSQL database
Jun 09 08:50:43  =========================================================================
Jun 09 08:50:44  15:50:44,394 INFO  [org.jboss.modules] (CLI command executor) JBoss Modules version 1.10.2.Final
Jun 09 08:50:44  15:50:44,451 INFO  [org.jboss.msc] (CLI command executor) JBoss MSC version 1.4.12.Final
Jun 09 08:50:44  15:50:44,459 INFO  [org.jboss.threads] (CLI command executor) JBoss Threads version 2.4.0.Final
Jun 09 08:50:44  15:50:44,576 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: Keycloak 12.0.0 (WildFly Core 13.0.3.Final) starting
Jun 09 08:50:44  15:50:44,611 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.as: org.jboss.msc.service.StartException in service jboss.as: Failed to start service
Jun 09 08:50:44     at org.jboss.msc@1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1731)
Jun 09 08:50:44     at org.jboss.msc@1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
Jun 09 08:50:44     at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
Jun 09 08:50:44     at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
Jun 09 08:50:44     at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
Jun 09 08:50:44     at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
Jun 09 08:50:44     at java.base/java.lang.Thread.run(Thread.java:834)
Jun 09 08:50:44  Caused by: java.lang.IllegalArgumentException: COM00008: Parameter 'abstractPath' must not be empty
Jun 09 08:50:44     at org.wildfly.common@1.5.4.Final//org.wildfly.common.Assert.checkNotEmptyParam(Assert.java:104)
Jun 09 08:50:44     at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.services.path.AbsolutePathService.convertPath(AbsolutePathService.java:70)
Jun 09 08:50:44     at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.services.path.AbsolutePathService.<init>(AbsolutePathService.java:49)
Jun 09 08:50:44     at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.services.path.AbsolutePathService.addService(AbsolutePathService.java:59)
Jun 09 08:50:44     at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.services.path.AbsolutePathService.addService(AbsolutePathService.java:53)
Jun 09 08:50:44     at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.services.path.PathManagerService.addAbsolutePathService(PathManagerService.java:259)
Jun 09 08:50:44     at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.services.path.PathManagerService.addHardcodedAbsolutePath(PathManagerService.java:160)
Jun 09 08:50:44     at org.jboss.as.server@13.0.3.Final//org.jboss.as.server.ServerPathManagerService.addService(ServerPathManagerService.java:55)
Jun 09 08:50:44     at org.jboss.as.server@13.0.3.Final//org.jboss.as.server.ApplicationServerService.start(ApplicationServerService.java:179)
Jun 09 08:50:44     at org.jboss.msc@1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
Jun 09 08:50:44     at org.jboss.msc@1.4.12.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
Jun 09 08:50:44     ... 6 more
Jun 09 08:50:44  Cannot start embedded server: WFLYEMB0022: Cannot invoke 'start' on embedded process: WFLYSRV0141: Cannot start server: JBTHR00005: Operation failed: Failed to start service: COM00008: Parameter 'abstractPath' must not be empty

我的 docker 入口点文件

 
# Set database config from Heroku DATABASE_URL or HEROKU_POSTGRESQL_ORANGE_URL
if [ "$DATABASE_URL" != "" ]; then
   echo "Found database configuration in DATABASE_URL=$DATABASE_URL"
 
   regex='^postgres://([a-zA-Z0-9_-]+):([a-zA-Z0-9]+)@([a-z0-9.-]+):([[:digit:]]+)/([a-zA-Z0-9_-]+)$'
   if [[ $DATABASE_URL =~ $regex ]]; then
       export DB_ADDR=$BASH_REMATCH[3]
       export DB_PORT=$BASH_REMATCH[4]
       export DB_DATABASE=$BASH_REMATCH[5]
       export DB_USER=$BASH_REMATCH[1]
       export DB_PASSWORD=$BASH_REMATCH[2]
 
       echo "DB_ADDR=$DB_ADDR, DB_PORT=$DB_PORT, DB_DATABASE=$DB_DATABASE, DB_USER=$DB_USER, DB_PASSWORD=$DB_PASSWORD"
       export DB_VENDOR=postgres
   fi
 
fi
 
# usage: file_env VAR [DEFAULT]
#    ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
#  "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
file_env() 
   local var="$1"
   local fileVar="$var_FILE"
   local def="$2:-"
   if [ "$!var:-" ] && [ "$!fileVar:-" ]; then
       echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
       exit 1
   fi
   local val="$def"
   if [ "$!var:-" ]; then
       val="$!var"
   elif [ "$!fileVar:-" ]; then
       val="$(< "$!fileVar")"
   fi
   export "$var"="$val"
   unset "$fileVar"

 
##################
# Add admin user #
##################
 
file_env 'KEYCLOAK_USER'
file_env 'KEYCLOAK_PASSWORD'
 
if [ $KEYCLOAK_USER ] && [ $KEYCLOAK_PASSWORD ]; then
   /opt/jboss/keycloak/bin/add-user-keycloak.sh --user $KEYCLOAK_USER --password $KEYCLOAK_PASSWORD || echo "User already exists."
fi
 
############
# Hostname #
############
 
if [ "$KEYCLOAK_HOSTNAME" != "" ]; then
   SYS_PROPS="-Dkeycloak.hostname.provider=fixed -Dkeycloak.hostname.fixed.hostname=$KEYCLOAK_HOSTNAME"
 
   if [ "$KEYCLOAK_HTTP_PORT" != "" ]; then
       SYS_PROPS+=" -Dkeycloak.hostname.fixed.httpPort=$KEYCLOAK_HTTP_PORT"
   fi
 
   if [ "$KEYCLOAK_HTTPS_PORT" != "" ]; then
       SYS_PROPS+=" -Dkeycloak.hostname.fixed.httpsPort=$KEYCLOAK_HTTPS_PORT"
   fi
fi
 
################
# Realm import #
################
 
if [ "$KEYCLOAK_IMPORT" ]; then
   SYS_PROPS+=" -Dkeycloak.import=$KEYCLOAK_IMPORT"
fi
 
########################
# JGroups bind options #
########################
 
if [ -z "$BIND" ]; then
   BIND=$(hostname -i)
fi
if [ -z "$BIND_OPTS" ]; then
   for BIND_IP in $BIND
   do
       BIND_OPTS+=" -Djboss.bind.address=$BIND_IP -Djboss.bind.address.private=$BIND_IP "
   done
fi
SYS_PROPS+=" $BIND_OPTS"
 
#################
# Configuration #
#################
 
# If the server configuration parameter is not present, append the HA profile.
if echo "$@" | egrep -v -- '-c |-c=|--server-config |--server-config='; then
   SYS_PROPS+=" -c=standalone-ha.xml"
fi
 
############
# DB setup #
############
 
file_env 'DB_USER'
file_env 'DB_PASSWORD'
 
# Lower case DB_VENDOR
DB_VENDOR=`echo $DB_VENDOR | tr A-Z a-z`
 
# Detect DB vendor from default host names
if [ "$DB_VENDOR" == "" ]; then
   if (getent hosts postgres &>/dev/null); then
       export DB_VENDOR="postgres"
   elif (getent hosts mysql &>/dev/null); then
       export DB_VENDOR="mysql"
   elif (getent hosts mariadb &>/dev/null); then
       export DB_VENDOR="mariadb"
   fi
fi
 
# Detect DB vendor from legacy `*_ADDR` environment variables
if [ "$DB_VENDOR" == "" ]; then
   if (printenv | grep '^POSTGRES_ADDR=' &>/dev/null); then
       export DB_VENDOR="postgres"
   elif (printenv | grep '^MYSQL_ADDR=' &>/dev/null); then
       export DB_VENDOR="mysql"
   elif (printenv | grep '^MARIADB_ADDR=' &>/dev/null); then
       export DB_VENDOR="mariadb"
   fi
fi
 
# Default to H2 if DB type not detected
if [ "$DB_VENDOR" == "" ]; then
   export DB_VENDOR="h2"
fi
 
# Set DB name
case "$DB_VENDOR" in
   postgres)
       DB_NAME="PostgreSQL";;
   mysql)
       DB_NAME="MySQL";;
   mariadb)
       DB_NAME="MariaDB";;
   h2)
       DB_NAME="Embedded H2";;
   *)
       echo "Unknown DB vendor $DB_VENDOR"
       exit 1
esac
 
# Append '?' in the beggining of the string if JDBC_PARAMS value isn't empty
export JDBC_PARAMS=$(echo $JDBC_PARAMS | sed '/^$/! s/^/?/')
 
# Convert deprecated DB specific variables
function set_legacy_vars() 
 local suffixes=(ADDR DATABASE USER PASSWORD PORT)
 for suffix in "$suffixes[@]"; do
   local varname="$1_$suffix"
   if [ $!varname ]; then
     echo WARNING: $varname variable name is DEPRECATED replace with DB_$suffix
     export DB_$suffix=$!varname
   fi
 done

set_legacy_vars `echo $DB_VENDOR | tr a-z A-Z`
 
# Configure DB
 
echo "========================================================================="
echo ""
echo "  Using $DB_NAME database"
echo ""
echo "========================================================================="
echo ""
 
if [ "$DB_VENDOR" != "h2" ]; then
   /bin/sh /opt/jboss/tools/databases/change-database.sh $DB_VENDOR
fi
 
/opt/jboss/tools/x509.sh
/opt/jboss/tools/jgroups.sh $JGROUPS_DISCOVERY_PROTOCOL $JGROUPS_DISCOVERY_PROPERTIES
/opt/jboss/tools/autorun.sh
 
##################
# Start Keycloak #
##################
 
exec /opt/jboss/keycloak/bin/standalone.sh $SYS_PROPS $@ -Djboss.http.port=$PORT
exit $?
 

我的 Dockerfile:

 
COPY docker-entrypoint.sh /opt/jboss/tools
 
ENTRYPOINT [ "/opt/jboss/tools/docker-entrypoint.sh" ]
 
CMD ["-b", "0.0.0.0"]
 
RUN mkdir -p /opt/jboss/keycloak/themes/my_theme/
COPY /my_theme/ /opt/jboss/keycloak/themes/my_theme/

【问题讨论】:

很难从该日志中分辨出来,但似乎有东西试图错误地添加路径,或者它可能是空的。 【参考方案1】:

我遇到了同样的问题,并且能够通过设置一个全新的 Keycloak Heroku 应用程序、在那里重新部署我的代码、然后重命名我的应用程序以便从旧应用程序到新应用程序的流量来解决这个问题。如果您需要,我可以提供有关此的详细信息,但这会导致一个新的 Keycloak 服务器(dyno)一旦扩展到 Performance-M 运行与以前完全相同(afaik,Keycloak 配置存储在底层数据库中,所以如果您将您的原始数据库附加到新的 dyno 应用程序,那么您应该没问题)

在过去一周左右的时间里,我遇到了完全相同的问题。我实际上也在运行不同版本的 Keycloak,v10,最初尝试升级到 v13 来解决问题,但没有成功。我认为发生某种损坏是正确的,因为我的实例在第一次故障发生时也没有受到影响。我检查了 Heroku 更改日志中是否有任何会影响我的部署的内容,因为故障似乎是在每日 dyno 重启后发生的,但我没有发现任何东西)

我认为您是正确的,这里存在某种损坏或潜在错误,可能是难以重现的错误,可能与 WildFly 代码、JVM、Keycloak 或与 Heroku 相关的东西

【讨论】:

以上是关于Keycloak - 无法启动嵌入式服务器:WFLYEMB0022:无法在嵌入式进程上调用“start”:参数“abstractPath”不能为空的主要内容,如果未能解决你的问题,请参考以下文章

Spring Boot 的 Keycloak 错误:tomcat 上的“不是子类型”

Keycloak Docker 容器重启后无法启动

Keycloak - docker jboss / keycloak-mysql“表'keycloak.WEB_ORIGINS'不存在”

KeyCloak - Javascript 和 Spring 启动应用程序

如何将 keycloak 安装为服务,使其自动启动?

Spring Boot 我无法切换 keycloak 和基本身份验证