You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WildFly 27远程EJB查找报错EJBCLIENT000409及认证问题求助

解决方案与WildFly 27远程有状态EJB调用指南

一、修复EJBCLIENT000409: No more destinations are available异常

该异常核心原因是客户端与服务器的远程EJB通信配置不匹配,或服务器未正确暴露远程端点,可按以下步骤排查:

1. 服务器端配置校验(standalone-full.xml)

确保http-remoting连接器已启用并关联正确安全域:

<subsystem xmlns="urn:jboss:domain:remoting:6.0">
    <http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
</subsystem>

同时确认ejb3子系统开启远程访问支持:

<subsystem xmlns="urn:jboss:domain:ejb3:8.0">
    <remote connector-ref="http-remoting-connector" thread-pool-name="default"/>
    <!-- 其他EJB相关配置 -->
</subsystem>

2. 客户端JNDI路径验证

你的JNDI格式符合规范,但需确认以下细节:

  • EAR部署名称enterprise-y-ear为实际部署后的无后缀名称
  • EJB模块名称enterprise-y-ejb与项目模块名完全一致
  • 远程接口全类名cs.edu.ey.ejb.remote.TokenServiceRemote无拼写错误
  • 有状态Bean必须添加?stateful后缀

3. 客户端依赖对齐

确保引入与WildFly 27版本严格匹配的EJB客户端依赖,Maven配置示例:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-ejb-client-bom</artifactId>
            <version>27.0.1.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-naming-client</artifactId>
    </dependency>
</dependencies>

二、修复WFHTTP000013: Authentication failed认证错误

改用HTTP传输时的认证失败,需确保客户端与服务器的安全机制匹配:

1. 服务器端安全域配置检查

确认ApplicationRealm的认证配置正确,standalone-full.xml中:

<security-realm name="ApplicationRealm">
    <authentication>
        <local default-user="$local" allowed-users="*" skip-group-loading="true"/>
        <properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
    </authentication>
    <authorization>
        <properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
    </authorization>
</security-realm>

注意:用户必须通过add-user.sh/add-user.bat工具生成,手动写入的明文密码无法被正确识别。

2. 客户端认证配置调整

将Sasl机制调整为与服务器兼容的类型,若使用DIGEST-MD5需确保密码是工具生成的哈希值,或改用PLAIN机制(生产环境建议配合HTTPS):

<configuration>
    <authentication-client xmlns="urn:elytron:1.0">
        <authentication-rules>
            <rule use-configuration="default"/>
        </authentication-rules>
        <authentication-configurations>
            <configuration name="default">
                <sasl-mechanism-selector selector="PLAIN"/>
                <set-user-name name="你的用户名"/>
                <credentials>
                    <clear-password password="你的密码"/>
                </credentials>
            </configuration>
        </authentication-configurations>
    </authentication-client>    
</configuration>

3. HTTP传输依赖补充

使用HTTP传输时,需额外引入wildfly-http-client依赖:

<dependency>
    <groupId>org.wildfly</groupId>
    <artifactId>wildfly-http-client</artifactId>
</dependency>

三、WildFly 27远程有状态EJB调用核心规则

  1. 服务器必须启用http-remoting连接器并关联ApplicationRealm
  2. 客户端初始上下文工厂固定为org.wildfly.naming.client.WildFlyInitialContextFactory
  3. 有状态EJB的JNDI查找必须添加?stateful后缀
  4. 认证机制需客户端与服务器严格匹配,优先使用Elytron配置文件而非硬编码
  5. 所有依赖版本必须与WildFly服务器版本完全一致,避免兼容性问题

内容的提问来源于stack exchange,提问作者ranxero

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 10:27:57