wso2 / product-apim

Welcome to the WSO2 API Manager source code! For info on working with the WSO2 API Manager repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
848 stars 786 forks source link

Error when adding a secondary user store for a tenant for the first time #4774

Closed tgtshanika closed 2 weeks ago

tgtshanika commented 5 years ago

Description:

The following error is logged when adding secondary user store manually for a tenant for the first time.

[2014-08-12 12:28:06,741] INFO - ReadWriteLDAPUserStoreManager LDAP connection created successfully in read-write mode [2014-08-12 12:28:06,783] INFO - ReadWriteLDAPUserStoreManager LDAP connection created successfully in read-write mode [2014-08-12 12:28:06,784] INFO - DeploymentEngine org.apache.axis2.deployment.DeploymentException: The deployment of storetenant1.xml is not valid.

This is not observed when the same .xml file is renamed and copied with a different domain name.

From https://wso2.org/jira/browse/APIMANAGER-2727

dushaniw commented 5 years ago

The issue can be reproduced in the 3.0 milestone pack as well. The issue occurs for the very first secondary user-store getting deployed. Before UserStoreDeploymentManager.deploy() method is called, the DefaultRealm initialize the secondary user store manager with the same domain name and add it to the userstoreManagerHolder map [1]. Afterward, when UserStoreDeploymentManager tries to create a secondary user store manager for the same domain name, it fails with UserStoreException as it tries to initialize a new user store manager with the duplicate domain name [2].

[1] https://github.com/wso2/carbon-kernel/blob/release-4.4.40/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/common/DefaultRealm.java#L274 [2] https://github.com/wso2/carbon-kernel/blob/release-4.4.40/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/common/AbstractUserStoreManager.java#L6286

dushaniw commented 5 years ago

Getting the same exception (when debug logs enabled for org.wso2.carbon.user.core.common.UserStoreDeploymentManager class) when adding the first secondary userstore from management console UI as well.

[2019-06-24 10:42:46,440]  INFO - UserStoreConfigAdminService folder 'userstores' created to store configurations for tenant = 7
[2019-06-24 10:42:48,444]  WARN - FileSystemPreferences Could not lock System prefs. Unix error code 0.
[2019-06-24 10:42:48,445]  WARN - FileSystemPreferences Couldn't flush system prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
[2019-06-24 10:42:53,435]  INFO - ReadWriteLDAPUserStoreManager LDAP connection created successfully in read-write mode
[2019-06-24 10:42:53,447]  INFO - ReadWriteLDAPUserStoreManager LDAP connection created successfully in read-write mode
[2019-06-24 10:42:53,448] DEBUG - UserStoreDeploymentManager The deployment of TEST.xml is not valid.
org.wso2.carbon.user.core.UserStoreException: Could not initialize new user store manager : TEST Duplicate domain names not allowed.
    at org.wso2.carbon.user.core.common.AbstractUserStoreManager.callSecure(AbstractUserStoreManager.java:175)
    at org.wso2.carbon.user.core.common.AbstractUserStoreManager.addSecondaryUserStoreManager(AbstractUserStoreManager.java:6269)
    at org.wso2.carbon.user.core.common.UserStoreDeploymentManager.deploy(UserStoreDeploymentManager.java:68)
    at org.wso2.carbon.identity.user.store.configuration.deployer.UserStoreConfigurationDeployer.deploy(UserStoreConfigurationDeployer.java:169)
    at org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136)
    at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:807)
    at org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144)
    at org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377)
    at org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254)
    at org.apache.axis2.deployment.RepositoryListener.startListener(RepositoryListener.java:371)
    at org.apache.axis2.deployment.scheduler.SchedulerTask.checkRepository(SchedulerTask.java:59)
    at org.apache.axis2.deployment.scheduler.SchedulerTask.run(SchedulerTask.java:67)
    at org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask.runAxisDeployment(CarbonDeploymentSchedulerTask.java:93)
    at org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask.run(CarbonDeploymentSchedulerTask.java:138)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.security.PrivilegedActionException: java.lang.reflect.InvocationTargetException
    at java.security.AccessController.doPrivileged(Native Method)
    at org.wso2.carbon.user.core.common.AbstractUserStoreManager.callSecure(AbstractUserStoreManager.java:165)
    ... 20 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.wso2.carbon.user.core.common.AbstractUserStoreManager$2.run(AbstractUserStoreManager.java:168)
    ... 22 more
Caused by: org.wso2.carbon.user.core.UserStoreException: Could not initialize new user store manager : TEST Duplicate domain names not allowed.
    at org.wso2.carbon.user.core.common.AbstractUserStoreManager.addSecondaryUserStoreManager(AbstractUserStoreManager.java:6292)
    ... 27 more