conexion de aplicacion cliente a session bean
Publicado por luis (3 intervenciones) el 01/02/2007 17:10:31
Hola estoy trabajando en el weblogic 8.1 y tengo el siguiente problema:
He conseguido generar el codigo, deployado y arrancado el servidor pero cuando lo intento llamar desde una aplicacion cliente me sucede el siguiente error:
Exception in thread "main" javax.naming.NoInitialContextException: Need to speci
fy class name in environment or system property, or as an applet parameter, or i
n an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at perfecttime.PerfectTimeClient.main(PerfectTimeClient.java:14)
el servidor si esta arrancando porque inclusive entro a http//localhost:7001/console y puedo ver que la aplicacion esta deployada alguien sabe como se tiene que conectar un cliente o tiene algun ejemplo de una aplicacion me seria muy util gracias aquie esta el codigo del cliente:
package perfecttime;
import javax.naming.Context;
import javax.naming.InitialContext;
public class PerfectTimeClient
{
public static void main(String[] args) throws Exception
{
// Get a JNDI context using
// the JNDI Naming service:
Context context = new InitialContext();
Context myEnv = (Context)context.lookup("java:comp/env");
// Look up the home interface in the
// JNDI Naming service:
Object ref = myEnv.lookup("ejb/PerfectTime");
// Cast the remote object to the home interface:
PerfectTimeHome home = (PerfectTimeHome)
javax.rmi.PortableRemoteObject.narrow(ref, PerfectTimeHome.class);
// Create a remote object from the home interface:
PerfectTime pt = home.create();
// Invoke getPerfectTime()
System.out.println("Perfect Time EJB invoked, time is: " +
pt.getPerfectTime() );
}
}
He conseguido generar el codigo, deployado y arrancado el servidor pero cuando lo intento llamar desde una aplicacion cliente me sucede el siguiente error:
Exception in thread "main" javax.naming.NoInitialContextException: Need to speci
fy class name in environment or system property, or as an applet parameter, or i
n an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at perfecttime.PerfectTimeClient.main(PerfectTimeClient.java:14)
el servidor si esta arrancando porque inclusive entro a http//localhost:7001/console y puedo ver que la aplicacion esta deployada alguien sabe como se tiene que conectar un cliente o tiene algun ejemplo de una aplicacion me seria muy util gracias aquie esta el codigo del cliente:
package perfecttime;
import javax.naming.Context;
import javax.naming.InitialContext;
public class PerfectTimeClient
{
public static void main(String[] args) throws Exception
{
// Get a JNDI context using
// the JNDI Naming service:
Context context = new InitialContext();
Context myEnv = (Context)context.lookup("java:comp/env");
// Look up the home interface in the
// JNDI Naming service:
Object ref = myEnv.lookup("ejb/PerfectTime");
// Cast the remote object to the home interface:
PerfectTimeHome home = (PerfectTimeHome)
javax.rmi.PortableRemoteObject.narrow(ref, PerfectTimeHome.class);
// Create a remote object from the home interface:
PerfectTime pt = home.create();
// Invoke getPerfectTime()
System.out.println("Perfect Time EJB invoked, time is: " +
pt.getPerfectTime() );
}
}
Valora esta pregunta


0