WSO2 API manager failing to create new api with MySql - 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.

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.

arquillian, wildfly change datasource to mysql - error missing/unsatisfied dependencies

i have working arquillian tests that use default h2/mem data base. now i want to switch to my sql.
I first copied mysql-connector-java-5.1.33-bin.jar to standalone/deployments. The log confirmed proper deployment. I also tried to setup the mysql datasource via wildfly's admin console and it worked fine (i did connection test but didn't add the datasource).
I want to keep the datasource setup within project's test. So i added the data source to src/test/resources/test-ds.xml:
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<datasource jndi-name="java:jboss/datasources/moritzTimetrackerTestDSmysql"
pool-name="moritzTimetracker-test" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/moritztimetracker</connection-url>
<driver>mysql-connector-java-5.1.33-bin.jar</driver>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
</datasource>
The src/test/resources/META-INF/test-persistence.xml looks like this:
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/moritzTimetrackerTestDSmysql</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
But if i run the test i get exception:
org.jboss.arquillian.container.spi.client.container.DeploymentException: Cannot deploy: test.war
...
Caused by: java.lang.Exception: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.data-source.java:jboss/datasources/moritzTimetrackerTestDSmysql is missing [jboss.jdbc-driver.mysql-connector-java-5_1_33-bin_jar]"]}
The log says:
JBAS014775: New missing/unsatisfied dependencies:
service jboss.data-source.java:jboss/datasources/moritzTimetrackerTestDSmysql (missing) dependents: [service jboss.data-source.reference-factory.java:jboss/datasources/moritzTimetrackerTestDSmysql]
service jboss.data-source.reference-factory.java:jboss/datasources/moritzTimetrackerTestDSmysql (missing) dependents: [service jboss.naming.context.java.jboss.datasources.moritzTimetrackerTestDSmysql]
service jboss.jdbc-driver.mysql-connector-java-5_1_33-bin_jar (missing) dependents: [service jboss.data-source.java:jboss/datasources/moritzTimetrackerTestDSmysql]
service jboss.persistenceunit."test.war#primary".__FIRST_PHASE__ (missing) dependents: [service jboss.deployment.unit."test.war".POST_MODULE]
How to correctly setup mysql as data source?
Your setup seems correct (I mean data source and persistence xml).
But please check whether you are deploying test-ds.xml file along with your app in every test case. I mean:
#Deployment
public static Archive<?> createDeployment() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource("test-ds.xml") /* CRUCIAL STEP */
...
}
In this way, your data source definition is deployed with every micro deployment of your EJBs.
Since it is very badly documented i viewed the standalone.xml after i created the data source via the admin web interface. Setting the mysql datasource this way works fine:
<datasource jndi-name="java:jboss/datasources/testDSmysql"
pool-name="test" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/db</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql-connector-java-5.1.33-bin.jar_com.mysql.jdbc.Driver_5_1</driver>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
</datasource>
See "drive-class" and "driver" - it is very different than stuff you read in documentation?!

WSO2 EMM - MySQL configuration don't work

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.

Connection interrupted when using WebHttpBinding in Transport SecurityMode

I want to expose an implementation of a contract over a WebHttpBinding with SecurityMode: transport (SSL).
However, when I try to access the site via Firefox, I only get
The connection to localhost was interrupted while the page was loading.
The config file is as follows:
<configuration>
<system.serviceModel>
<services>
<service name="MyService">
<endpoint address="https://localhost"
binding="webHttpBinding"
contract="MyService"
bindingConfiguration="secureWebHttp">
</endpoint>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="secureWebHttp">
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
If host within IIS, you need to configure the hosting website security to use an ssl certificate on port 443 in this case.
You also need to configure the service behavior to set the certificate name and store. Particularly when hosting the wcf service as windows services, the certificate needs to be set for the port that you want to use. for example httpcfg.exe or netsh in vista.
Check out MSDN Configuring HTTP and HTTPS