Search in sources :

Example 1 with InvalidServiceException

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);
    }
}
Also used : EJBHome(javax.ejb.EJBHome) NameNotFoundException(javax.naming.NameNotFoundException) UnknownServiceException(com.ing.ifsa.internal.exceptions.UnknownServiceException) PortableRemoteObject(javax.rmi.PortableRemoteObject) NamingException(javax.naming.NamingException) Method(java.lang.reflect.Method) NamingException(javax.naming.NamingException) UnknownServiceException(com.ing.ifsa.internal.exceptions.UnknownServiceException) InvalidServiceException(com.ing.ifsa.internal.exceptions.InvalidServiceException) NameNotFoundException(javax.naming.NameNotFoundException) InvalidServiceException(com.ing.ifsa.internal.exceptions.InvalidServiceException)

Aggregations

InvalidServiceException (com.ing.ifsa.internal.exceptions.InvalidServiceException)1 UnknownServiceException (com.ing.ifsa.internal.exceptions.UnknownServiceException)1 Method (java.lang.reflect.Method)1 EJBHome (javax.ejb.EJBHome)1 NameNotFoundException (javax.naming.NameNotFoundException)1 NamingException (javax.naming.NamingException)1 PortableRemoteObject (javax.rmi.PortableRemoteObject)1