2
votes

I'm trying to change the carbon H2 database (for this test) for a MariaDB system. Once my master-datasources.xml and my databases created and configured thanks to the provided scripts, I start the API Manager but it fails with the following error :

ERROR - Activator Cannot start User Manager Core bundle
June 1st 2018, 14:51:07.000 org.wso2.carbon.user.core.UserStoreException: Cannot initialize the realm.
Caused by: org.wso2.carbon.user.core.UserStoreException: nullType class java.lang.reflect.InvocationTargetException
June 1st 2018, 14:51:07.000 Caused by: org.wso2.carbon.user.core.UserStoreException: nullType class java.lang.reflect.InvocationTargetException
Caused by: org.wso2.carbon.user.core.UserStoreException: Error occurred while checking is existing domain : PRIMARY for tenant : -123

I tried to use MariaDB only for the carbon database, using the following datasource config:

<datasource>
    <name>WSO2_CARBON_DB</name>
    <description>The datasource used for registry and user manager</description>
    <jndiConfig>
        <name>jdbc/WSO2CarbonDB</name>
    </jndiConfig>
    <definition type="RDBMS">
        <configuration>
    <url>jdbc:mysql://wso2_mysql:3306/wso2_am_carbon;DB_CLOSE_ON_EXIT=FALSE</url>
            <username>wso2carbon</username>
            <password>wso2carbon</password>
    <!--<driverClassName>org.h2.Driver</driverClassName>-->
            <maxActive>50</maxActive>
            <maxWait>60000</maxWait>
            <testOnBorrow>true</testOnBorrow>
            <validationQuery>SELECT 1</validationQuery>
            <validationInterval>30000</validationInterval>
        </configuration>
    </definition>
</datasource>

user-mgt.xml is using the correct datasource name :

<Property name="dataSource">jdbc/WSO2CarbonDB</Property>

and my database has been initialized with the dbscripts/mysql5.7.sql script. User permissions have been set correctly.

Since after the failed start the database stays empty I guess there is a problem writing to it. So I tried to start the app with the -Dsetup parameter but no luck.

Thank you.

1
I've checked the user-mgt.xml, and it already has the AddAdmin parameter set to true. - cyrilv

1 Answers

0
votes

In the very first startup of the WSO2 server without the datasource changes, It will add an admin user to the default userstore. Therefore, if you have already created admin user within configured AD and that user has defined as admin user in IS configurations, IS use that user as the admin user.

Therefore, When you change the datasource of the primary userstore of WSO2 Server, you need to change the addAdmin property as true in user-mgt.xml file which can be found under /repository/conf directory.

<Configuration>
        <AddAdmin>true</AddAdmin>
            <AdminRole>admin</AdminRole>
            <AdminUser>
                <UserName>admin</UserName>
                <Password>admin</Password>
            </AdminUser>
            -
            -
        </Configuration>

Please check after changing the above property.