【问题标题】:Can't connect to jboss server - Operation failed with status WAITING无法连接到 jboss 服务器 - 操作失败,状态为 WAITING
【发布时间】:2015-03-29 14:45:05
【问题描述】:

尝试连接本地 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 的服务器。我在防火墙中打开了此端口,但没有帮助。

【问题讨论】:

    标签: java ejb jboss7.x windows-firewall


    【解决方案1】:

    不要使用“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");
    

    【讨论】:

      【解决方案2】:

      如果你使用的是 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>
      

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

      【讨论】:

        【解决方案3】:

        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

        【讨论】:

        • javax.naming.NamingException:无法连接到任何服务器。尝试的服务器:[http-remoting://localhost:8080]
        猜你喜欢
        • 1970-01-01
        • 2019-02-01
        • 2018-03-22
        • 2015-06-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多