3 Replies Latest reply on Sep 24, 2008 1:25 PM by Andrew DePue

    NullPointerException in latest svn version

    Andrew DePue Newbie

      I just built envers from the latest svn, and am getting a NullPointerException when using it in my own project.. note that the latest downloaded beta does not give this exception. Also note that envers passed all its tests.
      I can see why the NullPointerException is happening, but I am not yet familiar enough with Envers source to know what to make of it. Here is the stack trace:

      Caused by: java.lang.NullPointerException
       at org.jboss.envers.configuration.metadata.BasicMetadataGenerator.addComponent(BasicMetadataGenerator.java:132)
       at org.jboss.envers.configuration.metadata.BasicMetadataGenerator.addBasic(BasicMetadataGenerator.java:24)
       at org.jboss.envers.configuration.metadata.CollectionMetadataGenerator.addValueToMiddleTable(CollectionMetadataGenerator.java:308)
       at org.jboss.envers.configuration.metadata.CollectionMetadataGenerator.addWithMiddleTable(CollectionMetadataGenerator.java:225)
       at org.jboss.envers.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:99)
       at org.jboss.envers.configuration.metadata.VersionsMetadataGenerator.addValue(VersionsMetadataGenerator.java:148)
       at org.jboss.envers.configuration.metadata.VersionsMetadataGenerator.addProperties(VersionsMetadataGenerator.java:170)
       at org.jboss.envers.configuration.metadata.VersionsMetadataGenerator.generateSecondPass(VersionsMetadataGenerator.java:341)
       at org.jboss.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:93)
       at org.jboss.envers.configuration.VersionsConfiguration.<init>(VersionsConfiguration.java:80)
       at org.jboss.envers.configuration.VersionsConfiguration.getFor(VersionsConfiguration.java:93)
       at org.jboss.envers.event.VersionsEventListener.initialize(VersionsEventListener.java:192)
       at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:417)
       at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1310)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
       at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
       at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
       at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
       at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
       at ... (you get the idea)


      addValueToMiddleTable(...) is invoking BasicMetadataGenerator.addBasic, and the source line is hard coded to pass in null for the 'mapper' parameter, which gets propagated to addComponent. btw, it appears to be working on an @Embedded component, which is itself mapped via @CollectionOfElements. The parent entity maps it like so:

      @CollectionOfElements(fetch= FetchType.EAGER)
       @JoinTable(name="h_type_allowed_child", joinColumns = @JoinColumn(name="parent_type"))
       @IndexColumn(name="pos")
       @Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
       public List<AllowedChildElement> getAllowedChildTypes()


      The actual element has four properties: two integer, one string, and one @ManyToOne mapped like so:
      @ManyToOne(targetEntity=HRecordTypeImpl.class)
       @JoinColumn(name="child_type")
       @Index(name="idx_ace_child_type")
       public HRecordType<?> getAllowedChild()


      It's no problem if Envers does not yet support this - it would just be nice if it failed in a more elegant way. :)