4 Replies Latest reply on Jan 30, 2013 8:50 AM by Scott Marlow

    ORA-00942 errors upon deploying an app with hibernate

    Dominik Grupp Newbie

      In our project we are having an issue with error messages,

      which can't be explained and which potentially is a JBoss configuration

      issue.

       

      1.) On deployment with hibernate on AS 7.1.1 the log does

      contain the below error messages but does create the tables.

      Where do the error messages come from? The answer to this question

      is important to us since the client is thinking about using JBoss in future.

      2.) When trying to use eclipselink no table at all is created

      on the oracle db. We created the module for eclipselink according to

      https://community.jboss.org/wiki/HowToUseEclipseLinkWithAS7. The code,

      however, seems to be ok since with Glassfish the table is created in the db.

      Why are the tables not created with JBoss?

       

      I tried to create a small app (maven) to reproduce the problem and do attach it to this post.

      For both questions here I attached the logfile and persistence.xml as well.

        • 1. Re: ORA-00942 errors upon deploying an app with hibernate
          Dominik Grupp Newbie

          update part 1)

           

          I slightly modified the application and added another entity along with

          two derby schemas each one of them being assigned one of the entities

          via persistence.xml. The errors are still shown during deployment.

           

          Any ideas? Help much appreciated!!!

           

          Are those errors possibly "normal" due to the logging? I do attach the updated logfile to this posting.

           

          Here is my persistence.xml

           

              <persistence-unit name="LogService">
                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
                  <jta-data-source>ds_log</jta-data-source>
                  <class>de.org.grp.domain.Customer</class>
                  <exclude-unlisted-classes>true</exclude-unlisted-classes>
                  <properties>
                      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                      <property name="hibernate.show_sql" value="true"/>
                      <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>
                      <property name="hibernate.format_sql" value="true"/>
                  </properties>
              </persistence-unit>
          
              <persistence-unit name="MessageService">
                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
                  <jta-data-source>ds_messages</jta-data-source>
                  <class>de.org.grp.domain.Book</class>
                  <exclude-unlisted-classes>true</exclude-unlisted-classes>
                  <properties>
                      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                      <property name="hibernate.show_sql" value="true"/>
                      <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>
                      <property name="hibernate.format_sql" value="true"/>
                  </properties>
              </persistence-unit>
          

           

          part 2.)

           

          I learned by trial and test that the tables etc. are created on derby only once

          they are really accessed (e.g. when persisting an entity) but not before.

           

          I am astonished, however, that the tables are only created once an entity is being

          persisted and not earlier. What if a select statement is first trying to be executed?

           

          Here is my persistence.xml

           

                 <persistence-unit name="LogService" transaction-type="JTA">
                      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
                      <jta-data-source>ds_log</jta-data-source>
                      <class>de.org.grp.domain.Customer</class>
                      <exclude-unlisted-classes>true</exclude-unlisted-classes>
                      <properties>
                          <property name="eclipselink.target-server" value="JBoss" />
                          <property name="eclipselink.target-database" value="Derby" />
                          <property name="eclipselink.logging.level" value="ALL" />
                          <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
                          <property name="eclipselink.ddl-generation.output-mode" value="both" />
                          <property name="eclipselink.debug" value="ALL" />
                          <property name="eclipselink.weaving" value="static" />
                          <property name="eclipselink.logging.level.sql" value="FINEST" />
                          <property name="eclipselink.logging.level.cache" value="FINEST" />
                      </properties>
                  </persistence-unit>
          
                  <persistence-unit name="MessageService" transaction-type="JTA">
                      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
                      <jta-data-source>ds_messages</jta-data-source>
                      <class>de.org.grp.domain.Book</class>
                      <exclude-unlisted-classes>true</exclude-unlisted-classes>
                      <properties>
                          <property name="eclipselink.target-server" value="JBoss" />
                          <property name="eclipselink.target-database" value="Derby" />
                          <property name="eclipselink.logging.level" value="ALL" />
                          <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
                          <property name="eclipselink.ddl-generation.output-mode" value="both" />
                          <property name="eclipselink.debug" value="ALL" />
                          <property name="eclipselink.weaving" value="static" />
                          <property name="eclipselink.logging.level.sql" value="FINEST" />
                          <property name="eclipselink.logging.level.cache" value="FINEST" />
                      </properties>
                  </persistence-unit>
          

           

          and the datasource configuration in jboss 7 which applies for both problem 1 and 2

           

                 <subsystem xmlns="urn:jboss:domain:datasources:1.0">
                      <datasources>
                          <datasource jta="true" jndi-name="java:/ds_log" pool-name="derbyDSLog" enabled="true" use-java-context="true" use-ccm="true">
                              <connection-url>jdbc:derby://localhost:1527/ATestDB</connection-url>
                              <driver>derby</driver>
                              <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                              <pool>
                                  <prefill>true</prefill>
                                  <use-strict-min>false</use-strict-min>
                                  <flush-strategy>FailingConnectionOnly</flush-strategy>
                              </pool>
                              <security>
                                  <user-name>log</user-name>
                                  <password>log</password>
                              </security>
                          </datasource>
                          <datasource jta="true" jndi-name="java:/ds_messages" pool-name="derbyDSMessages" enabled="true" use-java-context="true" use-ccm="true">
                              <connection-url>jdbc:derby://localhost:1527/ATestDB</connection-url>
                              <driver>derby</driver>
                              <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                              <pool>
                                  <prefill>true</prefill>
                                  <use-strict-min>false</use-strict-min>
                                  <flush-strategy>FailingConnectionOnly</flush-strategy>
                              </pool>
                              <security>
                                  <user-name>messages</user-name>
                                  <password>messages</password>
                              </security>
                          </datasource>
                          <drivers> 
                              <driver name="derby" module="org.apache.derby">
                                  <driver-class>org.apache.derby.jdbc.ClientDriver</driver-class>
                              </driver>
                          </drivers>
                      </datasources>
                  </subsystem>
          
          • 2. Re: ORA-00942 errors upon deploying an app with hibernate
            Scott Marlow Master

            The ORA-00942 is minor, the attempt to drop the tables is failing because they don't yet exist in the database.  You could create the database tables manually and avoid the ORA-00942.

             

            I couldn't look at the source zip for some reason. 

            • 3. Re: ORA-00942 errors upon deploying an app with hibernate
              Dominik Grupp Newbie

              I tried again and first created the tables manually with

               

              create table Book (id bigint not null, title varchar(255), primary key (id) );
              create table Customer (id bigint not null, name varchar(255), salary bigint, primary key (id) );
              create table ID_CUSTOMER ( GEN_NAME varchar(255) not null , GEN_VAL bigint, primary key ( GEN_NAME ) ) ;
              create sequence hibernate_sequence start with 1 increment by 1;
              

               

              Now when deploying the first time, then the error messages do not appear anymore (see attached file HibernateLogEmptyTables.txt)

              apart from the error message about the hibernate sequence which was already reported (https://issues.jboss.org/browse/AS7-3860).

              However, for each redeployment the error messages do appear again (see attached file HibernateLog.txt).

               

              Possibly the error messages are due to the usage of "create-drop" for "hibernate.hbm2ddl.auto"

              since when using "create" the error messages disappear, as well when redeploying. It seems that "create-drop" really

              is a "drop-create-drop". So for a new deployment the first drop finds an empty schema and reports

              it appropriately. Could that be the cause?

               

              I read the documentation (http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-optional)

              and some google results but couldn't fully understand. It seems to be specific to hibernate since when using

              eclipselink along with derby that problem does not appear.

               

              hm, I could download and use the previous zip but I do attach the updated LogMessages.zip

              to this post again. You probably won't even need to use it to find the answers to my questions.

              • 4. Re: ORA-00942 errors upon deploying an app with hibernate
                Scott Marlow Master

                hibernate.hbm2ddl.auto works pretty well for tests, if that is what you need.  For deploying applications that need a set of database tables that will be there forever, you could manually create the tables.  Or, you could use the "create" once and take the "hibernate.hbm2ddl.auto" out of persistence.xml. 

                 

                If your application has multiple persistence unit definitions in the persistence.xml(s), they do get processed in parallel, meaning that any common base table referenced from multiple persistence units, could go throught the hibernate.hbm2ddl.auto code multiple times.  In other words, multiple Java threads (creating the entity manager factory) could be trying to create the same base table.

                 

                If you want to make improvements to hibernate.hbm2ddl.auto (via a code change/patch), checkout the "community" link on the hibernate project page at www.hibernate.org.

                 

                The next version of JPA (2.1), will introduce schema generation support.  That should help standardize how applications create their database tables during startup. 

                1 of 1 people found this helpful