WSO2 IS - org.wso2.carbon.user.core.UserStoreException: null

WSO2 IS - org.wso2.carbon.user.core.UserStoreException: null

我是 运行 一个包含所有产品的 WSO2 容器(apim-is-as-km-with-analytics),使用 mysql 作为数据库,当docker 撰写开始。我的问题出在 wso2-is 服务器上,它显示以下消息:

[2021-02-26 21:38:17,531] []  INFO {org.wso2.carbon.mex2.internal.DynamicCRMCustomMexComponent} - DynamicCRMSupport MexServiceComponent bundle activated successfully.
 [2021-02-26 21:38:19,923] []  INFO {org.apache.jasper.servlet.TldScanner} - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
 [2021-02-26 21:38:20,098] []  INFO {org.wso2.carbon.identity.authenticator.x509Certificate.internal.X509CertificateServiceComponent} - X509 Certificate Servlet activated successfully..
 [2021-02-26 21:38:23,807] [] ERROR {org.wso2.carbon.user.core.common.DefaultRealm} - nullType class java.lang.reflect.InvocationTargetException org.wso2.carbon.user.core.UserStoreException: nullType class java.lang.reflect.InvocationTargetException
    at org.wso2.carbon.user.core.common.DefaultRealm.createObjectWithOptions(DefaultRealm.java:397)
    at org.wso2.carbon.user.core.common.DefaultRealm.initializeObjects(DefaultRealm.java:224)
    at org.wso2.carbon.user.core.common.DefaultRealm.init(DefaultRealm.java:129)
    at org.wso2.carbon.user.core.common.DefaultRealmService.initializeRealm(DefaultRealmService.java:276)
    at org.wso2.carbon.user.core.common.DefaultRealmService.<init>(DefaultRealmService.java:102)
    at org.wso2.carbon.user.core.common.DefaultRealmService.<init>(DefaultRealmService.java:115)
    at org.wso2.carbon.user.core.internal.Activator.startDeploy(Activator.java:72)
    at org.wso2.carbon.user.core.internal.BundleCheckActivator.start(BundleCheckActivator.java:61)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.run(BundleContextImpl.java:842)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.run(BundleContextImpl.java:1)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:834)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:791)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1013)
    at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:365)
    at org.eclipse.osgi.container.Module.doStart(Module.java:598)
    at org.eclipse.osgi.container.Module.start(Module.java:462)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.run(ModuleContainer.java:1820)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.execute(EquinoxContainerAdaptor.java:150)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1813)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1770)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1735)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1661)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)
 Caused by: java.lang.reflect.InvocationTargetException
    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.wso2.carbon.user.core.common.DefaultRealm.createObjectWithOptions(DefaultRealm.java:351)
    ... 25 more
 Caused by: org.wso2.carbon.user.core.UserStoreException: DB error occurred while persisting domain : PRIMARY & tenant id : -1234
    at org.wso2.carbon.user.core.util.UserCoreUtil.persistDomain(UserCoreUtil.java:871)
    at org.wso2.carbon.user.core.common.AbstractUserStoreManager.persistDomain(AbstractUserStoreManager.java:8595)
    at org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager.<init>(ReadOnlyLDAPUserStoreManager.java:243)
    at org.wso2.carbon.user.core.ldap.UniqueIDReadOnlyLDAPUserStoreManager.<init>(UniqueIDReadOnlyLDAPUserStoreManager.java:148)
    at org.wso2.carbon.user.core.ldap.UniqueIDReadWriteLDAPUserStoreManager.<init>(UniqueIDReadWriteLDAPUserStoreManager.java:122)
    ... 30 more
 Caused by: java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

日志的最后一行显示一条消息

 Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

这很奇怪,因为我已经将 mysql 驱动程序放在 wso2-is 的 Dockerfile 上:

# copy MySQL JDBC connector to server home as a third party library
COPY --chown=wso2carbon:wso2 /binary/mysql-connector-java-8.0.17.jar ${WSO2_SERVER_HOME}/repository/components/dropins/

有人知道我错过了什么吗?

我已经检查了 toml 文件上的所有 jdbc 地址。
wso2am:3.2.0-高山
wso2is:5.10.0-高山
mysql:5.7.33
wso2am-analytics-dashboard:3.2.0-alpine
wso2am-analytics-worker:3.2.0-alpine

我的问题是 mysql 容器。尽管容器的运行状况良好,但尚未准备就绪:

mysql:5.7.33   "docker-entrypoint.s…"   ... Up 5 minutes (healthy)    0.0.0.0:3306->3306/tcp, 33060/tcp

当我尝试使用 workbench 访问时,它显示了消息:

...Error Code: 2013 Lost connection to MySQL server at 'reading initial communication packet', system error: 0  

解法:

我在所有 Dockerfiles(wso2am、wso2is、wso2am-analytics-worker)中添加了一个脚本(wait-for-it)以在启动 wso2 服务器之前检查 mysql 的可用性。

Docker 文件:

# install required packages. Need bash to wait-for-it
RUN apk add --no-cache netcat-openbsd \
        bash

# Add wait-for-it 
COPY --chown=wso2carbon:wso2 wait-for-it.sh ${USER_HOME}/

# initiate container after check if mysql is available and start WSO2 Carbon server
ENTRYPOINT ["/home/wso2carbon/wait-for-it.sh" , "cup-mysql:3306" , "--strict" , \
"--timeout=300" , "--" ,"/home/wso2carbon/docker-entrypoint.sh"]

并且还将所有容器的 start_period 增加到 60 秒以上,因为 mysql 花费 85 秒启动。

docker 容器日志 wso2is:

wait-for-it.sh: waiting 300 seconds for cup-mysql:3306
wait-for-it.sh: cup-mysql:3306 is available after 85 seconds
JAVA_HOME environment variable is set to /opt/java/openjdk
CARBON_HOME environment variable is set to /home/wso2carbon/wso2is-5.10.0

docker-compose.yml:

  mysql:
    container_name: cup-mysql
    image: mysql:5.7.33
    ports:
      - "3306:3306"
    networks:
      - wso2-network
    environment:
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - ./conf/mysql/scripts:/docker-entrypoint-initdb.d
      - ./conf/mysql/conf/my.cnf:/etc/mysql/my.cnf
    ulimits:
      nofile:
        soft: 20000
        hard: 40000
    command: [--ssl=0]
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-uroot", "-proot"]
      interval: 30s
      timeout: 60s
      retries: 5
      start_period: 80s
  is-as-km:
    container_name: cup-is-as-km
    build: ./dockerfiles/is-as-km/closeup
    image: wso2is:5.10.0-alpine
    healthcheck:
      test: ["CMD", "nc", "-z","localhost", "9443"]
      interval: 30s
      start_period: 180s
      retries: 20
    depends_on:
      mysql:
        condition: service_healthy
    volumes:
      - ./conf/is-as-km:/home/wso2carbon/wso2-config-volume
    ports:
      - "9444:9443"
    ....