Duke\'s Bank

OggieSvennson
24 de Diciembre del 2008
Hola,

Tengo tres Entities beans a los que llamo desde sus respectivos Controladores que son Session beans con estado. Pero No se cual es el JNDI de los Entities y no puedo invocarlos.

Basicamenete se reduce a dos clases:

public final class EJBGetter {
public static AccountHome getAccountHome() throws NamingException {
Context initial = getInitialContext();

Debug.print("Obteniendo la referencia de " + CodedNames.ACCOUNT_EJB);
Object objref = initial.lookup(CodedNames.ACCOUNT_EJB);
Debug.print("Obtenida referencia de " + CodedNames.ACCOUNT_EJB, objref);

//return (AccountHome) PortableRemoteObject.narrow(objref, AccountHome.class);
return (AccountHome)objref;
}

public static AccountControllerHome getAccountControllerHome()
throws NamingException {
Context initial = getInitialContext();

Object objref = initial.lookup(CodedNames.ACCOUNT_CONTROLLER_EJB);
Debug.print("Obtenida referencia " + CodedNames.ACCOUNT_CONTROLLER_EJB, objref);
Debug.print("Obtenida referencia de " + CodedNames.ACCOUNT_CONTROLLER_EJB, objref);

return (AccountControllerHome) PortableRemoteObject.narrow(objref,
AccountControllerHome.class);
}

public static CustomerHome getCustomerHome() throws NamingException {
Context initial = getInitialContext();

Debug.print("Obteniendo la referencia de " + CodedNames.CUSTOMER_EJB);
Object objref = initial.lookup(CodedNames.CUSTOMER_EJB);
Debug.print("Obtenida referencia de " + CodedNames.CUSTOMER_EJB, objref);

//return (CustomerHome) PortableRemoteObject.narrow(objref, CustomerHome.class);
return (CustomerHome)objref;
}

public static CustomerControllerHome getCustomerControllerHome()
throws NamingException {
Context initial = getInitialContext();

Object objref = initial.lookup(CodedNames.CUSTOMER_CONTROLLER_EJB);
Debug.print("Obtenida referencia de " + CodedNames.CUSTOMER_CONTROLLER_EJB, objref);

return (CustomerControllerHome) PortableRemoteObject.narrow(objref,
CustomerControllerHome.class);
}

public static TxHome getTxHome() throws NamingException {
Context initial = getInitialContext();

Debug.print("Obteniendo la referencia de " + CodedNames.TX_EJB);
Object objref = initial.lookup(CodedNames.TX_EJB);
Debug.print("Obtenida referencia de " + CodedNames.TX_EJB, objref);

//return (TxHome) PortableRemoteObject.narrow(objref, TxHome.class);
return (TxHome)objref;
}

public static TxControllerHome getTxControllerHome()
throws NamingException {
Context initial = getInitialContext();

Object objref = initial.lookup(CodedNames.TX_CONTROLLER_EJB);
Debug.print("Obtenida referencia de " + CodedNames.TX_CONTROLLER_EJB, objref);

return (TxControllerHome) PortableRemoteObject.narrow(objref,
TxControllerHome.class);
}

private static Context getInitialContext(){
Context ctx = null;

Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
env.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
env.put("j2ee.clientName", "bank-client");

try {
// Get an initial context
ctx = new InitialContext(env);
System.out.println("Got context");
Debug.print("Obtenido Contexto: ", ctx);
} catch (NamingException ne) {
// TODO Auto-generated catch block
System.out.println("Did not get context");
ne.printStackTrace();
}

return ctx;
}
}

y la segunda es,

public interface CodedNames {
public static final String BANK_DATABASE = "java:/DefaultDS";
public static final String ACCOUNT_EJB = "AccountEJB";
public static final String ACCOUNT_CONTROLLER_EJB = "AccountControllerEJB";
public static final String CUSTOMER_EJB = "CustomerEJB";
public static final String CUSTOMER_CONTROLLER_EJB = "CustomerControllerEJB";
public static final String TX_EJB = "TxEJB";
public static final String TX_CONTROLLER_EJB = "TxControllerEJB";
}

donde están los nombres a buscar.

Con los session (controladores) no tengo problemas pero con los entities que son locales sí.

El cliente accede sin problemas a los controladores, pero estos no a los entities. JBoss me dice "nombreEJB not bound".

Alguien me puede ayudar.

Un saludo,
José Álvarez de Lara

oggiesvennson
24 de Diciembre del 2008
Hola de nuevo,

Ya he consegidu que funcionen los JNDI con los nombres de los EJBs. De manera que el cliente de desktop funciona correctamente. Pero el cliente web no me funciona. Se supone que main.jsp lanza una peticion al controlador Dispatecher que por medio de javabeans y de las taglibraries debe dar un resultado. Pues bien, el resultado que obtengo es una página en blanco y el mensaje en la consola de que la clase DefinitionTag no me devuelve parámetros y el template.jsp, que es quien los procesa para mostrarlos, se queda en blanco.

Si alguien puede ayudarme le estaría muy agradecido.

Un saludo,
Oggie Svennson