无法连接到jboss服务器 - 操作失败,状态为WAITING

时间:2015-01-30 06:44:22

标签: java ejb jboss7.x windows-firewall

尝试连接到本地jboss服务器时遇到此异常(wildfly-8.2.0.Final)

    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:313)
    at javax.naming.InitialContext.init(InitialContext.java:244)
    at javax.naming.InitialContext.<init>(InitialContext.java:216)
    at com.sample.CalculatorIntegrationTestCase.obtainProxyReferences(CalculatorIntegrationTestCase.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
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)
    ... 18 more

JNDI属性如下:

@BeforeClass
    public static void obtainProxyReferences() throws Throwable {

        Properties properties = new Properties();
        properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        properties.put(Context.PROVIDER_URL, "remote://localhost:4447");
        properties.put("jboss.naming.client.ejb.context", true);
        properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        properties.put(Context.SECURITY_PRINCIPAL, "testuser");
        properties.put(Context.SECURITY_CREDENTIALS, "!Test1");
        namingContext = new InitialContext(properties);

        bean = (MeBeanImpl) namingContext.lookup(JNDI_NAME);
    }

Telnet还表示它无法通过端口4447连接到服务器。我在防火墙中打开了这个端口,但它没有帮助。

4 个答案:

答案 0 :(得分:0)

默认情况下,WildFly使用8080作为远程端口。 EJB客户端API使用具有http-upgrade功能的http端口与服务器进行通信以进行远程调用。

例如:

Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL,"http-remoting://localhost:8080");
jndiProps.put("jboss.naming.client.ejb.context", true);
jndiProps.put(Context.SECURITY_PRINCIPAL, "testuser");
jndiProps.put(Context.SECURITY_CREDENTIALS, "!Test1");

// create a context passing these properties
Context ctx = new InitialContext(jndiProps);
// lookup
ctx.lookup(JNDI_NAME);

请参阅:Remote EJB invocations via JNDI - EJB client API or remote-naming project

答案 1 :(得分:0)

如果您正在使用maven,请不要忘记添加此依赖项:

  <dependency>
    <groupId>org.wildfly</groupId>
    <artifactId>wildfly-ejb-client-bom</artifactId>
    <version>8.0.0.Final</version>
    <type>pom</type>
  </dependency>

对于JMS,您也需要这些:

  <dependency>
    <groupId>org.hornetq</groupId>
    <artifactId>hornetq-jms-client</artifactId>
    <version>2.2.13.Final</version>
  </dependency>
  <dependency>
    <groupId>org.hornetq</groupId>
    <artifactId>hornetq-core-client</artifactId>
    <version>2.2.13.Final</version>
  </dependency>

这应该是您需要的唯一依赖。

答案 2 :(得分:0)

而不是使用“remote:// localhost:4447”使用“http-remoting:// localhost:8080”

properties.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");

在代码中配置jndi属性时,查找名称不应包含ejb:

JNDI_NAME = "ear-name/ejb-name/beanClass!beanInterface.fullpath");

答案 3 :(得分:0)

更改您的财产

properties.put(Context.PROVIDER_URL,&#34; remote:// localhost:4447&#34;);

properties.put(Context.PROVIDER_URL,&#34; http-remoting:// localhost:4447&#34;);