1 2 Previous Next 15 Replies Latest reply: Mar 15, 2012 9:57 AM by Mark Kempster RSS

    Disabling envers in jboss 7.0.2 / hib 4?

    Mark Kempster Newbie

      I'm trying to deploy my application on as7.0.2, and am trying to do it without envers support. In my persistence.xml, I ask hibernate to validate the schema, like so

       

      <property name="hibernate.hbm2ddl.auto" value="validate"/>

       

      When that happens, envers gets included in the schema-validation phase and fails since I don't have a REVINFO table defined.

       

      Is there some way that I can force my application to validate against the database, but not envers?

       

      I can remove the hbm2ddl.auto property and have my war deploy, but then I'm without a sanity check for my application code. I haven't gotten anywhere with a WEB-INF/jboss-deployment-structure.xml like so (which was a shot in the dark)

       

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

                <deployment>

          <exclusions>

            <module name="org.hibernate.envers"/>

          </exclusions>

                </deployment>

      </jboss-deployment-structure>

       

      Is there a way around this, or am I stuck with (1) no-validation or (2) create a dummy REVINFO table?

       

      Thanks for your help!

      Mark

        • 1. Re: Disabling envers in jboss 7.0.2 / hib 4?
          Adam Warski Master

          But you do have classes annotated with @Audited? Because only then Envers should get activated.


          Adam

          • 2. Re: Disabling envers in jboss 7.0.2 / hib 4?
            Mark Kempster Newbie

            I don't have any @Audited classes in my war, and the old-style envers config is absent from persistence.xml.

             

            Mark

            • 3. Re: Disabling envers in jboss 7.0.2 / hib 4?
              Henrik Huttunen Newbie

              We have the same problem. We have no need for Envers, neither do we use any @Audited annotations. Is there other solution other than to downgrade to 7.0.1 or not use validate...?

              • 4. Re: Disabling envers in jboss 7.0.2 / hib 4?
                Adam Warski Master

                That's quire weird. Can you try breakpointing at org.hibernate.envers.configuration.EntitiesConfigurator:128:

                 

                if (classesAuditingData.getAllClassAuditedData().size() > 0) {

                 

                to see what are the audited entities?

                 

                Adam

                • 5. Re: Disabling envers in jboss 7.0.2 / hib 4?
                  jaikiran pai Master

                  Also please post that stacktrace about the missing table. That might give us a clue on what triggers Envers.

                  • 6. Re: Disabling envers in jboss 7.0.2 / hib 4?
                    Henrik Huttunen Newbie

                    12:35:26,341 INFO  [java.sql.DatabaseMetaData] (MSC service thread 1-8) HHH00262:Table not found: REVINFO

                    12:35:26,344 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.persistenceunit."foobar.war#primary": org.jboss.msc.service.StartException in s

                    ervice jboss.persistenceunit."foobar.war#primary": Failed to start service

                            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1780) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

                            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_13]

                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_13]

                            at java.lang.Thread.run(Thread.java:619) [:1.6.0_13]

                    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: primary] Unable to build EntityManagerFactory

                            at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:908)

                            at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:884)

                            at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)

                            at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:143)

                            at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:77)

                            at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

                            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

                            ... 3 more

                    Caused by: org.hibernate.HibernateException: Missing table: REVINFO

                            at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1263)

                            at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)

                            at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:446)

                            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1722)

                            at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)

                            at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)

                            ... 9 more

                    • 7. Re: Disabling envers in jboss 7.0.2 / hib 4?
                      Thyago Schleuss Newbie

                      Same here, my persistence.xml have only "validate" on "hibernate.hbm2ddl.auto" e i got the same exception

                       

                      aused by: org.hibernate.HibernateException: Missing table: REVINFO

                          at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1263)

                          at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)

                          at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:446)

                          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1722)

                          at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)

                          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)

                       

                      I'm use Jboss AS 7.0.2.Final with Hibernate 4, on a project

                      with Jboss Seam 3.1.0.Beta4

                       

                       

                      I don't have classes with @Audit, i'm try to use a existent database with a new aplication,

                      but hibernate try do force me to create this table, but i can't.

                      • 8. Re: Disabling envers in jboss 7.0.2 / hib 4?
                        Adam Warski Master

                        What about breakpointing at org.hibernate.envers.configuration.EntitiesConfigurator:128:

                         

                        if (classesAuditingData.getAllClassAuditedData().size() > 0) {

                         

                        and looking at what classes Envers thinks are audited?

                         

                        Adam

                        • 9. Re: Disabling envers in jboss 7.0.2 / hib 4?
                          Thyago Schleuss Newbie

                          Hi, thanks for fast reply.

                          I never had hibernate-envers dependecy on my project, but

                          i included her to debug. I saw, there's one of my classes that he catch:

                           

                          [org.hibernate.mapping.RootClass(br.com.tiny.model.entity.Question)=org.hibernate.envers.configuration.metadata.reader.ClassAuditingData@12ce7c6]

                          But my class Question, don't have anything that reffer Envers:

                          package br.com.tiny.model.entity;

                           

                          import java.math.BigDecimal;

                          import java.util.Date;

                           

                          import javax.persistence.Column;

                          import javax.persistence.Entity;

                          import javax.persistence.Id;

                          import javax.persistence.IdClass;

                          import javax.persistence.Table;

                          import javax.persistence.Temporal;

                          import javax.persistence.TemporalType;

                           

                          /**

                          * Entity of questions

                          * @since 0.0.1

                          */

                          @Entity

                          @Table(name = "question")

                          @IdClass(QuestionPK.class)

                          public class Question extends AbstractEntity {

                           

                              /**

                               * Default serial.

                               */

                              private static final long serialVersionUID = 1L;

                           

                              @Id

                              @Column(name = "id_transaction")

                              private Integer    idTransaction;

                           

                              @Id

                              @Column(name = "nr_seq")

                              private Integer nrSeq;

                           

                              @Column(name = "fl_accepted")

                              private Integer flAccepted;

                           

                              @Column(name = "dt_access")

                              @Temporal(TemporalType.TIMESTAMP)

                              private Date     accessDate;

                           

                              /**

                               * Default constructor.

                               */

                              public Question() {

                                  super();

                              }

                           

                              /** gets and sets and hashcode and equals impl **/

                          }

                           

                          Its a simple entity with compose-id.

                          what could be?

                          • 10. Re: Disabling envers in jboss 7.0.2 / hib 4?
                            Thyago Schleuss Newbie

                            I debuger a little longer here, maybe i'm wrong, but in this method on hibernate-envers project:

                            private void addAuditTable(XClass clazz) {

                                AuditTable auditTable = clazz.getAnnotation(AuditTable.class);

                                if (auditTable != null) {

                                    auditData.setAuditTable(auditTable);

                                } else {

                                    auditData.setAuditTable(getDefaultAuditTable());

                                }

                            }

                            it will be always get as an audit table.

                            and with this, it will always enter on this method:

                            public void addClassAuditingData(PersistentClass pc, ClassAuditingData cad) {

                                entityNameToAuditingData.put(pc.getEntityName(), cad);

                                persistentClassToAuditingData.put(pc, cad);

                            }

                            Finally, the method

                            classesAuditingData.getAllClassAuditedData()

                            caled on EntitiesConfigurator will always return

                            this class. I have only this entity on projet now, but

                            iguess if you add another, shall all be considered.

                            • 11. Re: Disabling envers in jboss 7.0.2 / hib 4?
                              Stian Thorgersen Novice

                              I had the same issue with an app that uses Hibernate directly (no JPA yet), I solved the problem by adding the property "hibernate.listeners.envers.autoRegister=false" to my hibernate.cfg.xml. Not sure if it will work with JPA, but worth a try.

                              • 12. Re: Disabling envers in jboss 7.0.2 / hib 4?
                                Adam Warski Master

                                Yes, this should work with JPA as well. A very good workaround

                                 

                                Adam

                                • 13. Re: Disabling envers in jboss 7.0.2 / hib 4?
                                  Adam Warski Master

                                  I found the cause and I'll commit a fix shortly, see https://hibernate.onjira.com/browse/HHH-6784.

                                   

                                  I'm very sorry for the trouble this caused and thanks a lot for debugging the problem!

                                   

                                  Adam

                                  • 14. Re: Disabling envers in jboss 7.0.2 / hib 4?
                                    Thyago Schleuss Newbie

                                    Thanks for the fix !!

                                    I am not the author of this topic, but to me he's answered!

                                    1 2 Previous Next