munna
munna

Reputation: 324

WSO2 API Manager with Analytics: stats-datasources.xml' - System datasource WSO2AM_STATS_DBcan not be updated

I am trying to setup statistics with wso2am-analytics-2.1.0 and wso2am-2.0.0.As per the documents i have configured the same WSO2AM_STATS_DB in analytics and wso2am as well. when i am starting the analytics server it is giving me below error. I have verified all previous posts but somehow not able to figuring out the resolution for this issue.

[2017-03-02 11:29:32,323] ERROR {org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent} -  Error in intializing system data sources: Error in initializing system data sources: Error in initializing system data sources at 'C:\MAHABO~1\WSO2AM~2.0\bin\..\repository\conf\datasources\stats-datasources.xml' - System datasource WSO2AM_STATS_DBcan not be updated.
org.wso2.carbon.ndatasource.common.DataSourceException: Error in initializing system data sources: Error in initializing system data sources at 'C:\MAHABO~1\WSO2AM~2.0\bin\..\repository\conf\datasources\stats-datasources.xml' - System datasource WSO2AM_STATS_DBcan not be updated.
        at org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSources(DataSourceManager.java:168)
        at org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.initSystemDataSources(DataSourceServiceComponent.java:192)
        at org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.setSecretCallbackHandlerService(DataSourceServiceComponent.java:178)
        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.eclipse.equinox.internal.ds.model.ComponentReference.bind(ComponentReference.java:376)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bindReference(ServiceComponentProp.java:430)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bind(ServiceComponentProp.java:218)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:343)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
        at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
        at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
        at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
        at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
        at org.wso2.carbon.securevault.internal.SecretManagerInitializerComponent.activate(SecretManagerInitializerComponent.java:48)
        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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
        at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
        at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
        at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
        at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
        at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
        at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
        at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.wso2.carbon.ndatasource.common.DataSourceException: Error in initializing system data sources at 'C:\MAHABO~1\WSO2AM~2.0\bin\..\repository\conf\datasources\stats-datasources.xml' - System datasource WSO2AM_STATS_DBcan not be updated.
        at org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSource(DataSourceManager.java:188)
        at org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSources(DataSourceManager.java:164)
        ... 40 more
Caused by: org.wso2.carbon.ndatasource.common.DataSourceException: System datasource WSO2AM_STATS_DBcan not be updated.
        at org.wso2.carbon.ndatasource.core.DataSourceRepository.registerDataSource(DataSourceRepository.java:344)
        at org.wso2.carbon.ndatasource.core.DataSourceRepository.addDataSource(DataSourceRepository.java:473)
        at org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSource(DataSourceManager.java:185)
        ... 41 more
[2017-03-02 11:29:34,269]  INFO {org.wso2.carbon.user.core.common.DefaultRealmService} -  Database already exists. Not creating a new database.


Analytics stats-datasources.xml :
org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader WSO2AM_STATS_DB The datasource used for setting statistics to API Manager jdbc/WSO2AM_STATS_DB jdbc:mysql://localhost:3306/WSO2AM_STATS_DB?autoReconnect=true&relaxAutoCommit=true root root com.mysql.jdbc.Driver 50 60000 true SELECT 1 30000 false
 </datasources>

Analytics master-datasources.xml

org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader WSO2_CARBON_DB The datasource used for registry and user manager jdbc/WSO2CarbonDB jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000 wso2carbon wso2carbon org.h2.Driver 50 60000 true SELECT 1 30000 false
    <!-- sample testing purpose -->
    <datasource>
    <name>WSO2AM_STATS_DB</name>
    <description>The datasource used for setting statistics to API Manager</description>
    <jndiConfig>
    <name>jdbc/WSO2AM_STATS_DB</name>
    </jndiConfig>
    <definition type="RDBMS">
    <configuration>
     <url>jdbc:mysql://localhost:3306/WSO2AM_STATS_DB?autoReconnect=true&amp;relaxAutoCommit=true</url>
     <username>root</username>
     <password>root</password>
     <driverClassName>com.mysql.jdbc.Driver</driverClassName>
     <maxActive>50</maxActive>
     <maxWait>60000</maxWait>
     <testOnBorrow>true</testOnBorrow>
     <validationQuery>SELECT 1</validationQuery>
     <validationInterval>30000</validationInterval>
     <defaultAutoCommit>false</defaultAutoCommit>
    </configuration>
    </definition>
    </datasource>
    
    <!-- For an explanation of the properties, see: http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html -->
    <!--datasource>
        <name>SAMPLE_DATA_SOURCE</name>
        <jndiConfig>
            <name></name>
            <environment>
                <property name="java.naming.factory.initial"></property>
                <property name="java.naming.provider.url"></property>
            </environment>
        </jndiConfig>
        <definition type="RDBMS">
            <configuration>

                <defaultAutoCommit></defaultAutoCommit>
                <defaultReadOnly></defaultReadOnly>
                <defaultTransactionIsolation>NONE|READ_COMMITTED|READ_UNCOMMITTED|REPEATABLE_READ|SERIALIZABLE</defaultTransactionIsolation>
                <defaultCatalog></defaultCatalog>
                <username></username>
                <password svns:secretAlias="WSO2.DB.Password"></password>
                <maxActive></maxActive>
                <maxIdle></maxIdle>
                <initialSize></initialSize>
                <maxWait></maxWait>

                <dataSourceClassName>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</dataSourceClassName>
                <dataSourceProps>
                    <property name="url">jdbc:mysql://localhost:3306/Test1</property>
                    <property name="user">root</property>
                    <property name="password">123</property>
                </dataSourceProps>

            </configuration>
        </definition>
    </datasource-->

</datasources>
APIM master-datasources.xml
<providers>
    <provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
</providers>

<datasources>

    <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:h2:repository/database/WSO2CARBON_DB;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>

    <datasource>
        <name>WSO2AM_DB</name>
        <description>The datasource used for API Manager database</description>
        <jndiConfig>
            <name>jdbc/WSO2AM_DB</name>
        </jndiConfig>
        <definition type="RDBMS">
            <configuration>
                <url>jdbc:h2:repository/database/WSO2AM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
                <username>wso2carbon</username>
                <password>wso2carbon</password>
                <defaultAutoCommit>false</defaultAutoCommit>
                <driverClassName>org.h2.Driver</driverClassName>
                <maxActive>50</maxActive>
                <maxWait>60000</maxWait>
                <testOnBorrow>true</testOnBorrow>
                <validationQuery>SELECT 1</validationQuery>
                <validationInterval>30000</validationInterval>
            </configuration>
        </definition>
    </datasource>

        <datasource>
   <name>WSO2AM_STATS_DB</name>
   <description>The datasource used for setting statistics to API Manager</description>
   <jndiConfig>
      <name>jdbc/WSO2AM_STATS_DB</name>
   </jndiConfig>
   <definition type="RDBMS">
      <configuration>
         <url>jdbc:mysql://localhost:3306/WSO2AM_STATS_DB?autoReconnect=true&amp;relaxAutoCommit=true</url>
         <username>root</username>
         <password>root</password>
         <driverClassName>com.mysql.jdbc.Driver</driverClassName>
         <maxActive>50</maxActive>
         <maxWait>60000</maxWait>
         <testOnBorrow>true</testOnBorrow>
         <validationQuery>SELECT 1</validationQuery>
         <validationInterval>30000</validationInterval>
         <defaultAutoCommit>false</defaultAutoCommit>
      </configuration>
   </definition>
</datasource>

    <datasource>
        <name>WSO2_MB_STORE_DB</name>
        <description>The datasource used for message broker database</description>
        <jndiConfig>
            <name>WSO2MBStoreDB</name>
        </jndiConfig>
        <definition type="RDBMS">
            <configuration>
                <url>jdbc:h2:repository/database/WSO2MB_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000</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>
                <defaultAutoCommit>false</defaultAutoCommit>
            </configuration>
        </definition>
    </datasource>

    <!-- For an explanation of the properties, see: http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html -->
    <!--datasource>
        <name>SAMPLE_DATA_SOURCE</name>
        <jndiConfig>
            <name></name>
            <properties>
                <property name="java.naming.factory.initial"></property>
                <property name="java.naming.provider.url"></property>
            </properties>
        </jndiConfig>
        <definition type="RDBMS">
            <configuration>

                <defaultAutoCommit></defaultAutoCommit>
                <defaultReadOnly></defaultReadOnly>
                <defaultTransactionIsolation>NONE|READ_COMMITTED|READ_UNCOMMITTED|REPEATABLE_READ|SERIALIZABLE</defaultTransactionIsolation>
                <defaultCatalog></defaultCatalog>
                <username></username>
                <password svns:secretAlias="WSO2.DB.Password"></password>
                <maxActive></maxActive>
                <maxIdle></maxIdle>
                <initialSize></initialSize>
                <maxWait></maxWait>

                <dataSourceClassName>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</dataSourceClassName>
                <dataSourceProps>
                    <property name="url">jdbc:mysql://localhost:3306/Test1</property>
                    <property name="user">root</property>
                    <property name="password">123</property>
                </dataSourceProps>

            </configuration>
        </definition>
    </datasource-->

</datasources>

Upvotes: 2

Views: 1034

Answers (1)

Pubci
Pubci

Reputation: 4001

This error could occur if you have defined the same datasource multiple times in the server configurations. If you check the analytics server configurations WSO2AM_STATS_DB is defined in stats-datasources.xml as well as the master-datasources.xml. You don't need to define this in master-datasources.xml. Please remove that datasource and start the analytics server.

Upvotes: 4

Related Questions