Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build Hibernate SessionFactory error with native mode in 1.8.0.final #12067

Closed
yuhaibohotmail opened this issue Sep 13, 2020 · 8 comments · Fixed by #12148
Closed
Assignees
Labels
area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working
Milestone

Comments

@yuhaibohotmail
Copy link

yuhaibohotmail commented Sep 13, 2020

Describe the bug
(Describe the problem clearly and concisely.)

When run in native mode , program will report " Unable to build Hibernate SessionFactory" error with either multiple persistence units or single persistence units.

[root@localhost single_ds_demo]# ./target/demo-1.0-SNAPSHOT-runner
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2020-09-13 19:19:26,963 WARN  [io.agr.pool] (main) Datasource '<default>': Ignor  ing property 'URL': No setter in class com.mysql.cj.jdbc.MysqlXADataSource
2020-09-13 19:19:26,964 WARN  [io.agr.pool] (main) Datasource '<default>': Ignor  ing property 'URL': No setter in class com.mysql.cj.jdbc.MysqlXADataSource
2020-09-13 19:19:26,971 WARN  [io.agr.pool] (Agroal_15085543651) Datasource '<de  fault>': Ignoring property 'password': No setter in class com.mysql.cj.jdbc.Mysq  lXADataSource
2020-09-13 19:19:26,971 WARN  [io.agr.pool] (Agroal_15085543651) Datasource '<de  fault>': Ignoring property 'user': No setter in class com.mysql.cj.jdbc.MysqlXAD  ataSource
2020-09-13 19:19:26,971 WARN  [io.agr.pool] (Agroal_15085543651) Datasource '<de  fault>': Available properties []
2020-09-13 19:19:27,001 WARN  [io.agr.pool] (Agroal_15085543651) Datasource '<de  fault>': Access denied for user ''@'172.18.0.1' (using password: NO)
2020-09-13 19:19:27,001 WARN  [org.hib.eng.jdb.spi.SqlExceptionHelper] (main) SQ  L Error: 1045, SQLState: 28000
2020-09-13 19:19:27,001 ERROR [org.hib.eng.jdb.spi.SqlExceptionHelper] (main) Ac  cess denied for user ''@'172.18.0.1' (using password: NO)
2020-09-13 19:19:27,001 ERROR [io.qua.application] (main) Failed to start applic  ation (with profile prod): javax.persistence.PersistenceException: [PersistenceU  nit: <default>] Unable to build Hibernate SessionFactory
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBui  lder.persistenceException(FastBootEntityManagerFactoryBuilder.java:115)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBui  lder.build(FastBootEntityManagerFactoryBuilder.java:75)
        at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider  .createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:56)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.  java:80)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.  java:55)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JP  AConfig.java:117)
        at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:41  )
        at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersist  enceUnits(HibernateOrmRecorder.java:82)
        at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUni  ts-1681903524.deploy_0(HibernateOrmProcessor$startPersistenceUnits-1681903524.zi  g:74)
        at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUni  ts-1681903524.deploy(HibernateOrmProcessor$startPersistenceUnits-1681903524.zig:  40)
        at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:630)
        at io.quarkus.runtime.Application.start(Application.java:90)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecyc  leManager.java:91)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
        at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
Caused by: org.hibernate.exception.GenericJDBCException: Unable to open JDBC Con  nection for DDL execution
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.conver  t(StandardSQLExceptionConverter.java:47)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlException  Helper.java:113)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlException  Helper.java:99)
        at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactio  nIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:62)
        at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactio  nCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBui  lderImpl.java:46)
        at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getD  dlTransactionIsolator(HibernateSchemaManagementTool.java:188)
        at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.buil  dGenerationTargets(HibernateSchemaManagementTool.java:146)
        at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDro  pperImpl.java:110)
        at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.perform  DatabaseAction(SchemaManagementToolCoordinator.java:145)
        at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process  (SchemaManagementToolCoordinator.java:73)
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.j  ava:316)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBui  lder.build(FastBootEntityManagerFactoryBuilder.java:73)
        ... 15 more
Caused by: java.sql.SQLException: Access denied for user ''@'172.18.0.1' (using   password: NO)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.jav  a:129)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.jav  a:97)
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(  SQLExceptionsMapping.java:122)
        at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.j  ava:197)
        at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:  416)
        at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:  128)
        at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:  113)
        at com.mysql.cj.jdbc.MysqlXADataSource.getXAConnection(MysqlXADataSource  .java:52)
        at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.j  ava:206)
        at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPoo  l.java:419)
        at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPoo  l.java:401)
        at java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityS  cheduledExecutor.java:65)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.  java:1126)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor  .java:628)
        at java.lang.Thread.run(Thread.java:834)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads  .java:517)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine  (PosixJavaThreads.java:192)

Expected behavior
(Describe the expected behavior clearly and concisely.)

Actual behavior
(Describe the actual behavior clearly and concisely.)

To Reproduce
Steps to reproduce the behavior:

Configuration

# Add your application.properties here, if applicable.

quarkus.http.port=8081

quarkus.datasource.db-kind=mysql
quarkus.datasource.username=user
quarkus.datasource.password=123
quarkus.datasource.jdbc.url=jdbc:mysql://192.168.1.132:3306/data
quarkus.datasource.jdbc.driver=com.mysql.cj.jdbc.MysqlXADataSource
quarkus.hibernate-orm.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.log.sql=true

quarkus.swagger-ui.always-include=true

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver:
  • Output of java -version:
  • GraalVM version : graalvm ce java11 20.2.0 centos 7.5
  • Quarkus version or git rev: 1.8.0.final
  • Build tool (ie. output of mvnw --version or gradlew --version): mvn 3.6.3

Additional context
(Add any other context about the problem here.)
This is a reproducer:
single_ds_demo.zip

@yuhaibohotmail yuhaibohotmail added the kind/bug Something isn't working label Sep 13, 2020
@quarkusbot quarkusbot added area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE labels Sep 13, 2020
@quarkusbot
Copy link

/cc @gsmet, @Sanne

@yuhaibohotmail
Copy link
Author

@gsmet ,Could you spare time to look at this problem?

@Sanne
Copy link
Member

Sanne commented Sep 16, 2020

thanks @yuhaibohotmail , I'll look at this.

@Sanne Sanne self-assigned this Sep 16, 2020
@gsmet
Copy link
Member

gsmet commented Sep 16, 2020

FWIW, I find it a bit suspicious: Caused by: java.sql.SQLException: Access denied for user ''@'172.18.0.1' (using password: NO) if you have a user and password defined, I wouldn't expect that.

@yuhaibohotmail
Copy link
Author

yuhaibohotmail commented Sep 16, 2020

That IP address has nothing to do with me. My address is 192.168.X.X.
On the same machine, the program runs normally with JVM.
I feel like the configuration infomation has been ignored:

2020-09-13 19:19:26,963 WARN  [io.agr.pool] (main) Datasource '<default>': Ignor  ing property 'URL': No setter in class com.mysql.cj.jdbc.MysqlXADataSource
2020-09-13 19:19:26,964 WARN  [io.agr.pool] (main) Datasource '<default>': Ignor  ing property 'URL': No setter in class com.mysql.cj.jdbc.MysqlXADataSource
2020-09-13 19:19:26,971 WARN  [io.agr.pool] (Agroal_15085543651) Datasource '<de  fault>': Ignoring property 'password': No setter in class com.mysql.cj.jdbc.Mysq  lXADataSource
2020-09-13 19:19:26,971 WARN  [io.agr.pool] (Agroal_15085543651) Datasource '<de  fault>': Ignoring property 'user': No setter in class com.mysql.cj.jdbc.MysqlXAD  ataSource

@Sanne
Copy link
Member

Sanne commented Sep 16, 2020

Ok, just verified that the're a simple one-liner solution, seems a ReflectiveClassBuildItem was missing.

I'll create an integration test for this and send the simple fix, but I also wonder if we could avoid needing Agroal to use reflection to set all properties at runtime; we could either use normal invocations, as we only support a limited set of properties, or create this bean at build time. @barreiro , what's your opinion? Maybe you want to do it?

Thanks

@gsmet
Copy link
Member

gsmet commented Sep 16, 2020

@Sanne how come we never caught this issue? Aren't the native IT for MySQL/MariaDB using authentication?

Will wait for the PR before commenting any further :)

@Sanne
Copy link
Member

Sanne commented Sep 17, 2020

@Sanne how come we never caught this issue? Aren't the native IT for MySQL/MariaDB using authentication?

It seems we had no such tests using the XA datasource

@gsmet gsmet added this to the 1.8.1.Final milestone Sep 17, 2020
@gsmet gsmet modified the milestones: 1.8.1.Final, 1.7.6.Final Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants