title: Nightmare with Jboss 7.1.1 Final
body: <p>I've been struggling with JBossAS and EJB, but can't solve the simplest question.</p>
  
  <p>I've looked through a lot of manuals, tutorial, guidelines, blogs and couldn't find the answer.</p>
  
  <p>I wrote two apps: server-side.jar and client-app. 1st app was assebled by maven and deployed on Jboss. Here it is:</p>
  
  <p>RemoteCalculator.java:</p>
  
  <pre><code>package com.calculator;
  import javax.ejb.Remote;
  
  public interface RemoteCalculator {
      int add( int op1, int op2 );
  }
  </code></pre>
  
  <p>CalculatorBean.java:</p>
  
  <pre><code>package com.calculator;
  import javax.ejb.Remote;
  import javax.ejb.Stateless;
  
  @Stateless
  @Remote(RemoteCalculator.class)
  public class CalculatorBean implements RemoteCalculator {
      @Override
      public int add( int op1, int op2 ) {
          return op1 + op2;
      }
  }
  </code></pre>
  
  <hr>
  
  <p>I've assembled "ejb-remote-stateless-1.0-SNAPSHOT.jar" and put it on Jboss. Satrted AS and have got "ejb-remote-stateless-1.0-SNAPSHOT.jar.deployed". Then I created 2nd simple console app - client for invocation CalculatorBean:</p>
  
  <pre><code>import com.calculator.RemoteCalculator;
  import org.jboss.sasl.JBossSaslProvider;
  
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  import java.security.Security;
  import java.util.Hashtable;
  
  public class EJBClient {
      private static void invokeStatelessBean() throws NamingException {
          RemoteCalculator statelessRemoteCalculator = lookupRemoteStatelessCalculator();
          int sum = statelessRemoteCalculator.add( 3, 4 );
          System.out.println( "sum = " + sum );
      }
  
  private static RemoteCalculator lookupRemoteStatelessCalculator() throws NamingException {
      Security.addProvider( new JBossSaslProvider() );
      final Hashtable&lt;String, String&gt; p = new Hashtable&lt;String, String&gt;();
      p.put( Context.PROVIDER_URL, "remote://127.0.0.1:4447" );
      p.put( Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming" );
      p.put( Context.SECURITY_PRINCIPAL, "admin" );
      p.put( Context.SECURITY_CREDENTIALS, "jboss" );
      p.put( Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory" );
      final Context context = new InitialContext( p );
  
      return ( RemoteCalculator ) context
              .lookup( "java:/ejb-remote-stateless-1.0-SNAPSHOT/CalculatorBean!com.calculator.RemoteCalculator" );
  }
  
  public static void main( String... args ) {
      try {
          invokeStatelessBean();
      } catch ( NamingException e ) {
          e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And I've got this exception:</p>
  
  <pre><code>ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: 
  
  Authentication failed: all available authentication mechanisms failed
  javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed]
  </code></pre>
  
  <p>I begg you to say me what is wrong? What have I done wrong? Please help!!!</p>