title: How do I find what persistence.xml is active
body: <p>I have inherited a maven based project that was created with Netbeans 7.4. I have configured a local Glassfish 3.1.2.2 in the servers tab, set up JDBC connection pools and resources and can debug the project correctly.
  However, I created 2 more tables in one of the connected databases, and let Netbeans generate 2 new entities from the Database schema. The entities are generated correctly, but when I start using them and start a debug session on the glassfish server I can see error messages being logged saying that the entities are not declared in the persistence unit.</p>
  
  <p>I am trying to find what persistence.xml is being used, but although I find a lot of old ones inside the project structure (that I didn't create myself and I don't have contact with the authors) I cannot find any that seems to be the one being used. Hibernate only refers to the Persistence Unit name, not to the path of the file being used.</p>
  
  <p>I am new to Java Persistence, so I am a bit confused. Can anybody suggest how I find, or recreate, the persistence.xml file?</p>
  
  <p>EDIT: Here is the stack trace:</p>
  
  <pre><code>INFO: HHH000412: Hibernate Core {4.2.6.Final}
  INFO: HHH000206: hibernate.properties not found
  INFO: HHH000021: Bytecode provider name : javassist
  INFO: HHH000204: Processing PersistenceUnitInfo [
      name: core_rw_pu_hibernate
      ...]
  INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
  INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
  SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
  SEVERE: Exception while preparing the app
  SEVERE: [PersistenceUnit: core_rw_pu_hibernate] Unable to build EntityManagerFactory
  javax.persistence.PersistenceException: [PersistenceUnit: core_rw_pu_hibernate] Unable to build EntityManagerFactory
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
      at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:206)
      at org.glassfish.persistence.jpa.PersistenceUnitLoader.&lt;init&gt;(PersistenceUnitLoader.java:120)
      at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:224)
      at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:495)
      at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:233)
      at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
      at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
      at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
      at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
      at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
      at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:744)
  Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.acme.ee.domain.entity.DeviceEntity.deviceInOuts[com.acme.ee.domain.entity.DeviceInOuts]
      at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1059)
      at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:733)
      at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:668)
      at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:69)
      at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1632)
      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1390)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1777)
      at org.hibernate.ejb.EntityManagerFactoryImpl.&lt;init&gt;(EntityManagerFactoryImpl.java:96)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
      ... 38 more
  </code></pre>