JNDI Binding and ejbcontext test
adrian.brock Nov 13, 2007 2:33 PMThe ejbcontext test is failing because it binds the remote proxy at /Stateless
but then wants to bind the home in a subcontext /Stateless/home
The /Stateless jndi binding can't be both a binding and a naming context. ;-)
The same is true for the Stateful bean in this test.
But this brought up an issue, where the already succesful bindings are not removed
from jndi, even though the deployment has failed.
public void start() throws Exception { init(); super.start(); Class[] interfaces = {ProxyFactory.class}; String targetId = getTargetId(); String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding); Object factoryProxy = createPojiProxy(targetId, interfaces, clientBindUrl); log.debug("Binding proxy factory for " + container.getEjbName() + " in JNDI at " + jndiName + PROXY_FACTORY_NAME + " with client bind url " + clientBindUrl); try { // OK Util.rebind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME, factoryProxy); } catch (NamingException e) { NamingException namingException = new NamingException("Could not bind stateful remote proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME); namingException.setRootCause(e); throw namingException; } assert !Dispatcher.singleton.isRegistered(targetId) : targetId + " is already registered"; Dispatcher.singleton.registerTarget(targetId, this); StatefulContainer statefulContainer = (StatefulContainer) container; RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class); if (remoteHome != null && !bindHomeAndBusinessTogether(statefulContainer)) { Object homeProxy = createHomeProxy(remoteHome.value()); String homeJndiName = ProxyFactoryHelper.getHomeJndiName(container); log.debug("Binding home proxy at " + homeJndiName); // OOPS an error doesn't unbind the remote proxy! Util.rebind(container.getInitialContext(), homeJndiName, homeProxy); } }
THIS IS A MEMORY LEAK!