init();
Context ctx = container.getInitialContext();
Name name = ctx.getNameParser("").parse(jndiName);
ctx = Util.createSubcontext(ctx, name.getPrefix(name.size() - 1));
String atom = name.get(name.size() - 1);
RefAddr refAddr = new StringRefAddr(JndiProxyFactory.FACTORY, jndiName + PROXY_FACTORY_NAME);
Reference ref = new Reference("java.lang.Object", refAddr, JndiProxyFactory.class.getName(), null);
try
{
Util.rebind(ctx, atom, ref);
} catch (NamingException e)
{
NamingException namingException = new NamingException("Could not bind stateful proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + ctx.getNameInNamespace() + "/" + atom);
namingException.setRootCause(e);
throw namingException;
}