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

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.

Related

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.

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.

JBOSS 7 MYSQL missing dependencies error

There are many threads like this one already for similar errors but none which have solved my problem so after an hour of trying to debug it, I have decide to ask for help.
Background
I am setting up a Java EE project. I have create an enterprise application and have create an EJB project, JPA project and web Project and added EAR's to the enterprise project.
I have also added mysql-connector-java-5.1.0-bin to the JBOSS/standalone/deployments folder. And added to this jar file to the JPA project.
Any advice on how to solve the error would be greatly apprecited.
The main error is:
missing/unavailable dependencies" =>
["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSD
Here is my full error:
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from [Module "org.hibernate:main" from local module loader #32008dad (roots: C:\Users\Bawn92\Desktop\Programs\jboss-as-7.1.1.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_07]
at java.lang.Class.forName(Class.java:186) [rt.jar:1.7.0_07]
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:101)
... 23 more
01:50:40,265 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "SIMSProject.ear" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\": Failed to start service"},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDBMissing[jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDB]"]}
01:50:40,296 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment SIMSWebProject.war in 31ms
01:50:40,296 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment SIMSEJB.jar in 31ms
01:50:40,309 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment SIMSProject.ear in 44ms
01:50:40,312 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.persistenceunit."SIMSProject.ear#SIMSJPA": org.jboss.msc.service.StartException in service jboss.persistenceunit."SIMSProject.ear#SIMSJPA": Failed to start service
01:50:40,316 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"SIMSProject.ear#SIMSJPA\": Failed to start service"},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDBMissing[jboss.persistenceunit.\"SIMSProject.ear#primary\"jboss.naming.context.java.jboss.datasources.SIMSDB]"]}}}
MY -ds.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jndi-name="java:jboss/datasources/SIMSDB" enabled="true"
use-java-context="true" pool-name="SIMSDB">
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver>mysql-connector-java-5.1.0-bin.jar</driver>
<pool></pool>
<security>
<user-name>root</user-name>
<password>nbuser</password>
</security>
</datasource>
</datasources>
My persistence.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/SIMSDB</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
<persistence-unit name="SIMSJPA">
<class>model.Class</class>
<class>model.Subject</class>
<class>model.Teacher</class>
<properties>
<!-- //i put in dialect line -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="nbuser"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/mydb"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
</persistence>
The datasourse section of my Standalone file is:
<datasource jndi-name="java:jboss/datasources/SIMSDB" pool-name="SIMSDB">
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver>mysql-connector-java-5.1.0-bin.jar</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>test</user-name>
<password>test</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
You need to create MySQL driver module.
JBoss 7 will be able to use if you create it like this:
download the driver (jar file)
create directory in you server path: {$jboss-home}/modules/com/mysql/main
and paste the driver jar file here
in same folder create and new file module.xml
Insert following code in that module.xml (if your jar file is named mysql.jdbc.jar):
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql.jdbc.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Make sure the dependencies for your mysql.jdbc.jar are OK.
JBoss 7 is not using -ds.xml any more.
You allready doing setup for your databse in standalon.xml, this the right way.
Just make sure your migration is correct. I see you have diffent user name and password...
EDIT1:
I don't know how hibernate works with JBoss 7.
But I see you should try to change in your persistence.xml
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
to
<property name="hibernate.connection.driver_class" value="com.mysql"/>
because you are using com.mysql as module name. Otherwise you can change module name to com.mysql.jdbc.Driver.
In your standalone.xml
change
<driver>mysql-connector-java-5.1.0-bin.jar</driver>
to
<driver>com.mysql</driver>
because you gave com.mysql as name for your driver:
<driver name="com.mysql" module="com.mysql">

Connecting JSF Web Application deployed on Glassfish to a local MySQL database

I have glassfish running on the same server that the MySQL database is running on. When I attempt to deploy the web application via the admin console, I get the following error:
Error occurred during deployment: Exception while preparing the app : Invalid resource : solardbdatasource__pm. Please see server.log for more details.
I am however able to run the web application from another computer and connect remotely to the database, only when I attempt to deploy the application on the same server as the database do I get the error. My glassfish-resources.xml for my working remote connection:
<resources>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false"
connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10"
connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit"
datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
fail-all-connections="false" idle-timeout-in-seconds="300"
is-connection-validation-required="false" is-isolation-level-guaranteed="true"
lazy-connection-association="false" lazy-connection-enlistment="false"
match-connections="false" max-connection-usage-count="0" max-pool-size="32"
max-wait-time-in-millis="60000" name="mysql_solardb_rootPool"
non-transactional-connections="false" pool-resize-quantity="2"
res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1"
steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="192.168.1.113"/>
<property name="portNumber" value="3306"/>
<property name="databaseName" value="solardb"/>
<property name="User" value="root"/>
<property name="Password" value="password"/>
<property name="URL" value="jdbc:mysql://192.168.1.113:3306/solardb?zeroDateTimeBehavior=convertToNull"/>
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="solardbdatasource" object-type="user" pool-name="mysql_solardb_rootPool"/>
When I attempt to deploy it on the server I change '192.168.1.113' to '127.0.0.1'(localhost) to no avail. My persistance.xml:
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="solar-decathlonPU" transaction-type="JTA">
<jta-data-source>solardbdatasource</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>
My problem seemed to be that the stand alone download of glassfish does not come with the mysql connector. In addition, i needed to manually configure the jdbc connection pool via the administrator console. One final issue I ran into was the 'URL' property, there are actually two when setting up a connection pool by default: 'Url' and 'URL', with the latter being the one I wanted.

Categories