WildFly JNDI lookup for local EJB deployed in a WAR

馋奶兔 提交于 2019-11-28 14:14:32

Thank you Yamada the JNDI names appear in the server logs at startup

this solution works:

private <E extends DomainObject> CrudService<E> lookUp(@NonNull Class<E> entityClass) throws NamingException {
    try {
        final Hashtable jndiProperties = new Hashtable();
        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        final Context context = new InitialContext(jndiProperties);
        return (CrudService<E>) context.lookup("java:module/"+entityClass.getSimpleName()+"Service");
    } catch (NamingException e) {
        log.error("lookUp({}) throws NamingException {}",entityClass.getSimpleName(),e.getMessage()) ;
        throw e ;
    }
}

without annotate EJB with @LocalBean

Just a short answer from mobile: Use @LocalBean for a no-Interface view of your bean. Add this to your stateless session bean and you should find it in the jndi view of your Server.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!