Q: Migration to Wildfly 21 from JBoss AS7.2 We are currently migrating our JBoss App-Server to Wildfly V21. We used this code to create an initial context to a cluster that uses our own LoadBalancer.
Old JBoss Code:
        Properties env = new Properties();
        env.put("remote.clusters", "ejb");
        env.put("remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
        env.put("remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED", "false");
        env.put("jboss.naming.client.ejb.context", "true");
        env.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
        env.put("deployment.node.selector", "our.packege.to.own.RandomServerSelector");

        StringBuilder connections = new StringBuilder();
        int counter = 0;
        for (String hostAndPort : hostAndPortList) {
            env.put("remote.connection.s" + counter + ".username", user);
            env.put("remote.connection.s" + counter + ".password", pwd);
            env.put("remote.connection.s" + counter + ".host", hostAndPort.split(":")[0]);
            env.put("remote.connection.s" + counter + ".port", hostAndPort.split(":")[1]);
            env.put("remote.connection.s" + counter + ".connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
            env.put("remote.connection.s" + counter + ".connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS",
                "JBOSS-LOCAL-USER");
            env.put("remote.connection.s" + counter + ".connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
            env.put("remote.connection.s" + counter + ".connect.timeout", "2000");

            // see https://community.jboss.org/thread/205784?start=15&tstart=180 /
            // https://issues.jboss.org/browse/EJBCLIENT-52
            env.put("remote.connection.s" + counter + "connect.options.org.jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL",
                "300000");

            // fill connections list
            if (connections.length() > 0) {
                connections.append(",");
            }
            connections.append("s" + counter);

            // prepare for next server
            counter++;
        }

        // connections-list
        env.put("remote.connections", connections.toString());

        EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(env);
        ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
        EJBClientContext.setSelector(selector);

        // create the initial context
        Properties p = new Properties();
        p.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); 
        _initialContext = new InitialContext(p);

For Wildfly 21 this do not works anymore so i spent a lot of time to find a way that works. Now i found the right implmentation for the legacy behavior. My Question is how must be the call implemented with remote+http (Context.PROVIDER_URL)
Current Code that works in legacy mode:
        Properties env = new Properties();
        env.put("remote.clusters", "ejb");
        env.put("remote.cluster.ejb.username", user);
        env.put("remote.cluster.ejb.password", pwd);

        env.put("remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
        env.put("remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED", "false");

        env.put("deployment.node.selector", "path.to.our.RandomServerSelector");

        env.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");

        StringBuilder connections = new StringBuilder();

        int sCount = 0;
        for (String host : hostsAndPorts) {
            env.put("remote.connection.s" + sCount + ".username", user);
            env.put("remote.connection.s" + sCount + ".password", pwd);
            env.put("remote.connection.s" + sCount + ".host", host.split(":")[0]);
            env.put("remote.connection.s" + sCount + ".port", host.split(":")[1]);
            env.put("remote.connection.s" + sCount + ".connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS",
                "false");
            env.put("remote.connection.s" + sCount + ".connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS",
                "JBOSS-LOCAL-USER");
            env.put("remote.connection.s" + sCount + ".connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT",
                "false");
            env.put("remote.connection.s" + sCount + ".connect.timeout", "2000");
            // fill connections list
            if (connections.length() > 0) {
                connections.append(",");
            }
            connections.append("s" + sCount);
            // prepare for next server
            sCount++;
        }

        // connections-list
        env.put("remote.connections", connections.toString());
        env.put("jboss.naming.client.ejb.context", true);
        
        
        JBossEJBProperties ejbProperties = JBossEJBProperties.fromProperties("ejb-client.properties", env);
        JBossEJBProperties.getContextManager().setGlobalDefault(ejbProperties);

        env = new Properties();
        env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        return new InitialContext(env);

