use of com.ing.ifsa.internal.exceptions.InvalidServiceException in project iaf by ibissource.
the class CustomIfsaServiceLocatorEJB method getBeanFromJNDI.
protected Object getBeanFromJNDI(String beanHomeJNDIName) throws UnknownServiceException, InvalidServiceException {
try {
Object obj = namingHelper.lookup(beanHomeJNDIName);
EJBHome svcHome = (EJBHome) PortableRemoteObject.narrow(obj, javax.ejb.EJBHome.class);
Class homeClass = svcHome.getClass();
Method createMethod = homeClass.getMethod("create", null);
Object remoteSvc = createMethod.invoke(svcHome, new Object[0]);
return remoteSvc;
} catch (ClassCastException e) {
log.error("Error creating EJB bean from JNDI Looking [" + beanHomeJNDIName + "]", e);
throw new InvalidServiceException("Can not find bean home interface [" + beanHomeJNDIName + "]", e);
} catch (NameNotFoundException e) {
log.error("Can not find EJB bean in JNDI: [" + beanHomeJNDIName + "]", e);
throw new UnknownServiceException("Can not find bean home interface [" + beanHomeJNDIName + "]", e);
} catch (NamingException e) {
log.error("Can not find EJB bean in JNDI: [" + beanHomeJNDIName + "]", e);
throw new UnknownServiceException("JNDI error looking up bean home interface [" + beanHomeJNDIName + "]", e);
} catch (Exception e) {
log.error(e, e);
throw new InvalidServiceException("Can not create bean [" + beanHomeJNDIName + "]", e);
}
}
Aggregations