2 Replies Latest reply on Aug 26, 2009 4:47 AM by Henki Lubis

    Unable to build EntityManagerFactory

    Henki Lubis Newbie

      Hi all, Im using seam 2.1.1 GA with Jboss 5.0.1 GA, and with condition my tables not generated yet.


      In my persistance.xml if i use



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



      and start my application, everything running well, but if i change to



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



      with the same condition my tables not generated yet, i got the following error




      09:39:55,348 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=aceagencyportal.ear/aceagencyportal.jar#aceagencyportal state=Create
      javax.persistence.PersistenceException: [PersistenceUnit: aceagencyportal] Unable to build EntityManagerFactory
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
           at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)
           at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301)
           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.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
           at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
           at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
           at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
           at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
           at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
           at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
           at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
           at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
           at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
           at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
           at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
           at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
           at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
           at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
           at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)
           at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
           at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
           at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
           at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
           at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
           at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
           at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:698)
           at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
           at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
           at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
           at org.jboss.Main.boot(Main.java:209)
           at org.jboss.Main$1.run(Main.java:547)
           at java.lang.Thread.run(Unknown Source)
      Caused by: org.hibernate.HibernateException: Missing table: agent
           at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1113)
           at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
           at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:349)
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
           at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
           ... 51 more



      Anybody know why this happened ?


        • 1. Re: Unable to build EntityManagerFactory
          Chris Simons Expert

          The exception is fairly clear, the agent table does not exist.


          Do you want the tables to populate based on your EJBs, or are you going to have them pre-created in the database itself?


          If the former, your <property name="hibernate.hbm2ddl.auto" value="update"/> property needs to read:


          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>


          Or just:


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


          Feel free to correct me if I have misunderstood your question.


          • 2. Re: Unable to build EntityManagerFactory
            Henki Lubis Newbie

            I also thought the agent table doesnt exist, but its not correct. This is what happaned when i ran it


            Condition 1:
            -Database still empty means no table generated and i want the hibernate create it for me
            -I use update value in persistance.xml
            - All tables generated and application running well


            Condition 2:
            -Database still empty means no table generated and i want the hibernate create it for me
            -I use validate value in persistance.xml
            - All tables generated including Agent Table but application got error as i mentioned.