title: No [EntityType] was found for the key class [...] in the Metamodel
body: <p><strong>Entity:</strong>  </p>
  
  <pre><code>@Entity
  @Table(name="user_account")
  public class UserAccount implements Serializable{
      private static final long serialVersionUID = -2606506548742732094L;
  
      @Id
      @GeneratedValue(strategy=GenerationType.TABLE)
      private Integer id;
  </code></pre>
  
  <p><strong>persistence.xml</strong></p>
  
  <pre><code>&lt;persistence-unit name="Maze" transaction-type="RESOURCE_LOCAL"&gt;
  
      &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
      &lt;properties&gt;
          &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/&gt;
          &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/mazedb"/&gt;
          &lt;property name="javax.persistence.jdbc.user" value="root"/&gt;
          &lt;property name="javax.persistence.jdbc.password" value="root"/&gt;
      &lt;/properties&gt;
  
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p><strong>The error</strong></p>
  
  <pre><code>WARNING: #{accountController.performLogin}: java.lang.IllegalArgumentException: No [EntityType] was found for the key class [com.maze.model.UserAccount] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific &lt;class&gt;com.maze.model.UserAccount&lt;/class&gt; property or a global &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt; element.
  javax.faces.FacesException: #{accountController.performLogin}: java.lang.IllegalArgumentException: No [EntityType] was found for the key class [com.maze.model.UserAccount] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific &lt;class&gt;com.maze.model.UserAccount&lt;/class&gt; property or a global &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt; element.
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
      at javax.faces.component.UICommand.broadcast(UICommand.java:315)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
      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:662)
  </code></pre>
  
  <p><strong>Behaviour</strong>
  Every time I restart the Web Container everything works just fine for a couple of minutes and than this error gets thrown. What am I missing?</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>Now I use an entity on the application scope as well and the same error occurs for the Country Entity. Both User and Country are defined as classes in the persistance.xml. Furthermore the exclude-unlisted-classes is set to false.</p>
  
  <pre><code>SEVERE: Critical error during deployment: 
  java.lang.ExceptionInInitializerError
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at     sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39    )
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  at java.lang.Class.newInstance0(Class.java:355)
  at java.lang.Class.newInstance(Class.java:308)
  at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188)
  at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102)
  at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
  at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
  at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:256)
  at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:255)
  at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4750)
  at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:550)
  at org.apache.catalina.core.StandardContext.start(StandardContext.java:5366)
  at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
  at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2000)
  at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)
  at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
  at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
  at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
  at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
  at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
  at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
  at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
  at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
  at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
  at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
  at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
  at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
  at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
  at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
  at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
  at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
  at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
  at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
  at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
  at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
  at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
  at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
  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:662)
  Caused by: java.lang.IllegalArgumentException: No [EntityType] was found for the key class [com.maze.model.Country] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific &lt;class&gt;com.maze.model.Country&lt;/class&gt; property or a global &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt; element.
  at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entityEmbeddableManagedTypeNotFound(MetamodelImpl.java:174)
  at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entity(MetamodelImpl.java:194)
  at org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl.from(AbstractQueryImpl.java:97)
  at com.maze.service.CountryService.readList(CountryService.java:74)
  at com.maze.util.MazeConstants.&lt;clinit&gt;(MazeConstants.java:26)
  </code></pre>
  
  <p>The Country entity:</p>
  
  <pre><code>@Entity
  @Table(name = "country")
  public class Country implements Serializable{
  
  private static final long serialVersionUID = 4086034429815316972L;
  
  @Id
  private Integer id;
  private String name;
  private String continent;
  private Integer population;
  private Float surface;
  
  @OneToMany(mappedBy = "country")
  private List&lt;User&gt; userList;
  </code></pre>
  
  <p>Now that this entity is used on application scope and the Entity throws this error the Glassfish fails to start completely.</p>
  
  <p><strong>SECOND EDIT :</strong>
  Based on the current behavior it seems that the web container starts and works fine until the first hot deployment.</p>