2 Replies Latest reply on Dec 31, 2018 10:36 AM by jaikiran pai

    wildfly15 default schema is invalid

    Stephen Yang Newbie

      I plan to use idea to develop and deploy a ejb jar file to wildfly, but console print below info, I think it is cased by hibernate default schema, How can I solve it ? Anyone can help me ? thanks

       

      persistence.xml:

         <persistence-unit name="persistUnit" transaction-type="JTA">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>java:jboss/datasources/MySqlDS</jta-data-source>
        <properties>
        <property name="hibernate.show_sql" value="true"/>
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.hbm2ddl.auto" value="update"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL8Dialect"/>
        <property name="hibernate.default_schema" value="sample"/>
        </properties>
      </persistence-unit>

       

       

       

      datasource config:

      <datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" spy="true" tracking="true"
         enlistment-trace="true" statistics-enabled="true">
        <connection-url>jdbc:mysql://localhost:3306/sample</connection-url>
        <driver-class>com.mysql.cj.jdbc.Driver</driver-class>
        <datasource-class>com.mysql.cj.jdbc.MysqlDataSource</datasource-class>
        <connection-property name="useSSL">
         false

         </connection-property>
        <connection-property name="serverTimezone">
         GMT+8

         </connection-property>
        <connection-property name="characterEncoding">
         UTF-8

         </connection-property>
        <driver>mysql</driver>
        <security>
        <user-name>sample</user-name>
        <password>sample</password>
        </security>
        <validation>
        <valid-connection-checker
         class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
        <background-validation>true</background-validation>
        <exception-sorter
         class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
        </validation>
        <statement>
        <share-prepared-statements>true</share-prepared-statements>
        </statement>
      </datasource>

       

      Error log:

      11:30:33,299 WARN  [org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl] (ServerService Thread Pool -- 37) GenerationTarget encountered exception accepting command : Error executing DDL "

          create table person (

             personId integer not null,

              age integer not null,

              birthday date,

              name varchar(32) not null,

              primary key (personId)

          ) engine=InnoDB" via JDBC Statement: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "

          create table person (

             personId integer not null,

              age integer not null,

              birthday date,

              name varchar(32) not null,

              primary key (personId)

          ) engine=InnoDB" via JDBC Statement

      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)

      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559)

      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504)

      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.createTable(AbstractSchemaMigrator.java:277)

      at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:71)

      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207)

      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114)

      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183)

      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)

      at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310)

      at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)

      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939)

      at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)

      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:170)

      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:128)

      at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:649)

      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:212)

      at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)

      at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)

      at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)

      at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)

      at java.lang.Thread.run(Thread.java:748)

      at org.jboss.threads.JBossThread.run(JBossThread.java:485)

      Caused by: java.sql.SQLException: No database selected

      at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:127)

      at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)

      at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)

      at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:790)

      at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:675)

      at org.jboss.jca.adapters.jdbc.WrappedStatement.execute(WrappedStatement.java:198)

      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)

      ... 22 more