WildFly recherche JNDI pour les locaux EJB déployé dans une GUERRE

Je suis l'aide de WildFly 8.1.0 sortie de la version Finale.

Ma demande est un JavaEE application web déployée dans une GUERRE (il n'y a pas de module EJB .de l'oreille).

Je veux appeler par programme local de l'EJB avec son nom en utilisant JNDI.

Les EJB sont juste annotée avec @Stateless (il n'y a pas de Locaux ou de l'interface de commande à Distance)

J'essaie en dessous de la fonction:

private <E extends DomainObject> CrudService<E> lookUp(Class<E> cl) {
    try {
        final Hashtable jndiProperties = new Hashtable();
        jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        final Context context = new InitialContext(jndiProperties);
        //The app name is the application name of the deployed EJBs. This is typically the ear name
        //without the .ear suffix. However, the application name could be overridden in the application.xml of the
        //EJB deployment on the server.
        //Since we haven't deployed the application as a .ear, the app name for us will be an empty string
        final String appName = "";
        //This is the module name of the deployed EJBs on the server. This is typically the jar name of the
        //EJB deployment, without the .jar suffix, but can be overridden via the ejb-jar.xml
        //In this example, we have deployed the EJBs in a jboss-as-ejb-remote-app.jar, so the module name is
        //jboss-as-ejb-remote-app
        final String moduleName = "jboss-as-ejb-remote-app";
        //AS7 allows each deployment to have an (optional) distinct name. We haven't specified a distinct name for
        //our EJB deployment, so this is an empty string
        final String distinctName = "";
        //The EJB name which by default is the simple class name of the bean implementation class
        final String serviceName = cl.getSimpleName() + "Service";
        //let's do the lookup
        return (CrudService<E>) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + serviceName );
        //return (CrudService<E>) context.lookup(serviceName);
    } catch (NamingException e) {
        log.error("NamingException {}",e) ;
        throw new RuntimeException(e) ;
    }
}

mais il ne fonctionne pas (obviusly il est à distance EJB)

Mais je ne trouve pas d'exemple pour les locaux EJB dans une GUERRE avec l'WildFly et je n'ai aucune idée de comment faire, je n'ai pas utiliser JNDI souvent...

J'ai trouvé un travail autour de l'annotation des EJB avec @Nommé(valeur="EjbClassName") et appelez-les à l'aide de JSF.

FacesContext context = FacesContext.getCurrentInstance() ;
return context.getApplication().evaluateExpressionGet(context, "#{"+cl.getSimpleName()+"Service}", CrudService.class) ;

Et ça fonctionne,

mais je préfère ne pas utiliser JSF comme il n'est pas lié à la couche de la vue.

  • Une fois que vous déployez la guerre, la WildFly serveur n'a pas connecter les noms JNDI qui sont en cours de chargement? Dans glassfish-je faire pour trouver le bon recherche de chaîne de...
InformationsquelleAutor kwisatz | 2014-09-24