无法完成架构更新: org.h2.jdbc.JdbcSQLException: 表 “PG_CLASS” 未找到;SQL 语句

2022-09-03 06:06:05

在openshift上部署应用程序时,我有下一个问题。我使用wildfly应用程序服务器和PostgreSQL cartrige。

在持久性中.xml我设置属性“hibernate.hbm2ddl.auto” value=“update”。在 org/main/postgresql 中的 wildfly 模块中,我看到 wildfly 使用 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]

我使用休眠作为JPA(休眠核心-4.3.6)。而且我认为这个问题与不同版本的Postgresql 9.2和9.3谁能解释一下如何在9.2 Postgres版本中更改休眠方言或在openshift上更改postgresql库模块?


答案 1

我刚刚将休眠属性更改为.这为我解决了这个问题。hibernate.hbm2ddl.autocreate


答案 2

最近有同样的错误。请打开wildefly的独立.xml(或独立完整.xml或您正在使用的任何一个),然后找到并删除以下片段:

<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"/>

重要提示:请确保在编辑前关闭 wildfly,否则它将在下次关闭时覆盖更改。


推荐