问题描述
我的Eclipse靛蓝,我用它来开发这个在我的电脑,然后在我的EC2实例也是如此,在亚马逊AWS,为GlassFish的我创建了一个JDBC连接池与使用JSF 2项目中使用Glassfish的3开源,我JPA实体管理器。
本地我的项目工程pretty的很好,但是当我部署的项目,并尝试执行相同的形式,它从一个在正在运行的GlassFish硬朗的同一个实例EC2上运行的数据库中获取某些值。
我收到此消息:
SERVERERROR:类javax.faces.el.EvaluationException
我在寻找它,但我没有发现任何东西为止。
有一些配置,我768,16做它的工作原理?
编辑:
下面的堆栈跟踪:
javax.faces.FacesException:#{reportc.generateReport}:javax.ejb.EJBException异常
在com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
在javax.faces.component.UICommand.broadcast(UICommand.java:315)
在javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
在javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
在com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
在com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
在com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
在javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
在org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
在org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
在com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
在com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
在org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
在com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
在com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
在com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
在com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
在com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
在com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
在com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
在com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
在com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
在com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
在com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
在com.sun.grizzly.ContextTask.run(ContextTask.java:71)
在com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:532)
在com.sun.grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:513)
在java.lang.Thread.run(Thread.java:636)
致:javax.faces.el.EvaluationException:javax.ejb.EJBException异常
在javax.faces.component.MethodBindingMethodEx$p$pssionAdapter.invoke(MethodBindingMethodEx$p$pssionAdapter.java:102)
在com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 32更多
javax.ejb.EJBException异常:产生的原因
在com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5193)
在com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5091)
在com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
在com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
在com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
在com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
在com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
在$ Proxy225.listLastMinutes(来源不明)
在com.brainset.eao .__ EJB31_Generated__LogEAO__Intf ____豆__。listLastMinutes(来源不明)
在com.brainset.controller.ReportControl.getLog(ReportControl.java:234)
在com.brainset.controller.ReportControl.generateReport(ReportControl.java:49)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java:616)
在com.sun.el.parser.AstValue.invoke(AstValue.java:234)
在com.sun.el.MethodEx pressionImpl.invoke(MethodEx pressionImpl.java:297)
在com.sun.faces.facelets.el.TagMethodEx pression.invoke(TagMethodEx pression.java:105)
在javax.faces.component.MethodBindingMethodEx$p$pssionAdapter.invoke(MethodBindingMethodEx$p$pssionAdapter.java:88)
... 33更多
致:java.lang.IllegalStateException:试图在一个封闭的EntityManagerFactory执行操作。
在org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.verifyOpen(EntityManagerFactoryDelegate.java:305)
在org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:276)
编辑2:这就是我如何使用EntityManager:
@Stateless(mappedName =logEAO)
@LocalBean
公共类LogEAO {
@PersistenceContext
私人EntityManager的EM;
公共LogEAO(){}
公共日志中找到(INT ID){
返回em.find(Log.class,ID);
}
// ..
从您的堆栈跟踪:
这只能意味着你手动管理(与的EntityManager
)而不是的EntityManagerFactory
让容器中只是 @PersistenceContext
。
在的EntityManagerFactory
是intented要在Web应用程序的启动创建只有一次,在整个Web应用程序的生命周期重用和Web应用的停机关闭。它不应该被某处中途封闭或序列化并再用于下一个重启循环
既然你显然是针对Glassfish的,我会强烈建议你自己来管理它,而是让Glassfish的做的工作。你最终要简单得多EJB code没有所有的麻烦手动管理的事务。
参见:
- Best实践中获得的EntityManagerFactory 行使>
更新:您的EJB code看上去一切正常。这更可能是Glassfish的错误或配置错误:
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.
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.
I receive this message:
serverError: class javax.faces.el.EvaluationException
I'm searching about it, but I don't found anything so far.
There's some configuration that I shoud do for it works ?
EDIT:
Here's the stacktrace:
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)
EDIT 2:This is how I'm using the EntityManager:
@Stateless(mappedName = "logEAO")
@LocalBean
public class LogEAO {
@PersistenceContext
private EntityManager em;
public LogEAO() {}
public Log find(int id) {
return em.find(Log.class, id);
}
// ..
From your stacktrace:
Update: Your EJB code looks all right. This is more likely a Glassfish bug or misconfiguration:
- Make sure that your JTA datasource configuration is right
- Make sure that you're using a Glassfish version which doesn't have a redeployment bug
- This redeployment bug is fixed in 3.1.2 and 4.0
这篇关于java.lang.IllegalStateException:试图在一个封闭的EntityManagerFactory执行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!