0 Replies Latest reply on Mar 29, 2015 5:45 PM by Jeff Larsen

    EJBClientContext lacks a test for being initialized

    Jeff Larsen Newbie

      If a client doesn't call EJBClientContext.getCurrent().close() before it shuts down, you get an error in the Wildlfy (8.2) server logs regarding "connection reset by peer". This is a nuisance because it's flagged as an error, not info or warning, but error. My logger is configured to email admins whenever the server encounters an error, so we can't have all this noise. This is more than a little bit annoying because client apps are not necessarily explicitly working with EJBClientContext, it just happens behind the scenes when you have an jboss-ejb-client.properties file configured. It wasn't exactly obvious that I needed to close the EJBClientContext, but I managed to find that it solves the server side error anyway. And no, calling close() on InitialContext doesn't help.


      So, that's my first point: If it's automatically initialized, I shouldn't have to manually clean it up to avoid errors in the server log. The fix for this should probably be on the server side (i.e., not flagged as an error), but perhaps the client side library can do something about this too.


      I have a desktop application framework for in-house apps. Some apps will connect to Wildfly, some may not. The problem is this: I want to do the remote connection cleanup at a high level in the framework so that each app need not code it separately. So in my "exitProgram()" method in the parent class, I would like to close any open EJBClientContext connections. But the only way to do so is to call EJBClientContext.getCurrent() which opens a connection if there is none. So apps that don't use Wildfly (or haven't used it yet) are wasting their time, waiting to initialize EJBClientContext, just so they can make sure to close it.


      Assuming nothing gets changed regarding my first point, my second point then, is that if we have to close these connections, there should be a way to know if they were ever opened in the first place without the need to uselessly open a new one.


      Sure, I can set a flag in my framework when it first creates an InitialContext so I know that there is an EJBClientContext that is going to need closing at some point, but this shouldn't be my housekeeping job in the first place.


      I'll be happy to submit this as a bug report (or two), but I thought I would post my minor rant here first in case the whole thing is something I'm missing or doing wrong.