1

我在查找我的 ejb 时遇到问题。在 servlet 中一切正常,但我需要从远程客户端连接到 ejb。

从部署控制台日志:

 java:global/easymenu-webappEAR/EasyMenu/CounterBean!sk.jbase.projects.easymenu.CounterBeanRemote
 java:app/EasyMenu/CounterBean!sk.jbase.projects.easymenu.CounterBeanRemote
 java:module/CounterBean!sk.jbase.projects.easymenu.CounterBeanRemote
 java:jboss/exported/easymenu-webappEAR/EasyMenu/CounterBean!sk.jbase.projects.easymenu.CounterBeanRemote
 java:global/easymenu-webappEAR/EasyMenu/CounterBean
 java:app/EasyMenu/CounterBean
 java:module/CounterBean

我在 webapp 中有 ejbmodule(我不知道它是如何分开的)

获取上下文:

public static InitialContext getInitialContext(String url) throws NamingException {
    Properties properties = new Properties();

    properties.setProperty(Context.URL_PKG_PREFIXES,
            "org.jboss.ejb.client.naming");
    properties.setProperty(Context.PROVIDER_URL, url);
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
    properties.setProperty(Context.SECURITY_PRINCIPAL, "pch");
    properties.setProperty(Context.SECURITY_CREDENTIALS, "peterch");

    return new InitialContext(properties);
}

抬头:

            CounterBeanRemote cbr = (CounterBeanRemote) ServiceLocator
                    .getInitialContext("remote://localhost:8080").lookup("java:app/EasyMenu/CounterBean!"
        + CounterBeanRemote.class.getName());

            System.out.println("Result: " + cbr.getMessage());

例外

mar 20, 2013 10:27:04 PM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
mar 20, 2013 10:27:04 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
mar 20, 2013 10:27:04 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Operation failed with status WAITING]
    at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
    at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
    at javax.naming.InitialContext.init(InitialContext.java:242)
    at javax.naming.InitialContext.<init>(InitialContext.java:216)
    at sk.jbase.projects.easymenu.client.EasyMenuClient.getInitialContext(EasyMenuClient.java:58)
    at sk.jbase.projects.easymenu.client.EasyMenuClient.main(EasyMenuClient.java:38)
Caused by: java.lang.RuntimeException: Operation failed with status WAITING
    at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:89)
    at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)
    at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)
    at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)
    at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
    ... 6 more
4

2 回答 2

0

我在 JBOSS AS 7.2 的最后一个夜间版本中遇到了同样的问题。当我刚刚将类路径中的 jboss-client.jar 恢复为旧版本时,它开始像魅力一样工作。

一旦你修复了上面的 URL 和查找以及 jboss-client.jar,就应该这样做。

于 2014-03-20T17:23:14.593 回答
0

您使用哪个 JBoss 版本?在 JBoss 7.1 中,默认远程端口是 4447,您应该使用 java:jboss/exported/ 之后的 URL。如果您使用“org.jboss.ejb.client.naming”,那么您需要一个“ejb:”前缀作为 URL 和通常在文件 jboss-ejb-client.properties 中的属性。

于 2013-05-29T08:03:19.580 回答