6 Replies Latest reply on Jan 13, 2009 5:44 AM by Adam Warski

    NPE on initialization

    Eike Hirsch Newbie

      Hi all,

      I am trying to switch a project to envers. I have annotated all classes as audited and checked the "is not supported" stuff. When starting up I get an NPE.

      2009-01-09 16:46:11.872::WARN: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not init listeners:
      java.lang.NullPointerException
       at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addValueToMiddleTable(CollectionMetadataGenerator.java:380)
       at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addWithMiddleTable(CollectionMetadataGenerator.java:303)
       at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:152)
       at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:136)
       at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:155)
       at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateSecondPass(AuditMetadataGenerator.java:343)
       at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:96)
       at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
       at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
       at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:232)
       at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
       at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
       at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
       at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1338)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
       at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
       at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
       at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
       at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
       at java.security.AccessController.doPrivileged(Native Method)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
       at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
       at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
       at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
       at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
       at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
       at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
       at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
       at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
       at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:530)
       at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
       at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
       at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
       at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
       at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
       at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
       at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161)
       at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
       at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:147)
       at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
       at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
       at org.mortbay.jetty.Server.doStart(Server.java:220)
       at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
       at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
       at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:345)
       at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:286)
       at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:204)
       at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:183)
       at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:579)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:498)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmentForProject(DefaultLifecycleExecutor.java:265)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:191)
       at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:149)
       at org.apache.maven.DefaultMaven.execute_aroundBody0(DefaultMaven.java:223)
       at org.apache.maven.DefaultMaven.execute_aroundBody1$advice(DefaultMaven.java:304)
       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:1)
       at org.apache.maven.embedder.MavenEmbedder.execute_aroundBody2(MavenEmbedder.java:904)
       at org.apache.maven.embedder.MavenEmbedder.execute_aroundBody3$advice(MavenEmbedder.java:304)
       at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:1)
       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:176)
       at org.apache.maven.cli.MavenCli.main(MavenCli.java:63)
       at org.apache.maven.cli.MavenCli.main(MavenCli.java:52)
      


      I guess this was not the best way to do the switch...

      Can anybody point me into the right direction? I really don't know where to start looking.

      I'm using the 3.4-Preview.

      thanx
      Eike