16

I have next problem when deploy application on openshift. I use a wildfly application server and PostgreSQL cartrige.

In persistence.xml i set property "hibernate.hbm2ddl.auto" value="update". In wildfly modules in org/main/postgresql i see that wildfly use postgresql-9.3-1102-jdbc41.jar

12:12:14,760 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 62) HHH000319: Could not get database metadata: org.h2.jdbc.JdbcSQLException: Table "PG_CLASS" not found; SQL statement:
select relname from pg_class where relkind='S' [42102-173]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)
        at org.h2.message.DbException.get(DbException.java:171)
        at org.h2.message.DbException.get(DbException.java:148)
        at org.h2.command.Parser.readTableOrView(Parser.java:4864)
        at org.h2.command.Parser.readTableFilter(Parser.java:1107)
        at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1713)
        at org.h2.command.Parser.parseSelectSimple(Parser.java:1821)
        at org.h2.command.Parser.parseSelectSub(Parser.java:1707)
        at org.h2.command.Parser.parseSelectUnion(Parser.java:1550)
        at org.h2.command.Parser.parseSelect(Parser.java:1538)
        at org.h2.command.Parser.parsePrepared(Parser.java:405)
        at org.h2.command.Parser.parse(Parser.java:279)
        at org.h2.command.Parser.parse(Parser.java:251)
        at org.h2.command.Parser.prepareCommand(Parser.java:218)
        at org.h2.engine.Session.prepareLocal(Session.java:428)
        at org.h2.engine.Session.prepareCommand(Session.java:377)
        at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1138)
        at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:72)
        at org.jboss.jca.adapters.jdbc.WrappedStatement.executeQuery(WrappedStatement.java:344)
        at org.hibernate.tool.hbm2ddl.DatabaseMetadata.initSequences(DatabaseMetadata.java:178) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.java:92) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.java:84) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:196) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:522) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) [hibernate-core-4.3.7.Final.jar:4.3.7.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844) [hibernate-entitymanager-4.3.7.Final.jar:4.3.7.Final]
        at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) [jipijapa-hibernate4-3-1.0.1.Final.jar:]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
        at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_05]
        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474) [wildfly-security-manager-1.0.0.Final.jar:1.0.0.Final]
        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.2.0.Final.jar:8.2.0.Final]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_05]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_05]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_05]
        at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final]

I'am use a hibernate as JPA (hibernate-core-4.3.6). And i think that this problem with different version of Postgresql 9.2 and 9.3 Can anybody explain me how to change hibernate dialect at 9.2 Postgres version or change postgresql library module on openshift?

Klimov Peter
  • 308
  • 1
  • 2
  • 12
  • That query `select relname from pg_class where relkind='S'` should work OK for pretty much any version of postgresql. The fact that the error message reports the table name capitalized seems suspicious though. – harmic Dec 29 '14 at 21:54
  • @Klimov Piter The table is called `"pg_catalog"."pg_class"` most definately not `"PG_CLASS"` although `PG_CLASS` is usually acceptable, quote marks make uppser case significant and I don't completely trust the hybernate developers not to obfuscate the error message by adding spurious quote-marks to the table name. There should be a matching error in the postgres server log. will you add that to the question please. – Jasen Dec 30 '14 at 09:27
  • 1
    @Jasen thank's a lot! I change my hibernate property file from hibernate.hbm2ddl.auto = "update" to "create" and it help me – Klimov Peter Dec 30 '14 at 19:59
  • if this issue is resolved pleas post your solution here (as an answer.) in a week you will ba able to accept that answer and this question qill be marked as solved. – Jasen Dec 30 '14 at 20:32
  • 1
    You are clearly using H2, not Postgres. H2 does not have a table named `pg_class` –  Dec 31 '14 at 12:31
  • I've received he same error when dialect was set to PostgreSQL9Dialect. After change to H2Dialect works properly. – TOUDIdel Mar 19 '19 at 10:43

6 Answers6

11

I just changed the hibernate property hibernate.hbm2ddl.auto to create. This resolved the issue for me.

kc2001
  • 5,008
  • 4
  • 51
  • 92
Klimov Peter
  • 308
  • 1
  • 2
  • 12
8

Had the same error recently. Please open your wildfly's standalone.xml (or standalone-full.xml or whichever you are using) and find and delete the following fragment:

<default-bindings contextservice="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/ExampleDS" jms-connection factory="java:jboss/DefaultJMSConnectionFactory" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>

Important: Make sure to shut wildfly down before editing, otherwise it will overwrite the changes the next time it shuts down.

Toastor
  • 8,980
  • 4
  • 50
  • 82
  • Good Question! To be honest - I'm not sure. It seems like this default DS is partially overriding the db connection settings of the deployments on this application server. I didn't dig into it further however once I got it working... – Toastor Aug 01 '17 at 19:08
  • 1
    This same error occurs when you're migrating an application from H2 to PostgreSQL and you forget to update ALL your connection strings. – Alex R Nov 11 '18 at 18:00
  • I can not confirm that this solves the problem. In case you experience the same have a look at my answer below (inconsistency with static metamodel). – r-uu Jan 26 '22 at 10:59
4

You need this property spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

Paul Hilliar
  • 579
  • 6
  • 8
0

1) check if you are using correct dialect in application.properties

spring.jpa.database-platform

2) and check the value of spring.jpa.hibernate.ddl-auto

0

spring.jpa.database-platform solved my problem

0

I saw this exception when I also had an inconsistency with my entity and persistence metamodel classes (e.g. Customer_.java). That inconsistency was also reported by wildfly. It disappeared when I resolved that inconsistencies.

r-uu
  • 423
  • 1
  • 4
  • 18