3 Replies Latest reply on Jun 4, 2010 7:21 AM by narcis eugen

    NPE instantiating entityManagerFactor

    Dave Ellery Newbie

      darn,


      So i have just finally finished designing my DB and moving to develop the front end, so I used to current setup to generate my seam project


      Seam: 2.1.2.CR1
      Jboss 4.2.4
      Jboss Tools 3.0
      DB postgresSQL 8.3


      I get the following when deploying to jboss


      22:33:42,796 ERROR [[/surge]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: entityManagerFactory
           at org.jboss.seam.Component.newInstance(Component.java:2144)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:113)
           at org.jboss.seam.init.Initialization.init(Initialization.java:736)
           at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36)
           at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
           at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
           at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
           at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
           at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
           at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
           at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
           at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
           at org.jboss.web.WebModule.startModule(WebModule.java:83)
           at org.jboss.web.WebModule.startService(WebModule.java:61)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
           at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
           at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
           at $Proxy0.start(Unknown Source)
           at org.jboss.system.ServiceController.start(ServiceController.java:417)
           at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
           at $Proxy44.start(Unknown Source)
           at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
           at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
           at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
           at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
           at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
           at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
           at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
           at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
           at $Proxy45.start(Unknown Source)
           at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
           at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
           at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
           at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
           at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
           at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
           at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
           at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
           at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
           at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
           at $Proxy9.deploy(Unknown Source)
           at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
           at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
           at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
      Caused by: javax.persistence.PersistenceException: java.lang.NullPointerException
           at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:252)
           at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
           at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:85)
           at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2257)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
           at org.jboss.seam.Component.newInstance(Component.java:2132)
           ... 94 more
      Caused by: java.lang.NullPointerException
           at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:135)
           at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
           at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
           at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
           at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
           at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
           at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
           at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:183)
           at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:240)
           ... 107 more



      anyone have any idea's?


        • 1. Re: NPE instantiating entityManagerFactor
          Stuart Douglas Master

          Hibernate is failing to build the entity manager in OneToOneSecondPass.doSecondPass. Have a google or look at the source to see what that actually means. It probably means something is wrong with a OneToOne mapping.

          • 2. Re: NPE instantiating entityManagerFactor
            Dave Ellery Newbie

            yes well, after doing a lot of digging last night I never actually discovered what the issue was (mappings or otherwise)


            So I did figure out how to resolve the issue,


            originally when I generated the project I have set the package structure as


            com.project.entity/session


            so I regenerated it as


            com.domain.project.entity/session


            and to my surprise it worked perfectly.


            very strange indeed,


            I believe the NPE has been fixed(fails nicely) in a more up to date version of hibernate (3.3 and up)

            • 3. Re: NPE instantiating entityManagerFactor
              narcis eugen Newbie

              Hi,


              I have the same weird behavior and I cannot find a solution to this. The problem is that I do the database design in iterations.
              For each iteration we add one or more tables.


              What we do is for every iteration we generate the project skeleton using JBoss Tools and merge the new resources into the main project.


              Now we have reached a point where if we add just one new table with no relations to the old ones, and we generate all the artifacts and we copy just the entity class we have the exception from the first post on project startup.


              Basically what I want to do is, create a Target table to store the possible targets for Seam Identity Management, for user permission.


              The generate class looks like this :



              //Generated Mar 22, 2010 5:26:50 PM by Hibernate Tools 3.2.4.GA
              
              import javax.persistence.*;
              
              import org.hibernate.validator.NotNull;
              
              /**
               * Target generated by hbm2java
               */
              @Entity
              @Table(name = "TARGET")
              public class Target implements java.io.Serializable {
              
                   private String nume;
              
                   public Target() {
                   }
              
                   public Target(String nume) {
                        this.nume = nume;
                   }
              
                   @Id
                   @Column(name = "NUME", unique = true, nullable = false)
                   @NotNull
                   public String getNume() {
                        return this.nume;
                   }
              
                   public void setNume(String nume) {
                        this.nume = nume;
                   }
              
              }





              The target table only has one varchar column that is also PK. I gave up the foreign key from user_permission table.


              Anybody has any idea how to solve this ?


              Thanks,
              Narcis