Wildfly 10 won't prefill - mysql

I'm Pretty new to wildfly 10. i have my datasources working and my connector working. i have successfuly connections. i have the prefill setting selected. it just doesn't populate my sql database with any tables.
<datasource jta="true" jndi-name="java:/MySqlDS" pool-name="MySqlDS" enabled="tru$
<connection-url>jdbc:mysql://<IP>:3306/DatabaseName?useSSL=false</connection-$
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql</driver>
<pool>
<min-pool-size>50</min-pool-size>
<max-pool-size>500</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensi$
<background-validation>true</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysq$
</validation>
</datasource>

You're missing the purpose of prefill. It is to fill the database connection pool pretty much on startup. It doesn't create any tables for you. Usually that is an external process like a SQL script to create the tables. There are other options such as Hibernate that can create tables on startup but that is a different question.

Bydefault JBoss will not create any table in Mysql DB schema, you have to deploy application which will create table in DB schema. Why you are expecting JBoss to create tables in DB schema ?

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.

Hive : why is metastore_db created in my project folder?

I have put hive-site.xml in my spark/conf dir and configured it to connect to thrift://<user>:9083 and I am not using derby I have mysql-connector-jar inside hive/lib folder , still every time I create hive table and store data , all data are stored in metastore_db in my project directory instead in my hdfs://<user>:9000/user/hive/warehouse, so if I delete metastore_db data is lost.
conf/hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://saurab:3306/metastore_db?
createDatabaseIfNotExist=true</value>
<description>metadata is stored in a MySQL server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>MySQL JDBC driver class</description>
</property>
<property>
<name>hive.aux.jars.path</name>
<value>/home/saurab/hadoopec/hive/lib/hive-serde-
2.1.1.jar</value>
</property>
<property>
<name>spark.sql.warehouse.dir</name>
<value>hdfs://saurab:9000/user/hive/warehouse</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://saurab:9083</value>
<description>URI for client to contact metastore
server</description>
</property>
This is my thriftserver log.Mysql server is running.So why it is still creating metastore_db and storing data there.
I would say you have made those changes on the Spark conf folder but not on the server one (at least not all of them).
Notice on the server log:
"metastore.MetaStoreDirectSql: Using direct SQL, underlying DB is DERBY"
A common practice is instead of copying the config under spark/conf just add a link from there to /etc/hive/conf/hive-site.xml, to make sure client and server are using the same configuration.
My advice is to setup the server side correctly first (you also have a port conflict), test it with beeline and only them start using it from Spark

How to prevent database renewing its data in camunda

I am using
- camunda-bpm-wildfly-7.4.0
- mysql-5.6.24-winx64
- wildfly-8.2.1.Final
I have integerated mysql with camunda wildfly.
My datasource code in the standalone.xml is as follows,
<datasource jta="true" jndi-name="java:jboss/datasources/ProcessEngine" pool-name="ProcessEngine" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:8888/camundabpm?DB_CLOSE_DELAY=-1;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>mysql</driver>
How do I prevent the database resetting on server restart? It removes all data and replaces it with new data on every server start. So I am unable to persist my data between server on and off.
Update:
I found out that hibernate was deleting the tables from the db So I changed the property from this
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
to
<property name="hibernate.hbm2ddl.auto" value="update" />
after having a look at How to make Hibernate not drop tables. But now the tasklist process instances are removed and only the tables created by my project remain and all other tables are refreshed with new data.
Can you check the value of the databaseSchemaUpdate poroperty? It should be contained in the standalone.xml of our WildFly (very down). Make sure it os not set to create-drop.
See https://docs.camunda.org/manual/7.4/reference/deployment-descriptors/tags/process-engine/#configuration-properties

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?!

The underlying provider failed to open , login failed for user IIS APPPOOL

i am not a sql server guy but i am working on a client's application and want to connect to the database through EF Code first
the Exception message that i have is
The underlying provider failed to open
The Exception details
Cannot open database [DatabaseName] requested by the login. the login failed
login failed for user 'IIS APPPOOL\ASP.NET v4.0"
My web config
<add name="TraininGoDB"
providerName="System.Data.SqlClient"
connectionString="Server=LOCALPCNAME\SQLEXPRESS;Database=[DATABASENAME];Integrated Security=True;"/>
The EF context and entities are defined in a separate project with the app config of the following
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
i am using SQL Server Express 2008
don't know the problem from the database configration or from the web config
The user under which the web application pool (associated to your web application) is running doesn't have permissions to access your database. You need to grant it permissions or run under another user who has permissions. So, to summarize: check under which user your application pool is running, then check that that user has access to your database.
If all of your Web.config files are correct, SQLSERVER has the appropriate permissions, etc., there's one more thing you can check. I once had this issue when a client had me configure the project so that Entity Framework would not automatically drop the databases (if, for example, the models changed), but I was still testing the project on localhost. I thus needed to create a new database, but I forgot to fix my context files. For example, my problem was:
public MasterContext(string nameOrConnectionString) : base(nameOrConnectionString)
{
Database.SetInitializer<MasterContext>(null);
}
when it should have been (for the purpose of testing):
public MasterContext(string nameOrConnectionString) : base(nameOrConnectionString)
{
Database.SetInitializer<MasterContext>(new DropCreateDatabaseIfModelChanges<MasterContext>());
}
Otherwise, I would receive the same error, that the underlying provider failed on open, with the inner exception being that the login failed for the user.