JBOSS - 远程EJB查找

时间:2017-11-06 10:13:44

标签: servlets java-ee jboss ejb jndi

我有这个耳朵(" Application.ear"):

Application.ear;
|__ejbProj.jar;
|  |___source;
|      |___bean;
|      |   |___LocalHelloWorld.class;
|      |   |___RemoteHelloWorld.class;
|      |
|      |___bean_interface;
|          |___HelloWorldInterface.class;
|
|__WEB.jar;
.
.
.

我的WEB.jar包含一个试图查找我的远程ejb的servlet。

public class MyServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

            context = new VelocityContext();
            final Hashtable jndiProperties = new Hashtable();
            jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

            InitialContext initialContext;
            String errorStatus="Undefined";
        try {

            initialContext = new InitialContext(jndiProperties);
            HelloWorldInterface remoteEjb=(HelloWorldInterface) initialContext.lookup("ejb:/Application/ejbProj/RemoteHelloWorld!source.bean_interface.HelloWorldInterface");           

            if (remoteEjb!=null) {

                errorStatus=remoteEjb.printMessage();
            }
            else {

                errorStatus="Error";
            }
        } catch (NamingException e) {

            errorStatus="NamingException: "+e.getMessage();
            e.printStackTrace();
        }
    }
}

这是我得到的错误:

  

EJBCLIENT000024:无法找到EJB匹配" StatelessEJBLocator   for" / Application / RemoteHelloWorld / ejbProj",view是interface   source.bean_interface.HelloWorldInterface,affinity is None"

这是我的界面:

public interface HelloWorldInterface {

    public String printMessage();

}

这是我的RemoteBean:

@Remote
@Stateless
public class RemoteHelloWorld implements HelloWorldInterface{

    @Override
    public String printMessage() {

        return "This is a remote EJB called \"RemoteHelloWorld\"";
    }

}

你能帮我解决这个问题吗?感谢

0 个答案:

没有答案