Skip to content

Instantly share code, notes, and snippets.

@dimovelev
Last active February 14, 2016 11:55
Show Gist options
  • Save dimovelev/e1804c1d5eda6c4c4cfb to your computer and use it in GitHub Desktop.
Save dimovelev/e1804c1d5eda6c4c4cfb to your computer and use it in GitHub Desktop.
WebLogic JNDI - Not Closing The Initial Context
@WebService
public class FacadeJaxWs implements FacadeWebService {
@EJB(lookup = "FrontendEjb")
protected FrontendEjbHome frontendEjbHome;
public void updateCustomer() {
Properties envBackend = new Properties();
envBackend.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
envBackend.put(Context.PROVIDER_URL, "t3://backend:7001");
envBackend.put(Context.SECURITY_PRINCIPAL, "backend_user");
envBackend.put(Context.SECURITY_CREDENTIALS, "backend_password");
Context ctxBackend = new InitialContext(envBackend);
BackendEjbHome home = (BackendEjbHome) ctxBackend.lookup("BackendEjb");
BackendEjb remote = home.create();
remote.updateCustomerInBackend(mode);
FrontendEjb remote = frontendEjbHome.create();
remote.updateCustomerInFrontend(mode);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment