question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hibernate exception when deploying JPA prod

See original GitHub issue

While deploying apicurio/apicurio-registry-jpa:latest image with:

- name: QUARKUS_PROFILE
  value: prod
- name: QUARKUS_DATASOURCE_URL
  value: {{ .Values.postgresql.postgresqlUrl }}
- name: QUARKUS_DATASOURCE_USERNAME
  value: {{ .Values.postgresql.postgresqlUsername }}
- name: QUARKUS_DATASOURCE_PASSWORD
  value: {{ .Values.postgresql.postgresqlPassword}}

Receive:

Hibernate:

    drop table meta if exists
2020-02-20 15:32:55,836 WARN  [org.hib.too.sch.int.ExceptionHandlerLoggedImpl] (main) GenerationTarget encountered exception accepting command : Error executing DDL "
    drop table meta if exists" via JDBC Statement: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "
    drop table meta if exists" via JDBC Statement
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375)
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359)
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:241)
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154)
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126)
	at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112)
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:145)
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:320)
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
	at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:65)
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:54)
	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(JPAConfig.java:109)
	at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:57)
	at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersistenceUnits(HibernateOrmRecorder.java:82)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits78.deploy_0(HibernateOrmProcessor$startPersistenceUnits78.zig:51)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits78.deploy(HibernateOrmProcessor$startPersistenceUnits78.zig:70)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:234)
	at io.quarkus.runtime.Application.start(Application.java:87)
	at io.quarkus.runtime.Application.run(Application.java:210)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:41)
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "if"
  Position: 22
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2505)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2241)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:310)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:447)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:368)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:309)
	at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:295)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:272)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:267)
	at io.agroal.pool.wrapper.StatementWrapper.execute(StatementWrapper.java:232)
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
	... 23 more

Same thing for other tables.

Similarly:

2020-02-20 15:32:55,914 WARN  [org.hib.too.sch.int.ExceptionHandlerLoggedImpl] (main) GenerationTarget encountered exception accepting command : Error executing DDL "
    create table artifacts (
       global_id bigint not null,
        artifact_id varchar(255) not null,
        value blob not null,
        version bigint not null,
        primary key (global_id)
    )" via JDBC Statement: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "
    create table artifacts (
       global_id bigint not null,
        artifact_id varchar(255) not null,
        value blob not null,
        version bigint not null,
        primary key (global_id)
    )" via JDBC Statement
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:439)
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:423)
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:314)
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)
	at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:156)
	at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:320)
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
	at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:65)
	at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:54)
	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(JPAConfig.java:109)
	at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:57)
	at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersistenceUnits(HibernateOrmRecorder.java:82)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits78.deploy_0(HibernateOrmProcessor$startPersistenceUnits78.zig:51)
	at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits78.deploy(HibernateOrmProcessor$startPersistenceUnits78.zig:70)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:234)
	at io.quarkus.runtime.Application.start(Application.java:87)
	at io.quarkus.runtime.Application.run(Application.java:210)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:41)
Caused by: org.postgresql.util.PSQLException: ERROR: type "blob" does not exist
  Position: 122
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2505)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2241)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:310)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:447)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:368)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:309)
	at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:295)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:272)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:267)
	at io.agroal.pool.wrapper.StatementWrapper.execute(StatementWrapper.java:232)
	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
	... 23 more

In PostgreSQL there is no blob type but bytea.

Seems like the driver doesn’t execute PostgreSQL compatible statements.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
EricWittmanncommented, Feb 20, 2020

Would I be correct in interpreting this as “-jpa fails unless built with -Pprod”?

@jsenko can you comment on this? Perhaps test to see if the JPA version works with postgresql when built without -Pprod.

I’m pretty sure that the -latest build was done as a dev build, because the most recent build was a snapshot/non-release build. And the -latest tag is pushed for both snapshot and non-release builds. The next time a release is done, there will be a new latest-release tag. But regardless, the JPA variant should work even when building as dev, I would hope.

0reactions
EricWittmanncommented, May 14, 2020

OK I’ve confirmed - all docker builds are done with -Pprod enabled. Closing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hibernate exception when try to launch Tomcat - Stack Overflow
I have application on spring-mvc+jpa. I build war and try to start on tomcat. DataConfig: import org.hibernate.ejb.HibernatePersistence ...
Read more >
14.6 JPA - Spring
In such a scenario, the entire persistence unit deployment, including the weaving (byte-code transformation) of persistent classes, is up to the Java EE...
Read more >
Getting error while deploying on prod due to JPA
Caused by: java.lang.RuntimeException: No JPA entity manager defined for 'default'. at play.db.jpa.DefaultJPAApi.withTransaction(DefaultJPAApi.java:126) ...
Read more >
Chapter 12. Java Persistence API (JPA) Red Hat JBoss ...
It manages the entity instances and their lifecycle. Loaded entities are placed into the persistence context before being returned to the application. Entity ......
Read more >
Common Hibernate Exceptions - Baeldung
Many conditions can cause exceptions to be thrown while using Hibernate. These can be mapping errors, infrastructure problems, SQL errors, data ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found