InitialContext ictx = new InitialContext();
RefAddr ra = ((Reference) ret).get(0);
try {
ret = ictx.lookup((String) ra.getContent());
} catch (Exception e) {
NamingException ne = new NamingException(e.getMessage());
ne.setRootCause(e);
logger.error("unexpected exception {0}", e.getMessage(), e);
throw ne;
}
} else if (ret instanceof Reference) {
// Use NamingManager to build an object
try {
Object o = javax.naming.spi.NamingManager.getObjectInstance(ret, n, this, this.environment);
ret = o;
} catch (NamingException e) {
throw e;
} catch (Exception e) {
NamingException ne = new NamingException(e.getMessage());
ne.setRootCause(e);
throw ne;
}
if (ret == null) {
logger.error("Can not build an object with the reference {0}", name);
throw new NamingException("Can not build an object with the reference '" + name + "'");
}
}
return ret;
}