0 Replies Latest reply on Aug 27, 2016 1:38 AM by kayvan.jamshidi

    Remote connection failed: javax.security.sasl.SaslException: Authentication failed: the server presented no authentication mechanisms

    kayvan.jamshidi

      I wrote a example remote ejb client  that connects to remote server wildfly 9.0.2 final ,

      here my code :

       

       

       

          public class EjbRemoteClient {

          public static void main(String[] args) {

       

              // Connection to Wildfly Server instance

              String host = "remote ip server";

              String port = "7273"; // Wildfly HTTP port

       

              Context remotingContext;

              try {

                  remotingContext = createRemoteEjbContext(host, port);

              } catch (NamingException e) {

                  System.err.println("Error setting up remoting context");

                  e.printStackTrace();

                  return;

              }

       

              String ejbUrl = "ejb:/myserver_core/someinterfaceImpl!com.art.dataserver.api.ejb.inf.BulkRemoteInf";

       

              someinterface mtnBulk;

              try {

                  mtnBulk = createEjbProxy(remotingContext, ejbUrl, someinterface .class);

              } catch (NamingException e) {

                  System.err.println("Error resolving bean");

                  e.printStackTrace();

                  return;

              } catch (ClassCastException e) {

                  System.err.println("Resolved EJB is of wrong type");

                  e.printStackTrace();

                  return;

              }

       

              // Call remote method with parameter

              try {

                 

                  AimedJobsModel aimedJobsModel =mtnBulk.getAimedJobs();

              } catch (Exception e) {

                  System.err.println("Error accessing remote bean");

                  e.printStackTrace();

                  return;

              }

          }

       

          /**

           * Create Remote EJB Context.

           *

           * @return remote EJB context

           * @throws NamingException

           *             if creating the context fails

           */

          private static Context createRemoteEjbContext(String host, String port) throws NamingException {

       

              Hashtable<Object, Object> props = new Hashtable<>();

       

              props.put(INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

              props.put(URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

       

              props.put("jboss.naming.client.ejb.context", false);

              props.put("org.jboss.ejb.client.scoped.context", true);

       

              //props.put("endpoint.name", "client-endpoint");

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

              props.put("remote.connections", "default");

              props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", false);

              props.put(Context.SECURITY_PRINCIPAL, "myusername");

              props.put(Context.SECURITY_CREDENTIALS, "mypass");

              props.put(PROVIDER_URL, "http-remoting://" + host + ":" + port);

              props.put("remote.connection.default.host", host);

              props.put("remote.connection.default.port", port);

              props.put("remote.connection.default.connect.timeout", "15000");

              return new InitialContext(props);

          }

       

          /**

           * Get a proxy for a remote EJB.

           *

           * @param remotingContext

           *            remote EJB context

           * @param ejbUrl

           *            URL of the EJB

           * @param ejbInterfaceClass

           *            class of the remote interface of the EJB

           * @param <T>

           *            type of the EJB remote interface

           * @return EJB proxy

           * @throws NamingException

           *             if the name resolving fails

           * @throws ClassCastException

           *             if the EJB proxy is not of the given type

           */

          @SuppressWarnings("unchecked")

          private static <T> T createEjbProxy(Context remotingContext, String ejbUrl, Class<T> ejbInterfaceClass)

                  throws NamingException, ClassCastException {

              Object resolvedproxy = remotingContext.lookup(ejbUrl);

              return (T) resolvedproxy;

          }}

       

       

      here is important sections of standalone-full.xml on server side :

       

          <subsystem xmlns="urn:jboss:domain:remoting:3.0">

                  <endpoint/>

                  <http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>

                  <outbound-connections>

                      <remote-outbound-connection name="remote-ejb-connection" outbound-socket-binding-ref="remote-ejb" username="myusername" security-realm="ejb-security-realm">

                          <properties>

                              <property name="SASL_POLICY_NOANONYMOUS" value="false"/>

                              <property name="SSL_ENABLED" value="false"/>

                          </properties>

                      </remote-outbound-connection>

                  </outbound-connections>

              </subsystem>

       

      and my exception is :

       

        

       

          Aug 25, 2016 8:48:15 PM org.xnio.Xnio <clinit>

      INFO: XNIO version 3.2.2.Final

      Aug 25, 2016 8:48:15 PM org.xnio.nio.NioXnio <clinit>

      INFO: XNIO NIO Implementation Version 3.2.2.Final

      Aug 25, 2016 8:48:16 PM org.jboss.remoting3.EndpointImpl <clinit>

      INFO: JBoss Remoting version 4.0.3.Final

      Aug 25, 2016 8:48:16 PM org.jboss.remoting3.remote.RemoteConnection handleException

      ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: the server presented no authentication mechanisms

      Aug 25, 2016 8:48:16 PM org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector setupEJBReceivers

      WARN: Could not register a EJB receiver for connection to "remote ip server":7273

      java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: the server presented no authentication mechanisms

          at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:92)

          at org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:77)

          at org.jboss.ejb.client.remoting.RemotingConnectionManager.getConnection(RemotingConnectionManager.java:51)

          at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:155)

          at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:115)

          at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createIdentifiableEjbClientContext(EjbNamingContext.java:258)

          at org.jboss.ejb.client.naming.ejb.EjbNamingContext.setupScopedEjbClientContextIfNeeded(EjbNamingContext.java:123)

          at org.jboss.ejb.client.naming.ejb.EjbNamingContext.<init>(EjbNamingContext.java:98)

          at org.jboss.ejb.client.naming.ejb.ejbURLContextFactory.getObjectInstance(ejbURLContextFactory.java:38)

          at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:601)

          at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:550)

          at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:345)

          at javax.naming.InitialContext.lookup(InitialContext.java:417)

          at com.illucit.ejbremote.EjbRemoteClient.createEjbProxy(EjbRemoteClient.java:149)

          at com.illucit.ejbremote.EjbRemoteClient.main(EjbRemoteClient.java:52)

      Caused by: javax.security.sasl.SaslException: Authentication failed: the server presented no authentication mechanisms

          at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:388)

          at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:242)

          at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)

          at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:196)

          at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:110)

          at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)

          at org.xnio.ChannelListeners$DelegatingChannelListener.handleEvent(ChannelListeners.java:1092)

          at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)

          at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)

          at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:87)

          at org.xnio.nio.WorkerThread.run(WorkerThread.java:539)

          at ...asynchronous invocation...(Unknown Source)

          at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:272)

          at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:388)

          at org.jboss.ejb.client.remoting.EndpointPool$PooledEndpoint.connect(EndpointPool.java:187)

          at org.jboss.ejb.client.remoting.NetworkUtil.connect(NetworkUtil.java:153)

          at org.jboss.ejb.client.remoting.NetworkUtil.connect(NetworkUtil.java:133)

          at org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:75)

          ... 13 more

       

      Aug 25, 2016 8:48:16 PM org.jboss.ejb.client.EJBClient <clinit>

      INFO: JBoss EJB Client version 2.0.1.Final

      Aug 25, 2016 8:48:16 PM org.jboss.remoting3.remote.RemoteConnection handleException

      ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: the server presented no authentication mechanisms

      Error accessing remote bean

      java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:, moduleName:dataserver_core, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@62e7f11d

          at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:749)

          at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)

          at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)

          at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253)

          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198)

          at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181)

          at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)

          at com.sun.proxy.$Proxy2.getAimedJobs(Unknown Source)

          at com.illucit.ejbremote.EjbRemoteClient.main(EjbRemoteClient.java:70)

      please help me