Weld and a EntityManagerFactory Container Managed

237 Views Asked by At

I need to know how ensures that container closes EMF (using wildfly 8.0 and hibernate-jpa).

Every time that I undeploy my app a instance of WeldJpaInjectionServices$EntityManagerResourceReferenceFactory stays on memory holding a EMF instance.

This is causing a OOM Exception after some deploys/undeploys.

I'm not using EMF references in my code, only a EntityManager with @Produces and @PersistenceContext annotation.

It is happening on wildfly 8.0, 8.1 and 9.0alpha, with java 7 and 8.

1

There are 1 best solutions below

0
On

Leak is related with keep-alive and read-timeout properties of Undertow.

In new version of Wildfly (8.2) we can define these properties:

<subsystem xmlns="urn:jboss:domain:undertow:1.2">
            <buffer-cache name="default"/>
            <server name="default-server">
                <http-listener name="default" socket-binding="http" tcp-keep-alive="true" read-timeout="30000"/>

After setup no more leaks on deploy/undeploy.

ISSUE:WFLY-3536 - Wildfly 8.1.0 Final keeps established connections forever