title: java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory
body: <p>I have Eclipse Indigo that I use to develop a JSF 2 project using Glassfish 3 Open Source, this in my computer then in my EC2 instance too, in Amazon AWS, for both Glassfish's I created a JDBC Connection Pool to use with my JPA Entity Manager. </p>
  
  <p>Locally my project works pretty fine, but when I deploy the project and try to execute the same form, which gets some values from the database that is running in the same instance EC2 that is running the GlassFIsh tough.</p>
  
  <p>I receive this message:</p>
  
  <p><img src="https://i.stack.imgur.com/GydCt.jpg" alt="enter image description here"></p>
  
  <p><strong>serverError: class javax.faces.el.EvaluationException</strong></p>
  
  <p>I'm searching about it, but I don't found anything so far.</p>
  
  <p>There's some configuration that I shoud do for it works ?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here's the stacktrace:</p>
  
  <pre><code>javax.faces.FacesException: #{reportc.generateReport}: javax.ejb.EJBException
          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:636)
  Caused by: javax.faces.el.EvaluationException: javax.ejb.EJBException
          at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
          at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
          ... 32 more
  Caused by: javax.ejb.EJBException
          at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5193)
          at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5091)
          at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
          at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
          at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
          at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
          at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
          at $Proxy225.listLastMinutes(Unknown Source)
          at com.brainset.eao.__EJB31_Generated__LogEAO__Intf____Bean__.listLastMinutes(Unknown Source)
          at com.brainset.controller.ReportControl.getLog(ReportControl.java:234)
          at com.brainset.controller.ReportControl.generateReport(ReportControl.java:49)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:616)
          at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
          at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
          at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
          at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
          ... 33 more
  Caused by: java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory.
          at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.verifyOpen(EntityManagerFactoryDelegate.java:305)
          at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:276)
  </code></pre>
  
  <p><strong>EDIT 2:</strong>
  This is how I'm using the EntityManager:</p>
  
  <pre><code>@Stateless(mappedName = "logEAO")
  @LocalBean
  public class LogEAO {
      @PersistenceContext
      private EntityManager em;
  
      public LogEAO() {}
  
  
      public Log find(int id) {
          return em.find(Log.class, id);
      }
      // .. 
  </code></pre>