EJB client seeing resources leaked such as connection leaks in JBoss EAP 6.x / 7.0
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.0
- 6.x
Issue
- EJB client seeing resources leaked such as connection leaks in JBoss EAP 6.x / 7.0
Resolution
If using ejb-client scoped context , then the client must close the ejb-client context as shown in this article once it is done, and that context must the ejb-client context, not the top level InitialContext. If you are not holding a reference to the ejb-context, you can just do this below to ensure you close the ejb-context.
try {
...
} finally {
((Context)context.lookup("ejb:")).close();
...
}
Note: make sure you have a try / finally block to ensure that if an exception is thrown that you still invoke the close method, else you can leak connections.
Similarly if you are using the remote-naming configuration approach, then you need to make sure you hold a reference to the remote-naming InitialContext and also ensure you have a try/finally block and then close the context when done.
try {
...
} finally {
context.close();
...
}
Diagnostic Steps
Questions
- Which method of configuring the remote EJB call is the client using? Please attach code showing the client application creating the InitialContext and the properties being passed into it. This article shows the various ways of configuring.
- Please attach the client server and ejb server JBoss profile configuration (standalone*.xml/domain.xml)
- Please attach the server.logs from both the client and server.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.