Attempting to execute an operation on a closed EntityManager (OracleDB, ojdbc8)

Every few days, like today, again an “Attempting to execute an operation on a closed EntityManager”.

Am I the only one struggling with this? Four people are currently working on it (it’s supposed to be 60 again, like WebLogic), but this “Closed EntityManager” thing is killing me.

Shouldn’t Payara (Glassfish) make sure that doesn’t happen?

An excerpt of the exception:

java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManager.
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.verifyOpen(EntityManagerImpl.java:2067) ~[org.eclipse.persistence.jpa.jar:?]
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createNativeQuery(EntityManagerImpl.java:1300) ~[org.eclipse.persistence.jpa.jar:?]
	at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createNativeQuery(EntityManagerWrapper.java:560) ~[container-common.jar:?]
	at de.huss.component.abonnement.AboAdministrationImpl$1.getAboEntityLazyDataModel(AboAdministrationImpl.java:130) ~[business-persistence-impl-1.1-SNAPSHOT.jar:?]
	at de.huss.abo.application.controller.AboAdministrationControllerImpl.getLazyAboEntityList(AboAdministrationControllerImpl.java:428) ~[hussmediareloaded-abomodul-1.1-SNAPSHOT.jar:?]
	at de.huss.abo.application.controller.AboAdministrationControllerImpl$Proxy$_$$_WeldSubclass.getLazyAboEntityList$$super(Unknown Source) ~[hussmediareloaded-abomodul-1.1-SNAPSHOT.jar:?]
	at sun.reflect.GeneratedMethodAccessor3092.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_331]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_331]
	at org.jboss.weld.interceptor.proxy.TerminalAroundInvokeInvocationContext.proceedInternal(TerminalAroundInvokeInvocationContext.java:51) ~[weld-osgi-bundle.jar:?]
	at org.jboss.weld.interceptor.proxy.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:78) ~[weld-osgi-bundle.jar:?]
	at de.huss.commons.aspect.cache.SessionCacheAspect.lambda$action$2(SessionCacheAspect.java:54) ~[commons-1.1-SNAPSHOT.jar:?]
	at java.util.concurrent.ConcurrentSkipListMap.computeIfAbsent(ConcurrentSkipListMap.java:1699) [?:1.8.0_331]
	at de.huss.commons.aspect.cache.SessionCacheAspect.action(SessionCacheAspect.java:52) [commons-1.1-SNAPSHOT.jar:?]
	at sun.reflect.GeneratedMethodAccessor497.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_331]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_331]
	at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73) [weld-osgi-bundle.jar:?]
	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeAroundInvoke(InterceptorMethodHandler.java:84) [weld-osgi-bundle.jar:?]
	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:72) [weld-osgi-bundle.jar:?]
	at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:56) [weld-osgi-bundle.jar:?]
	at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:79) [weld-osgi-bundle.jar:?]
	at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:68) [weld-osgi-bundle.jar:?]
	at de.huss.abo.application.controller.AboAdministrationControllerImpl$Proxy$_$$_WeldSubclass.getLazyAboEntityList(Unknown Source) [hussmediareloaded-abomodul-1.1-SNAPSHOT.jar:?]
	at sun.reflect.GeneratedMethodAccessor2550.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_331]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_331]
	at javax.el.BeanELResolver.getValue(BeanELResolver.java:299) [jakarta.el.jar:3.0.3.payara-p5]
	at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:156) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:184) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.el.parser.AstValue.getValue(AstValue.java:114) [jakarta.el.jar:3.0.3.payara-p5]
	at com.sun.el.parser.AstValue.getValue(AstValue.java:177) [jakarta.el.jar:3.0.3.payara-p5]
	at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184) [jakarta.el.jar:3.0.3.payara-p5]
	at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-osgi-bundle.jar:?]
	at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:170) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:157) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIData.getValue(UIData.java:736) [jakarta.faces.jar:2.3.14.payara-p3]
	at org.primefaces.component.api.UIData.getDataModel(UIData.java:839) [primefaces-8.0.18.jar:8.0.18]
	at javax.faces.component.UIData.getRowCount(UIData.java:347) [jakarta.faces.jar:2.3.14.payara-p3]
	at org.primefaces.component.datatable.DataTableRenderer.encodeScript(DataTableRenderer.java:252) [primefaces-8.0.18.jar:8.0.18]
	at org.primefaces.component.datatable.DataTableRenderer.render(DataTableRenderer.java:99) [primefaces-8.0.18.jar:8.0.18]
	at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:89) [primefaces-8.0.18.jar:8.0.18]
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:595) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1654) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:615) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:159) [jakarta.faces.jar:2.3.14.payara-p3]
	at org.primefaces.component.api.UIData.visitTree(UIData.java:920) [primefaces-8.0.18.jar:8.0.18]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:150) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIForm.visitTree(UIForm.java:355) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:150) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:400) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:319) [jakarta.faces.jar:2.3.14.payara-p3]
	at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:57) [primefaces-8.0.18.jar:8.0.18]
	at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:228) [jakarta.faces.jar:2.3.14.payara-p3]
	at org.omnifaces.context.OmniPartialViewContext.processPartial(OmniPartialViewContext.java:124) [omnifaces-2.7.18.jar:2.7.18]
	at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1102) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1647) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:442) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132) [jakarta.faces.jar:2.3.14.payara-p3]
	at org.omnifaces.viewhandler.OmniViewHandler.renderView(OmniViewHandler.java:115) [omnifaces-2.7.18.jar:2.7.18]
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76) [jakarta.faces.jar:2.3.14.payara-p3]
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708) [jakarta.faces.jar:2.3.14.payara-p3]
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451) [jakarta.faces.jar:2.3.14.payara-p3]
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1637) [web-core.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:331) [web-core.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) [web-core.jar:?]
	at de.huss.merlin.filter.MDCFilter.doFilter(MDCFilter.java:38) [MDCFilter.class:?]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) [web-core.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) [web-core.jar:?]
	at org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:181) [omnifaces-2.7.18.jar:2.7.18]
	at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108) [omnifaces-2.7.18.jar:2.7.18]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) [web-core.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) [web-core.jar:?]
	at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:81) [primefaces-8.0.18.jar:8.0.18]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) [web-core.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) [web-core.jar:?]
	at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:282) [tyrus-container-servlet.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) [web-core.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) [web-core.jar:?]
	at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) [log4j-web-2.17.0.jar:2.17.0]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) [web-core.jar:?]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) [web-core.jar:?]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257) [web-core.jar:?]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) [web-core.jar:?]
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:757) [web-core.jar:?]
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:577) [web-core.jar:?]
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) [web-glue.jar:?]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:158) [web-core.jar:?]
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371) [web-core.jar:?]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238) [web-core.jar:?]
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520) [kernel.jar:?]
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217) [kernel.jar:?]
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569) [nucleus-grizzly-all.jar:?]
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549) [nucleus-grizzly-all.jar:?]
	at java.lang.Thread.run(Thread.java:750) [?:1.8.0_331]

The sample code:

                    Query countQuery = dataAccessObjectService.getEntityManager(
                                    DataAccessObjectService.PersistenceUnitType.DEFAULT_ENTITY)
                            .createNativeQuery("SELECT COUNT(*) FROM (" + queryString[0] + ")");
                    aboEntityMappingTypeList.forEach(type -> countQuery.setParameter(type.name(), valueMap.get(type)));
                    BigDecimal singleResult = (BigDecimal) countQuery
                            .setHint(QueryHints.ALLOW_NATIVE_SQL_QUERY, HintValues.TRUE)
                            .setHint(QueryHints.CACHE_STATMENT, HintValues.TRUE)
                            .setHint(QueryHints.QUERY_RESULTS_CACHE, HintValues.TRUE)
                            .getSingleResult();
                    int count = singleResult.intValue();

payara-resources.xml:

    <jdbc-connection-pool name="OracleHussodbPool"
                          res-type="javax.sql.XADataSource"
                          datasource-classname="oracle.jdbc.xa.client.OracleXADataSource"
                          pool-resize-quantity="2"
                          max-pool-size="64"
                          steady-pool-size="10"
                          idle-timeout-in-seconds="300"
                          max-wait-time-in-millis="5000"
                          is-isolation-level-guaranteed="true"
                          pooling="true"
                          is-connection-validation-required="true"
                          connection-validation-method="custom-validation"
                          validation-classname="org.glassfish.api.jdbc.validation.OracleConnectionValidation"
                          connection-leak-timeout-in-seconds="5"
                          statement-leak-timeout-in-seconds="5"
                          init-sql="SELECT 1 FROM DUAL">
        <property name="URL" value="jdbc:oracle:thin:@***"/>
        <property name="User" value="***"/>
        <property name="Password" value="***"/>
    </jdbc-connection-pool>

I once left this discussion because it doesn’t fit in there and may not get enough attention.

migration-from-weblogic-server-1

System:
Payara 5.2022.2
JavaEE 8.0.1
Windows 10 / Linux Debian
Java 1.8 JDK (Eclipse Foundation)
(org.glassfish-javax.faces) 2.3.9, Primefaces 8.18
EclipseLink, version: Eclipse Persistence Services - 2.7.9.payara-p1

Hi @StevenHachel,

I was unable to reproduce this issue with the information provided, If you can you provide a simple to follow scenario on how to reproduce this on the latest release of Payara Community Edition, I will gladly take a look into this issue.

Additionally, is an XADatasource is strictly necessary for your connection pool? Could a regular Datasource be used instead?

Thanks,
James

AFAIR this error message will appear if you call EntityManager.close() somewhere and after this you still use the EntityManager. I would make a search for the close()-Method in the source code first and remove it if it was found.

Cheers

Hello Aleks,

i use PersistenceContext.

Example:

@Stateless
public class DataAccessObjectServiceImpl implements DataAccessObjectService {

    @PersistenceContext(unitName = "hussodbPU")
    private EntityManager entityManager;

    @Override
    public <T> T getById(Class<T> entity, long id) {
        return entityManager.find(entity, id);
    }

    @Override
    public <T> T updateElement(T entity) {
        return entityManager.merge(entity);
    }

  ...

my code doesn’t close the EntityManager.

The code has been running in WebLogic for many years without problems, only under Glassfish there are problems. :frowning:

Hey James,

is it unusual to work with an XADataSource?

Edit:
I’ll switch to
datasource-classname="oracle.jdbc.pool.OracleConnectionPoolDataSource
and see how it behaves.

The Payara establishes a new connection after the error. It is also true that it is closed when not in use, but it would be good if a new connection was made available in a timely manner to avoid this error.
I have yet to find out why this isn’t happening.

Sorry if I annoy you with that!

Steven

Hi Steven,

It’s not unusual to work with an XADataSource however if you don’t need distributed transactions which the XADataSource provides, it is recommended to use a DataSource as this will reduce the complexity and therefore is less likely to cause problems within your application.

As Aleks stated this error normally occurs when you attempt to use a closed EntityManager however as you aren’t closing the EntityManager that can’t be the problem.

Without a way of reproducing this issue locally, it’s difficult to identify if there is a bug within Payara here, are there uncaught runtime exceptions you can observe in the logs before the IllegalStateException which could be causing the EntityManager to close?

Again, if you are able to provide a small reproducer application it would greatly help in identifying if there is a bug here in Payara.

Thanks,
James

1 Like

Hey,

i got such an ominous exception again. I can’t explain how this happens.
I can’t be the only one with this problem and why is it running on an ancient WebLogic 12.1 and with JavaEE6?
The code hasn’t changed…

I can’t get it reproduced in a simple example. I can’t reproduce it because I don’t see the problem.
I can’t switch to a productive/enterprise environment with payara :frowning:

i switched to
datasource-classname="oracle.jdbc.pool.OracleDataSource"

Exception:

java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManager.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.verifyOpen(EntityManagerImpl.java:2067) ~[org.eclipse.persistence.jpa.jar:?]
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createNativeQuery(EntityManagerImpl.java:1300) ~[org.eclipse.persistence.jpa.jar:?]
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createNativeQuery(EntityManagerWrapper.java:560) ~[container-common.jar:?]
at de.huss.component.abonnement.AboLeistungenAdministrationImpl$1.getAboEntityLazyDataModel(AboLeistungenAdministrationImpl.java:154) ~[business-persistence-impl-1.1-SNAPSHOT.jar:?]
at de.huss.abo.application.controller.AboLeistungenControllerImpl.getLazyAboLeistungenEntityList(AboLeistungenControllerImpl.java:200) ~[hussmediareloaded-abomodul-1.1-SNAPSHOT.jar:?]
at de.huss.abo.application.controller.AboLeistungenControllerImpl$Proxy$_$$WeldSubclass.getLazyAboLeistungenEntityList$$super(Unknown Source) ~[hussmediareloaded-abomodul-1.1-SNAPSHOT.jar:?]
at sun.reflect.GeneratedMethodAccessor3666.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_331]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_331]
at org.jboss.weld.interceptor.proxy.TerminalAroundInvokeInvocationContext.proceedInternal(TerminalAroundInvokeInvocationContext.java:51) ~[weld-osgi-bundle.jar:?]
at org.jboss.weld.interceptor.proxy.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:78) ~[weld-osgi-bundle.jar:?]
at de.huss.commons.aspect.cache.SessionCacheAspect.lambda$action$2(SessionCacheAspect.java:55) ~[commons-1.1-SNAPSHOT.jar:?]
at java.util.concurrent.ConcurrentSkipListMap.computeIfAbsent(ConcurrentSkipListMap.java:1699) ~[?:1.8.0_331]
at de.huss.commons.aspect.cache.SessionCacheAspect.action(SessionCacheAspect.java:53) ~[commons-1.1-SNAPSHOT.jar:?]
at sun.reflect.GeneratedMethodAccessor482.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_331]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_331]
at org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73) ~[weld-osgi-bundle.jar:?]
at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeAroundInvoke(InterceptorMethodHandler.java:84) ~[weld-osgi-bundle.jar:?]
at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:72) ~[weld-osgi-bundle.jar:?]
at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:56) ~[weld-osgi-bundle.jar:?]
at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:79) ~[weld-osgi-bundle.jar:?]
at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:68) ~[weld-osgi-bundle.jar:?]
at de.huss.abo.application.controller.AboLeistungenControllerImpl$Proxy$
$$_WeldSubclass.getLazyAboLeistungenEntityList(Unknown Source) ~[hussmediareloaded-abomodul-1.1-SNAPSHOT.jar:?]
at sun.reflect.GeneratedMethodAccessor3665.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_331]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_331]
at javax.el.BeanELResolver.getValue(BeanELResolver.java:299) ~[jakarta.el.jar:3.0.3.payara-p5]
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:156) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:184) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.el.parser.AstValue.getValue(AstValue.java:114) ~[jakarta.el.jar:3.0.3.payara-p5]
at com.sun.el.parser.AstValue.getValue(AstValue.java:177) ~[jakarta.el.jar:3.0.3.payara-p5]
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184) ~[jakarta.el.jar:3.0.3.payara-p5]
at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50) ~[weld-osgi-bundle.jar:?]
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:170) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:157) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIData.getValue(UIData.java:736) ~[jakarta.faces.jar:2.3.14.payara-p3]
at org.primefaces.component.api.UIData.getDataModel(UIData.java:620) ~[primefaces-11.0.7.jar:11.0.7]
at org.primefaces.component.datatable.DataTable.loadLazyScrollData(DataTable.java:493) ~[primefaces-11.0.7.jar:11.0.7]
at org.primefaces.component.datatable.DataTableRenderer.preRender(DataTableRenderer.java:117) ~[primefaces-11.0.7.jar:11.0.7]
at org.primefaces.component.datatable.DataTableRenderer.render(DataTableRenderer.java:96) ~[primefaces-11.0.7.jar:11.0.7]
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:89) ~[primefaces-11.0.7.jar:11.0.7]
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:595) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1654) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:615) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:159) ~[jakarta.faces.jar:2.3.14.payara-p3]
at org.primefaces.component.api.UIData.visitTree(UIData.java:701) ~[primefaces-11.0.7.jar:11.0.7]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:150) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIForm.visitTree(UIForm.java:355) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:150) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1468) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:400) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:319) ~[jakarta.faces.jar:2.3.14.payara-p3]
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:57) ~[primefaces-11.0.7.jar:11.0.7]
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:228) ~[jakarta.faces.jar:2.3.14.payara-p3]
at org.omnifaces.context.OmniPartialViewContext.processPartial(OmniPartialViewContext.java:122) ~[omnifaces-3.13.4.jar:3.13.4]
at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1102) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1647) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:442) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132) ~[jakarta.faces.jar:2.3.14.payara-p3]
at org.omnifaces.viewhandler.OmniViewHandler.renderView(OmniViewHandler.java:151) ~[omnifaces-3.13.4.jar:3.13.4]
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76) ~[jakarta.faces.jar:2.3.14.payara-p3]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708) ~[jakarta.faces.jar:2.3.14.payara-p3]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451) ~[jakarta.faces.jar:2.3.14.payara-p3]
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1637) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:331) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) ~[web-core.jar:?]
at de.huss.merlin.filter.MDCFilter.doFilter(MDCFilter.java:38) ~[MDCFilter.class:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) ~[web-core.jar:?]
at org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:183) ~[omnifaces-3.13.4.jar:3.13.4]
at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108) ~[omnifaces-3.13.4.jar:3.13.4]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) ~[web-core.jar:?]
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:81) ~[primefaces-11.0.7.jar:11.0.7]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) ~[web-core.jar:?]
at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:282) ~[tyrus-container-servlet.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) ~[web-core.jar:?]
at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) ~[log4j-web-2.17.2.jar:2.17.2]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211) ~[web-core.jar:?]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257) ~[web-core.jar:?]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) ~[web-core.jar:?]
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:757) ~[web-core.jar:?]
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:577) ~[web-core.jar:?]
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) ~[web-glue.jar:?]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:158) ~[web-core.jar:?]
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:372) ~[web-core.jar:?]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:239) ~[web-core.jar:?]
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520) ~[kernel.jar:?]
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217) ~[kernel.jar:?]
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:201) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549) ~[nucleus-grizzly-all.jar:?]
at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_331]

027: @Stateless
028: public class AboLeistungenAdministrationImpl implements Serializable
...
150: public LazyDataModel<AboleistungenEntity> getAboEntityLazyDataModel() {
152:     Query countQuery = dataAccessObjectService.getEntityManager(
153:                                       DataAccessObjectService.PersistenceUnitType.DEFAULT_ENTITY)
154:                                       .createNativeQuery("SELECT COUNT(*) FROM ABO");
       ...

Mhhhh, i guess, that the method dataAccessObjectService.getEntityManager returns a EntityManager, which is not initialized or it is closed.

Cheers

Yes, but what or who closes the entity manager at runtime (the system runs 24 hours a day) in between times? I do not understand that. Especially since this is only a snippet of code that was run through.
Before that, many other successful queries run before it gets to this point, which ONLY queries the COUNT and every other query works again. The entitymanger is probably reinitialized after this error… I can’t explain it any other way.

As described, that happens once or twice a week. Always another place… always in between. Code is executed. In one step 8 to 10 queries run through, then one, like in the example the count query, which runs into an exception and the following 8 to 10 queries run through without error. So in a queue of queries in between just close the EntiyManager? What is going wrong in the context?

Translated with DeepL Translate: The world's most accurate translator (free version)

Steven

Hello,

I seem to be the only one having this (still) problem?
Could it be that there is also a problem with Primefaces 11? Use the Primefaces LazyDataModel. I didn’t have this problem with Primefaces 8. Now can it be a combination of PF11, JavaEE8 and Payara? Or are there general problems with the OracleDB drivers?

steven

Is this a Payara bug, or why is the EntityManager simply closed in between and the next time it is called, data can be read from the database again?

Surely that can’t be normal behavior of a highly advertised high-performance container?
We are currently switching to JBoss in parallel. If the problem does not appear in it anymore, I cannot recommend the Payara in any way. Irrespective of whether we are running Windows or Linux, we are constantly faced with some kind of strange behavior.

We don’t have the problem with WebLogic 14, but we want to solve it. It runs a GlassFish, but Oracle seems to be able to do it better with EntityManager management.

Steven

another example:

LOGGER.debug("DEFAULT_ENTITY_TWO is open: {}", entityManager.isOpen());
DEFAULT_ENTITY_TWO is open: TRUE

java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManager.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.verifyOpen(EntityManagerImpl.java:2067)
at org.eclipse.persistence.internal.jpa.QueryImpl.setMaxResults(QueryImpl.java:848)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setMaxResults(EJBQueryImpl.java:437)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setMaxResults(EJBQueryImpl.java:1)
at com.sun.enterprise.container.common.impl.QueryWrapper.setMaxResults(QueryWrapper.java:127)
at com.sun.enterprise.container.common.impl.TypedQueryWrapper.setMaxResults(TypedQueryWrapper.java:86)

On the one hand, True is returned when “entityManager.isOpen()” is called, but with “setMaxResults()” is the EntityManager closed? What shoud that?

I just joined, and happened upon this thread. Have you tried injecting the EM directly into your query class, instead of obtaining one from another Stateless bean?

I would use:

@Stateless
028: public class AboLeistungenAdministrationImpl implements Serializable
029:     @PersistenceContext(unitName = "hussodbPU")
030:     private EntityeManager entityManager;
...
150: public LazyDataModel<AboleistungenEntity> getAboEntityLazyDataModel() {
152:     Query countQuery = entityManager.createNativeQuery("SELECT COUNT(*) FROM ABO");

I tried it that way, or something similar. It works quite well for a while, but every now and then the connection is closed again and the next time it is called up it works again.
This is really strange. The GlassFish EJB container seems to handle the PersistenceContext differently than the WebLogic under JavaEE 6.
I have now done this so that I open the connection manually and close it again when I am in the LazyLoading part.