WSO2 EMM - MySQL configuration don't work - mysql

I'm trying to install wso2 EMM 1.0.1 on Debian. The server don't start with error : database not configured or has not started up. I followed the instructions from documentation. The database exists with the content and I change the master datasources.xml file like the example.
Overview of the beginning of the file :
<providers>
<provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
</providers>
<datasources>
<datasource>
<name>BDD_EMM</name>
<description>BDD MySQL pour EMM</description>
<jndiConfig>
<name>jdbc/emmdb</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:mysql://localhost:3306/EMM_DB</url>
<username>EMM</username>
<password>xxxxxx</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>...

Can you please double check database name, user and password as same as you define inside datasources.xml.
Also check mysql jdbc driver inside repository/components/lib folder.

Related

When Connecting WSO2 apim in docker to mysql in local machine getting error while using useSSL=true in url

When Connecting WSO2 apim in docker to mysql in local machine getting error while using ssl=true in url .
Datasource connection code in apim:
<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://host.docker.internal:3306/carbon_db?serverTimezone=UTC&useSSL=true</url>
<username>userame</username>
<password>password</password>
<driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
<defaultAutoCommit>true</defaultAutoCommit>
</configuration>
</definition>
</datasource>
It works fine when useSSL=false. useSSL= true gives the following connection failure error:
wso2am_1 | [2019-05-06 07:37:25,095] ERROR - TransactionManager Failed to start new registry transaction.
wso2am_1 | com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
Mysql server is 8.0 and ssl variables are as:
Please try with requireSSL=true.

WSO2 API Manager Mysql database initialization

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.
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.

WSO2 API manager failing to create new api with MySql

I have a new install of wso2 api manager v1.10.0. When using the default master-datasources.xml that uses the h2 database it works fine. I can click on the 'Deploy Sample API' button and the CalculatorAPI sample gets created properly. However, when I change master-datasources.xml to use MySql then trying to create the sample Calculator API hangs (the UI hangs at "Please Wait"). The CalculatorAPI is created but is not Published and the lifecycle cannot be changed to Published. The only change I made was to master-datasources.xml.
MySql and wso2AM are installed locally on Ubuntu Linux.
The data source configs for MySql I am using are:
<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://localhost:3306/regdb</url>
<username>regadmin</username>
<password>regadmin</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
<maxActive>80</maxActive>
<maxWait>60000</maxWait>
<minIdle>5</minIdle>
<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:mysql://localhost:3306/WSO2AM_DB</url>
<username>regadmin</username>
<password>regadmin</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
<maxActive>80</maxActive>
<maxWait>60000</maxWait>
<minIdle>5</minIdle>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
I ran the following commands in MySql to apply privileges:
GRANT ALL ON regdb.* TO regadmin#localhost IDENTIFIED BY "regadmin";
GRANT ALL ON WSO2AM_DB.* TO regadmin#localhost IDENTIFIED BY "regadmin";
FLUSH PRIVILEGES;
I started api manager with -Dsetup and it did create tables under both regdb and WSO2AM_DB.
The MySql jdbc driver is in repository/components/lib/mysql-connector-java-5.1.38.jar.
I checked all the logs and there are no errors. Any help will be appreciated.
I tried the same scenario using wso2 API manager 1.10 with MySQL but it works for me.
If you are still getting this error
Delete the API and disconnect your wifi or broadband connection for a while and try.
If you can see the API in CREATED mode. click on the API and go to lifecycle tab and change the status to PUBLISHED.

VS2012 WCF REST Service - Error: Cannot obtain metadata

I have built a WCF REST web service (WCF Service Application) and when I debug with Visual Studio 2012, it will spin up the WCF Test Client app and try to add my web service. I am getting the following error:
Error: Cannot obtain Metadata from http://localhost:50925/Service1.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:50925/Service1.svc Metadata contains a reference that cannot be resolved: 'http://localhost:50925/Service1.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service
I have visited the MSDN document linked above and I believe I have set up my web.config correctly.
Web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Service1" behaviorConfiguration="Service1Behavior">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"> </endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I still continue to receive the same error message. I am new to WCF / VS 2012 and .Net 4.0, but I am fluent in VS2008 .Net 2.0.
WCF REST services do not expose metadata, which is why you were getting that message (see more details in this blog post). If you're using the WCF Test Client, it's talking to a SOAP service (endpoint), not a REST one.
If you want to enable a RESTful endpoint, you can define the service element in configuration and define an endpoint inside of it which uses the webHttpBinding, and the endpoint also needs a behaviorConfiguration pointing to an endpoint behavior with the <webHttp/> behavior.
As it turns out I created a new WCF project and looked at what was going on here. VS2012/.Net 4.0 does not like the service configurations with endpoints defined. Here is my new web.config that works fine. I will need to look into why this is but at least it answers my question.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

MVC2 MySQL Hosting Issue?

I have an MVC2 app that utilizes MySql.Web ver. 6.2.2.0, on my dev machine locally it works fine!
However, once I upload it to my http://www.winhost.com account I get the following error:
Parser Error Message: Unable to initialize provider. Missing or incorrect schema.
Line 32: <clear/>
Line 33: <add name="MySqlMembershipProvider"
Line 34: type="MySql.Web.Security.MySQLMembershipProvider,MySql.Web,
Version=6.2.2.0, Culture=neutral,PublicKeyToken=c5687fc88969c44d"
Is there something I can do to get this going? Or am I at the mercy of my host?
here is my config:
<membership defaultProvider="MySqlMembershipProvider">
<providers>
<clear/>
<add name="MySqlMembershipProvider"
type="MySql.Web.Security.MySQLMembershipProvider,MySql.Web, Version=6.2.2.0, Culture=neutral,PublicKeyToken=c5687fc88969c44d"
autogenerateschema="true"
connectionStringName="mysql"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
passwordFormat="Encrypted"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
applicationName="/"
/>
</providers>
</membership>
Try these articles to help ensure your host, your MySQL instance, and your web app are configured correctly.
MySQL ASP.NET Membership and Role Provider
ASP.NET and MySQL - membership provider
Marvin Palmer has a great walkthrough on Implementing .NET Membership and Roles using MySql Connector
Another potentially related question.