【问题标题】:Remote EJB on WildflyWildfly 上的远程 EJB
【发布时间】:2014-08-22 08:49:45
【问题描述】:

我有独立的应用程序连接到 Wildfly 服务器以获得 EJB 代理。这是 maven 项目,作为我的依赖项:

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

要获取我正在使用的 EJB:

final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
env.put("jboss.naming.client.ejb.context", true);
InitialContext remoteContext = new InitialContext(env);

String jndi = "jndi";
RemoteInterface lookup = (RemoteInterface) remoteContext.lookup(jndi);

一切正常,但服务器没有要求输入用户名和密码。如何添加认证?

【问题讨论】:

    标签: ejb wildfly


    【解决方案1】:

    这对你有用,因为你可能在 localhost 上进行测试。如果您尝试访问任何远程服务器,那么它将失败。 WildFLy 远程 EJB 调用默认需要经过身份验证,AFAIK。

    您需要添加这些属性:

    env.put("java.naming.security.principal", "user");      
    env.put("java.naming.security.credentials", "pass");
    

    您还需要为 WildFly 添加此用户。

    【讨论】:

      猜你喜欢
      • 2015-04-20
      • 2014-08-18
      • 1970-01-01
      • 2015-05-12
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-16
      相关资源
      最近更新 更多