X
xbl
Unregistered / Unconfirmed
GUEST, unregistred user!
我的ejb 名称为 Hello,
已经成功将 ejb 部署到 Jboss 中,
但是客户端访问 ejb 时出错:
javax.naming.NameNotFoundException: Hello not bound
//客户端代码:
public class HelloClient
{
public static void main(String[] args)
{
try
{
Properties p=new Properties();
p.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
p.setProperty("java.naming.provider.url", "localhost:1099");
InitialContext jndiContext = new InitialContext(p);
System.out.println("Got context");
// Get a reference to the Interest Bean
Object ref = jndiContext.lookup("Hello");
System.out.println("Got reference");
// Get a reference from this to the Bean's Home interface
HelloHome home = (HelloHome)
PortableRemoteObject.narrow(ref, HelloHome.class);
// Create an Hello object from the Home interface
Hello hello = home.create();
// call the hello() method
System.out.println(hello.hello());
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
问题出在哪里呢?
已经成功将 ejb 部署到 Jboss 中,
但是客户端访问 ejb 时出错:
javax.naming.NameNotFoundException: Hello not bound
//客户端代码:
public class HelloClient
{
public static void main(String[] args)
{
try
{
Properties p=new Properties();
p.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
p.setProperty("java.naming.provider.url", "localhost:1099");
InitialContext jndiContext = new InitialContext(p);
System.out.println("Got context");
// Get a reference to the Interest Bean
Object ref = jndiContext.lookup("Hello");
System.out.println("Got reference");
// Get a reference from this to the Bean's Home interface
HelloHome home = (HelloHome)
PortableRemoteObject.narrow(ref, HelloHome.class);
// Create an Hello object from the Home interface
Hello hello = home.create();
// call the hello() method
System.out.println(hello.hello());
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
问题出在哪里呢?