最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I make EJB request to two different servers deployed in Wildfly 26 - Stack Overflow

programmeradmin1浏览0评论

I am currently facing an issue in WildFly 26.1.3 where an EJB Client dynamically switching between two WildFly EJB servers exhibits unexpected behavior. Issue Summary:

  1. First EJB call to Server 1 succeeds (Created a new Context and JNDI lookup for Server 1).
  2. First EJB call to Server 2 succeeds (Created a new Context and JNDI lookup for Server 2).
  3. Second call to Server 2 fails with an authentication error.

Below is the code which I am trying to execute.


package com.bally.test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;

import com.ballydev.sds.siteconfig.dto.SiteDTO;
import com.ballydev.sds.siteconfig.service.ISiteConfig;


public class TestSiteEJBService<T> {

    private static Map<String, Context> contextMap = new HashMap<>();

    public static final String  SiteConfigService = "ejb:SDS/SUSEngineEJB/SiteConfig!com.ballydev.sds.siteconfig.service.ISiteConfig";

    private static int x = 0;

    public static void main(String[] args) {
        System.setProperty("javax.ssl.trustStore", "keystore");

        try {
            TestSiteEJBService<ISiteConfig> serviceLocator = new TestSiteEJBService<ISiteConfig>();

            ISiteConfig configService1 = serviceLocator.fetchEJBService_16(SiteConfigService, "10.2.212.73", "18443");
            List<SiteDTO> siteDTOs = configService1.getAllSiteInfo();
            System.out.println("Site details from Server 1:");
            for (SiteDTO siteDTO : siteDTOs) {
                System.out.println("\t"+siteDTO.getNumber() +"\t type:"+  siteDTO.getProperty().getPropertyTypeId());
            }

            ISiteConfig configService2 = serviceLocator.fetchEJBService_16(SiteConfigService, "10.2.38.112", "18443");
            List<SiteDTO> siteDTORemotes = configService2.getAllSiteInfo();
            System.out.println("Site details from Server 2:");
            for (SiteDTO siteDTO : siteDTORemotes) {
                System.out.println("\t"+siteDTO.getNumber() +"\t type:"+  siteDTO.getProperty().getPropertyTypeId());
            }

            // This line of code throws error
            System.out.println("Making Request again to Server 2:");
            List<SiteDTO> siteDTORemotes2 = configService2.getAllSiteInfo();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @SuppressWarnings("unchecked")
    public T fetchEJBService_16(String serviceName, String hostIp, String portNumber) throws Exception {

        String serverUrl = getJndiUrl(hostIp, portNumber, true);
        System.out.println("Lookup serverUrl: " + serverUrl+ " serviceName: "+serviceName);
        Context context = contextMap.get(serverUrl);
        if (context == null) {

            for (String url : contextMap.keySet()) {
                Context existingContext = contextMap.get(url);
                existingContext.close();
                contextMap.remove(url);
                System.out.println("######### Closing context for "+url);
            }       

            Properties props = new Properties();

            props.setProperty(Context.INITIAL_CONTEXT_FACTORY, ".wildfly.naming.client.WildFlyInitialContextFactory");
            props.setProperty(Context.URL_PKG_PREFIXES, ".jboss.ejb.client.naming");
            props.setProperty("remote.connectionprovider.create.options.xnio.Options.SSL_ENABLED", "true");
            props.put("wildfly.naming.client.ejb.context", "true");

            List<String> serverUrlList = Arrays.asList(serverUrl.split(","));
            StringBuilder sb = new StringBuilder();

            for (String url : serverUrlList) {
                String protocol = url.substring(0, url.indexOf(":"));
                String host = url.substring(url.indexOf(":") + 3, url.lastIndexOf(":"));
                String port = url.substring(url.lastIndexOf(":") + 1);
                if (sb.length() > 0) {
                    sb.append(",");
                }
                String appName = "app" + (++x);
                props.put("remote.connection." + appName + ".protocol", protocol);
                props.put("remote.connection." + appName + ".host", host);
                props.put("remote.connection." + appName + ".port", port);
                props.put("remote.connection." + appName + ".username", "sds");
                props.put("remote.connection." + appName + ".password", "Bally@1234");
                props.put("remote.connection." + appName + ".connect.options.xnio.Options.SSL_STARTTLS", "true");
                props.put("remote.connection." + appName + ".connect.options.jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL", "600000");
                props.put("remote.connection." + appName + ".connect.options.xnio.Options.SASL_POLICY_NOANONYMOUS", "true");    

                sb.append(appName);
            }
            props.put("remote.connections", sb.toString());

            System.out.println("JNDI Properties 16:");
            for (Entry<Object,Object> propentry : props.entrySet()) {
                System.out.println("\t"+propentry.getKey() +" : "+ propentry.getValue());
            }

            System.out.println("######### Creating InitialContext for serverUrl: " + serverUrl);
            context = new InitialContext(props);
            contextMap.put(serverUrl, context);
        }

        T proxy = (T) context.lookup(serviceName);
        return proxy;
    }

    public static String getJndiUrl(String hostIp, String portNumber, boolean isSSLEnabled) {   
        String[] hostIPs = hostIp.split(",");
        StringBuilder sb = new StringBuilder();
        for(String hostIP : hostIPs) {
            if(isSSLEnabled){
                sb.append("https-remoting://").append(hostIP).append(":").append(portNumber);
            }else{
                sb.append("http-remoting://").append(hostIP).append(":").append(portNumber);
            }

            sb.append(",");
        }
        return sb.toString().substring(0, sb.length() - 1);
    }
}

I am trying to make EJB request to different servers based on user input. Below is the code output with error when I do EJB request to second server.

Lookup serverUrl: https-remoting://10.2.212.73:18443 serviceName: ejb:SDS/SUSEngineEJB/SiteConfig!com.ballydev.sds.siteconfig.service.ISiteConfig
JNDI Properties 16:
    remote.connection.app1.port : 18443
    remote.connectionprovider.create.options.xnio.Options.SSL_ENABLED : true
    remote.connection.app1.password : Bally@1234
    remote.connection.app1.connect.options.xnio.Options.SASL_POLICY_NOANONYMOUS : true
    java.naming.factory.initial : .wildfly.naming.client.WildFlyInitialContextFactory
    java.naming.factory.url.pkgs : .jboss.ejb.client.naming
    remote.connection.app1.connect.options.jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL : 600000
    remote.connection.app1.connect.options.xnio.Options.SSL_STARTTLS : true
    remote.connections : app1
    remote.connection.app1.host : 10.2.212.73
    wildfly.naming.client.ejb.context : true
    remote.connection.app1.protocol : https-remoting
    remote.connection.app1.username : sds
######### Creating InitialContext for serverUrl: https-remoting://10.2.212.73:18443
Mar 14, 2025 12:22:16 AM .wildfly.naming.client.Version <clinit>
INFO: WildFly Naming version 1.0.15.Final
Mar 14, 2025 12:22:16 AM .wildfly.naming.client.ProviderEnvironment$Builder populateFromEnvironment
INFO: WFNAM00049: Usage of the legacy "remote.connections" property is deprecated; please use javax.naming.Context#PROVIDER_URL instead
Mar 14, 2025 12:22:16 AM .wildfly.security.Version <clinit>
INFO: ELY00001: WildFly Elytron version 1.19.1.Final
Mar 14, 2025 12:22:16 AM .jboss.ejb.client.naming.ejb.ejbURLContextFactory <clinit>
INFO: EJBCLIENT000064: .jboss.ejb.client.naming.ejb.ejbURLContextFactory is deprecated; new applications should use .wildfly.naming.client.WildFlyInitialContextFactory instead
Mar 14, 2025 12:22:16 AM .xnio.Xnio <clinit>
INFO: XNIO version 3.8.7.Final
Mar 14, 2025 12:22:16 AM .xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.8.7.Final
Mar 14, 2025 12:22:17 AM .jboss.threads.Version <clinit>
INFO: JBoss Threads version 2.4.0.Final
Mar 14, 2025 12:22:17 AM .jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 5.0.25.Final
Mar 14, 2025 12:22:17 AM .jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 4.0.44.Final
Site details from Server 1:
    99   type:0
    416  type:0
    417  type:0
    429  type:0
    432  type:0
    419  type:1
    428  type:1
    427  type:1
    423  type:1
    301  type:0
    302  type:0
    777  type:0
    646  type:0
Lookup serverUrl: https-remoting://10.2.38.112:18443 serviceName: ejb:SDS/SUSEngineEJB/SiteConfig!com.ballydev.sds.siteconfig.service.ISiteConfig
######### Closing context for https-remoting://10.2.212.73:18443
JNDI Properties 16:
    remote.connectionprovider.create.options.xnio.Options.SSL_ENABLED : true
    java.naming.factory.initial : .wildfly.naming.client.WildFlyInitialContextFactory
    java.naming.factory.url.pkgs : .jboss.ejb.client.naming
    remote.connection.app2.connect.options.xnio.Options.SSL_STARTTLS : true
    remote.connection.app2.username : sds
    remote.connection.app2.protocol : https-remoting
    remote.connections : app2
    wildfly.naming.client.ejb.context : true
    remote.connection.app2.password : Bally@1234
    remote.connection.app2.connect.options.xnio.Options.SASL_POLICY_NOANONYMOUS : true
    remote.connection.app2.host : 10.2.38.112
    remote.connection.app2.connect.options.jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL : 600000
    remote.connection.app2.port : 18443
######### Creating InitialContext for serverUrl: https-remoting://10.2.38.112:18443
Site details from Server 2:
    99   type:0
    416  type:1
    417  type:1
    429  type:1
    432  type:1
    419  type:0
    428  type:0
    427  type:0
    423  type:0
Making Request again to Server 2:
.jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
    at .jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:112)
    at .jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:78)
    at .xnio.IoFuture$HandlingNotifier.notify(IoFuture.java:215)
    at .xnio.AbstractIoFuture$NotifierRunnable.run(AbstractIoFuture.java:720)
    at .xnio.IoUtils$2.execute(IoUtils.java:71)
    at .xnio.AbstractIoFuture.runNotifier(AbstractIoFuture.java:693)
    at .xnio.AbstractIoFuture$NotifierState.doNotify(AbstractIoFuture.java:267)
    at .xnio.AbstractIoFuture$NotifierState.notifyFailed(AbstractIoFuture.java:253)
    at .xnio.AbstractIoFuture.setException(AbstractIoFuture.java:595)
    at .xnio.FutureResult.setException(FutureResult.java:85)
    at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:532)
    at .jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at .jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
    at .jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
    at .jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
    at .xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
    at java.base/java.lang.Thread.run(Thread.java:1583)
    Suppressed: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.212.73:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        at .jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:112)
        at .jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:78)
        at .xnio.IoFuture$HandlingNotifier.notify(IoFuture.java:215)
        at .xnio.AbstractIoFuture$NotifierRunnable.run(AbstractIoFuture.java:720)
        at .xnio.IoUtils$2.execute(IoUtils.java:71)
        at .xnio.AbstractIoFuture.runNotifier(AbstractIoFuture.java:693)
        at .xnio.AbstractIoFuture$NotifierState.doNotify(AbstractIoFuture.java:267)
        at .xnio.AbstractIoFuture$NotifierState.notifyFailed(AbstractIoFuture.java:253)
        at .xnio.AbstractIoFuture.setException(AbstractIoFuture.java:595)
        at .xnio.FutureResult.setException(FutureResult.java:85)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:532)
        at .jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at .jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at .jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at .jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1348)
        ... 2 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.212.73:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.212.73:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.212.73:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
    at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
    at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
    at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
    ... 6 more

I am currently facing an issue in WildFly 26.1.3 where an EJB Client dynamically switching between two WildFly EJB servers exhibits unexpected behavior. Issue Summary:

  1. First EJB call to Server 1 succeeds (Created a new Context and JNDI lookup for Server 1).
  2. First EJB call to Server 2 succeeds (Created a new Context and JNDI lookup for Server 2).
  3. Second call to Server 2 fails with an authentication error.

Below is the code which I am trying to execute.


package com.bally.test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;

import com.ballydev.sds.siteconfig.dto.SiteDTO;
import com.ballydev.sds.siteconfig.service.ISiteConfig;


public class TestSiteEJBService<T> {

    private static Map<String, Context> contextMap = new HashMap<>();

    public static final String  SiteConfigService = "ejb:SDS/SUSEngineEJB/SiteConfig!com.ballydev.sds.siteconfig.service.ISiteConfig";

    private static int x = 0;

    public static void main(String[] args) {
        System.setProperty("javax.ssl.trustStore", "keystore");

        try {
            TestSiteEJBService<ISiteConfig> serviceLocator = new TestSiteEJBService<ISiteConfig>();

            ISiteConfig configService1 = serviceLocator.fetchEJBService_16(SiteConfigService, "10.2.212.73", "18443");
            List<SiteDTO> siteDTOs = configService1.getAllSiteInfo();
            System.out.println("Site details from Server 1:");
            for (SiteDTO siteDTO : siteDTOs) {
                System.out.println("\t"+siteDTO.getNumber() +"\t type:"+  siteDTO.getProperty().getPropertyTypeId());
            }

            ISiteConfig configService2 = serviceLocator.fetchEJBService_16(SiteConfigService, "10.2.38.112", "18443");
            List<SiteDTO> siteDTORemotes = configService2.getAllSiteInfo();
            System.out.println("Site details from Server 2:");
            for (SiteDTO siteDTO : siteDTORemotes) {
                System.out.println("\t"+siteDTO.getNumber() +"\t type:"+  siteDTO.getProperty().getPropertyTypeId());
            }

            // This line of code throws error
            System.out.println("Making Request again to Server 2:");
            List<SiteDTO> siteDTORemotes2 = configService2.getAllSiteInfo();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @SuppressWarnings("unchecked")
    public T fetchEJBService_16(String serviceName, String hostIp, String portNumber) throws Exception {

        String serverUrl = getJndiUrl(hostIp, portNumber, true);
        System.out.println("Lookup serverUrl: " + serverUrl+ " serviceName: "+serviceName);
        Context context = contextMap.get(serverUrl);
        if (context == null) {

            for (String url : contextMap.keySet()) {
                Context existingContext = contextMap.get(url);
                existingContext.close();
                contextMap.remove(url);
                System.out.println("######### Closing context for "+url);
            }       

            Properties props = new Properties();

            props.setProperty(Context.INITIAL_CONTEXT_FACTORY, ".wildfly.naming.client.WildFlyInitialContextFactory");
            props.setProperty(Context.URL_PKG_PREFIXES, ".jboss.ejb.client.naming");
            props.setProperty("remote.connectionprovider.create.options..xnio.Options.SSL_ENABLED", "true");
            props.put("wildfly.naming.client.ejb.context", "true");

            List<String> serverUrlList = Arrays.asList(serverUrl.split(","));
            StringBuilder sb = new StringBuilder();

            for (String url : serverUrlList) {
                String protocol = url.substring(0, url.indexOf(":"));
                String host = url.substring(url.indexOf(":") + 3, url.lastIndexOf(":"));
                String port = url.substring(url.lastIndexOf(":") + 1);
                if (sb.length() > 0) {
                    sb.append(",");
                }
                String appName = "app" + (++x);
                props.put("remote.connection." + appName + ".protocol", protocol);
                props.put("remote.connection." + appName + ".host", host);
                props.put("remote.connection." + appName + ".port", port);
                props.put("remote.connection." + appName + ".username", "sds");
                props.put("remote.connection." + appName + ".password", "Bally@1234");
                props.put("remote.connection." + appName + ".connect.options..xnio.Options.SSL_STARTTLS", "true");
                props.put("remote.connection." + appName + ".connect.options..jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL", "600000");
                props.put("remote.connection." + appName + ".connect.options..xnio.Options.SASL_POLICY_NOANONYMOUS", "true");    

                sb.append(appName);
            }
            props.put("remote.connections", sb.toString());

            System.out.println("JNDI Properties 16:");
            for (Entry<Object,Object> propentry : props.entrySet()) {
                System.out.println("\t"+propentry.getKey() +" : "+ propentry.getValue());
            }

            System.out.println("######### Creating InitialContext for serverUrl: " + serverUrl);
            context = new InitialContext(props);
            contextMap.put(serverUrl, context);
        }

        T proxy = (T) context.lookup(serviceName);
        return proxy;
    }

    public static String getJndiUrl(String hostIp, String portNumber, boolean isSSLEnabled) {   
        String[] hostIPs = hostIp.split(",");
        StringBuilder sb = new StringBuilder();
        for(String hostIP : hostIPs) {
            if(isSSLEnabled){
                sb.append("https-remoting://").append(hostIP).append(":").append(portNumber);
            }else{
                sb.append("http-remoting://").append(hostIP).append(":").append(portNumber);
            }

            sb.append(",");
        }
        return sb.toString().substring(0, sb.length() - 1);
    }
}

I am trying to make EJB request to different servers based on user input. Below is the code output with error when I do EJB request to second server.

Lookup serverUrl: https-remoting://10.2.212.73:18443 serviceName: ejb:SDS/SUSEngineEJB/SiteConfig!com.ballydev.sds.siteconfig.service.ISiteConfig
JNDI Properties 16:
    remote.connection.app1.port : 18443
    remote.connectionprovider.create.options..xnio.Options.SSL_ENABLED : true
    remote.connection.app1.password : Bally@1234
    remote.connection.app1.connect.options..xnio.Options.SASL_POLICY_NOANONYMOUS : true
    java.naming.factory.initial : .wildfly.naming.client.WildFlyInitialContextFactory
    java.naming.factory.url.pkgs : .jboss.ejb.client.naming
    remote.connection.app1.connect.options..jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL : 600000
    remote.connection.app1.connect.options..xnio.Options.SSL_STARTTLS : true
    remote.connections : app1
    remote.connection.app1.host : 10.2.212.73
    wildfly.naming.client.ejb.context : true
    remote.connection.app1.protocol : https-remoting
    remote.connection.app1.username : sds
######### Creating InitialContext for serverUrl: https-remoting://10.2.212.73:18443
Mar 14, 2025 12:22:16 AM .wildfly.naming.client.Version <clinit>
INFO: WildFly Naming version 1.0.15.Final
Mar 14, 2025 12:22:16 AM .wildfly.naming.client.ProviderEnvironment$Builder populateFromEnvironment
INFO: WFNAM00049: Usage of the legacy "remote.connections" property is deprecated; please use javax.naming.Context#PROVIDER_URL instead
Mar 14, 2025 12:22:16 AM .wildfly.security.Version <clinit>
INFO: ELY00001: WildFly Elytron version 1.19.1.Final
Mar 14, 2025 12:22:16 AM .jboss.ejb.client.naming.ejb.ejbURLContextFactory <clinit>
INFO: EJBCLIENT000064: .jboss.ejb.client.naming.ejb.ejbURLContextFactory is deprecated; new applications should use .wildfly.naming.client.WildFlyInitialContextFactory instead
Mar 14, 2025 12:22:16 AM .xnio.Xnio <clinit>
INFO: XNIO version 3.8.7.Final
Mar 14, 2025 12:22:16 AM .xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.8.7.Final
Mar 14, 2025 12:22:17 AM .jboss.threads.Version <clinit>
INFO: JBoss Threads version 2.4.0.Final
Mar 14, 2025 12:22:17 AM .jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 5.0.25.Final
Mar 14, 2025 12:22:17 AM .jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 4.0.44.Final
Site details from Server 1:
    99   type:0
    416  type:0
    417  type:0
    429  type:0
    432  type:0
    419  type:1
    428  type:1
    427  type:1
    423  type:1
    301  type:0
    302  type:0
    777  type:0
    646  type:0
Lookup serverUrl: https-remoting://10.2.38.112:18443 serviceName: ejb:SDS/SUSEngineEJB/SiteConfig!com.ballydev.sds.siteconfig.service.ISiteConfig
######### Closing context for https-remoting://10.2.212.73:18443
JNDI Properties 16:
    remote.connectionprovider.create.options..xnio.Options.SSL_ENABLED : true
    java.naming.factory.initial : .wildfly.naming.client.WildFlyInitialContextFactory
    java.naming.factory.url.pkgs : .jboss.ejb.client.naming
    remote.connection.app2.connect.options..xnio.Options.SSL_STARTTLS : true
    remote.connection.app2.username : sds
    remote.connection.app2.protocol : https-remoting
    remote.connections : app2
    wildfly.naming.client.ejb.context : true
    remote.connection.app2.password : Bally@1234
    remote.connection.app2.connect.options..xnio.Options.SASL_POLICY_NOANONYMOUS : true
    remote.connection.app2.host : 10.2.38.112
    remote.connection.app2.connect.options..jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL : 600000
    remote.connection.app2.port : 18443
######### Creating InitialContext for serverUrl: https-remoting://10.2.38.112:18443
Site details from Server 2:
    99   type:0
    416  type:1
    417  type:1
    429  type:1
    432  type:1
    419  type:0
    428  type:0
    427  type:0
    423  type:0
Making Request again to Server 2:
.jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
    at .jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:112)
    at .jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:78)
    at .xnio.IoFuture$HandlingNotifier.notify(IoFuture.java:215)
    at .xnio.AbstractIoFuture$NotifierRunnable.run(AbstractIoFuture.java:720)
    at .xnio.IoUtils$2.execute(IoUtils.java:71)
    at .xnio.AbstractIoFuture.runNotifier(AbstractIoFuture.java:693)
    at .xnio.AbstractIoFuture$NotifierState.doNotify(AbstractIoFuture.java:267)
    at .xnio.AbstractIoFuture$NotifierState.notifyFailed(AbstractIoFuture.java:253)
    at .xnio.AbstractIoFuture.setException(AbstractIoFuture.java:595)
    at .xnio.FutureResult.setException(FutureResult.java:85)
    at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:532)
    at .jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at .jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
    at .jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
    at .jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
    at .xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
    at java.base/java.lang.Thread.run(Thread.java:1583)
    Suppressed: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.212.73:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        at .jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:112)
        at .jboss.ejb.protocol.remote.RemoteEJBReceiver$1.handleFailed(RemoteEJBReceiver.java:78)
        at .xnio.IoFuture$HandlingNotifier.notify(IoFuture.java:215)
        at .xnio.AbstractIoFuture$NotifierRunnable.run(AbstractIoFuture.java:720)
        at .xnio.IoUtils$2.execute(IoUtils.java:71)
        at .xnio.AbstractIoFuture.runNotifier(AbstractIoFuture.java:693)
        at .xnio.AbstractIoFuture$NotifierState.doNotify(AbstractIoFuture.java:267)
        at .xnio.AbstractIoFuture$NotifierState.notifyFailed(AbstractIoFuture.java:253)
        at .xnio.AbstractIoFuture.setException(AbstractIoFuture.java:595)
        at .xnio.FutureResult.setException(FutureResult.java:85)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:532)
        at .jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at .jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at .jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at .jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1348)
        ... 2 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.212.73:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.212.73:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.38.112:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
    Suppressed: .jboss.ejb.client.RequestSendFailedException: Error in connecting to Destination @https-remoting://10.2.212.73:18443 : Please check if the client and server are configured to use the same protocol and ports. 
        ... 17 more
    Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
        at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
        at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
        at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
        ... 6 more
Caused by: .wildfly.security.auth.AuthenticationException: JBREM000308: Authentication failed (no mechanisms left), tried: (none)
    at .jboss.remoting3.ConnectionPeerIdentityContext.doAuthenticate(ConnectionPeerIdentityContext.java:379)
    at .jboss.remoting3.ConnectionPeerIdentityContext.authenticate(ConnectionPeerIdentityContext.java:183)
    at .jboss.remoting3.EndpointImpl$3.lambda$handleDone$0(EndpointImpl.java:529)
    ... 6 more

Share Improve this question asked Mar 14 at 9:02 GaneshGanesh 1 0
Add a comment  | 

1 Answer 1

Reset to default 0

The issue got resolved by changing infinispan subsystem configuration for ejb in standalone-ha.xml

New Configuration:

        <cache-container name="ejb" default-cache="passivation" marshaller="PROTOSTREAM" aliases="sfsb" modules=".wildfly.clustering.ejb.infinispan">
            <local-cache name="passivation">
                <expiration interval="0"/>
                <file-store passivation="true" purge="false"/>
            </local-cache>
        </cache-container>

Old Configuration:

        <cache-container name="ejb" default-cache="dist" marshaller="PROTOSTREAM" aliases="sfsb" modules=".wildfly.clustering.ejb.infinispan">
            <transport lock-timeout="60000" />
            <distributed-cache name="dist">
                <locking isolation="REPEATABLE_READ" />
                <transaction mode="BATCH" />
                <expiration interval="0" />
                <file-store />
            </distributed-cache>
        </cache-container>
发布评论

评论列表(0)

  1. 暂无评论