3 Replies Latest reply on Sep 26, 2005 1:06 PM by perfectionist

    PostgreSQL 8 and EJB3 and Hibernate

      I am having a problem getting EJB3 from AS 4.0.3RC2 to work with PostgreSQL database. Have been working on windows, linux and mac osx and all of them fail with the same message. It has to do with system_sequences. I have this code working with the built in hypersonic but when I make changes to the datasource configuration files it seems to work but fails on completing the schema update.

      Are there issues with Postgres?

      This is a snippet from the log file. If here are any more configuration information needed I can supply it. But I bet someone has seen this before and can tell me about the error.

      Thanks!

      ...
      14:15:43,094 INFO [SettingsFactory] Default entity-mode: pojo
      14:15:43,106 INFO [SessionFactoryImpl] building session factory
      14:15:46,811 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
      14:15:46,815 INFO [SchemaUpdate] Running hbm2ddl schema update
      14:15:46,815 INFO [SchemaUpdate] fetching database metadata
      14:15:46,853 ERROR [SchemaUpdate] could not get database metadata
      org.postgresql.util.PSQLException: ERROR: relation "system_sequences" does not exist
       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1499)
       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1284)
       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
       at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:429)
       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:334)
       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:233)
       at org.jboss.resource.adapter.jdbc.WrappedStatement.executeQuery(WrappedStatement.java:142)
       at org.hibernate.tool.hbm2ddl.DatabaseMetadata.initSequences(DatabaseMetadata.java:113)
       at org.hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.java:39)
       at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:132)
       at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:297)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1033)
       at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:439)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:272)
       at org.jboss.ejb3.Ejb3Deployment.initializeManagedEntityManagerFactory(Ejb3Deployment.java:476)
       at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:219)
      ...
      


        • 1. Re: PostgreSQL 8 and EJB3 and Hibernate
          chrismalan

          From "relation "system_sequences" does not exist" I get the idea that JBoss can't find the specified database. The good news is that 4.0.3RC2 and EJB3 work with Postgres 8. Here is my postgres-ds.xml:

          <datasources>
           <local-tx-datasource>
           <jndi-name>RSA</jndi-name>
           <connection-url>jdbc:postgresql://localhost:5432/RSA</connection-url>
           <driver-class>org.postgresql.Driver</driver-class>
           <user-name>postgres</user-name>
           <password>postgres</password>
           <!-- sql to call when connection is created
           <new-connection-sql>some arbitrary sql</new-connection-sql>
           -->
          
           <!-- sql to call on an existing pooled connection when it is obtained from pool
           <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
           -->
          
           <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
           <metadata>
           <type-mapping>PostgreSQL 7.2</type-mapping>
           </metadata>
           </local-tx-datasource>
          
          </datasources>


          I have postgresql-8.0-311.jdbc3.jar in JBOSS_HOME/server/default/lib This is in Windows XP

          This is the persistence.xml file:
          <?xml version="1.0" encoding="UTF-8"?>
          <entity-manager>
           <name>RSA</name>
           <provider>org.hibernate.ejb.HibernatePersistence</provider>
           <jta-data-source>java:/RSA</jta-data-source>
           <properties>
           <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
           <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
           <property name="hibernate.hbm2ddl.auto" value="update"/>
           </properties>
          </entity-manager>


          All pojos and session beans are in the same .ejb3 archive.

          The whole lot is in an .ear archive and this is application.xml:
          <?xml version="1.0" encoding="utf-8"?>
          <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
           <display-name>The name</display-name>
           <description>The description</description>
           <module>
           <ejb>rsa.ejb3</ejb>
           </module>
           <module>
           <web>
           <web-uri>rsa.war</web-uri>
           <context-root>rsa</context-root>
           </web>
           </module>
          </application>

          Good luck,

          • 2. Re: PostgreSQL 8 and EJB3 and Hibernate
            augustynr

            Hi,
            Did you resolve it? I am trying the same thing and would appreciate any pointers you may have.
            Thank,
            robert

            • 3. Re: PostgreSQL 8 and EJB3 and Hibernate

              Great! This worked for me. I had missed meta-data stuff in the datasource xml and provider and hibernate-dialect in the persistence.xml.

              Thanks for the code snippets!

              The application is now up and running.