configuration ejb au niveau client
J'ai créé un ejb SessionBean stateless accessible de facon remote.
Ma question est comment configurer proprement l'accès à l'ejb remote.
Sur un site, j'ai trouvé le moyen ci-dessous. Cela marche pour moi mais pas pour mon collegue: (Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial)
Des idées????!!!!
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Properties connectionProperties = new Properties();
static{
connectionProperties.put("org.omg.CORBA.ORBInitialPort", "3700");
connectionProperties.put("org.omg.CORBA.ORBInitialHost","localhost");
try {
InitialContext ctx = new InitialContext(connectionProperties);
Object ref = ctx.lookup(classT.getName());
T service = (T) PortableRemoteObject.narrow(ref, classT);
System.out.println("got service "+classT.getName()+": "+service);
return service;
} catch (NamingException ex) {
throw new RuntimeException("unable to get service "+classT.getName(), ex);
} |