我已经创建和EJB与远程接口:

@Stateless
public class TestSessionBean implements TestSessionRemote 
{

    public void businessMethod() 
    {
            System.out.println ("***businessMethod");
    }
}

我从经由运行在服务器上的另一部件(例如一个servlet)访问它

ic = new InitialContext();
ic.lookup("myEJB");

我使用NetBeans 6.5.1和GlassFish v2中。

我怎么能这样做?

谢谢, IDO

有帮助吗?

解决方案

实际EJB3使用默认的命名约定,我至极还没有找到一种方法来解决。

为bean的名字会是这样的: TestSessionBean#package.TestSessionBean

要接取您的远程服务,你可以做这样的事情。

InitialContext ctx = new InitialContext();
ctx.lookup(interfaceClass.getSimpleName()+"#"+interfaceClass.getName());

其中interfaceClass是类远程接口。

确实注意到您还没有定义为Web服务器的远程接口(或本地为此事)。你mightnot能够从另一个上下文接取theejb。

作为改变,实际上是我不认为有可能通过anotations名称。不知道虽然

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top