java.lang.ClassCastException: org.jboss.ejb.client.naming.ejb.EjbNamingContext cannot be cast to
<p>I have an EJB stateless project (helloworld) running under Wildfly 8.2.1 Final server with java 1.7 and a client app with java 1.8. I'm getting an error. Thank you</p>

<blockquote>
  <p>Exception in thread "main" java.lang.ClassCastException:
  org.jboss.ejb.client.naming.ejb.EjbNamingContext cannot be cast to
  com.aburak.sb.SessionBeanRemote   at
  com.aburak.sb.Driver.main(Driver.java:15)</p>
</blockquote>

<p>this is my Driver Class which is Client Application</p>

<pre><code>public class Driver {
    public static void main(String[] args) throws NamingException {
            Context context=Driver.getInitialContext();
            SessionBeanRemote sbRemote= (SessionBeanRemote) context.lookup("ejb:SessionBean/SessionBean!com.aburak.sb.SessionBeanRemote");
            sbRemote.sessionBeanMethod();
    }
    public static Context getInitialContext() throws NamingException{
        Properties properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        properties.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        properties.setProperty(Context.PROVIDER_URL, "http://127.0.0.1:8080");

        return new InitialContext(properties);
    }
}
</code></pre>

<p>Remote BeanSession  </p>

<pre><code>@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class SessionBean implements  SessionBeanRemote, SessionBeanLocal{

private static final long serialVersionUID = -7201692010023776738L;

@Override
public void sessionBeanMethod() {
    System.out.println("SessionBean executed...");

}
</code></pre>

<p>SessionBeanRemote </p>

<pre><code>@Remote
public interface SessionBeanRemote extends SessionBeanIF{

}
</code></pre>

<p>(SessionBeanLocal is exact the same SessionBeanRemote except @Local annotation)</p>

<p>SessionBeanIF</p>

<pre><code>public interface SessionBeanIF extends Serializable{
public void sessionBeanMethod();
}
</code></pre>

<p>and this is the client Drive class</p>

<pre><code>public class Driver {
    public static void main(String[] args) throws NamingException {
            Context context=Driver.getInitialContext();
            SessionBeanRemote sbRemote= (SessionBeanRemote) context.lookup("ejb:SessionBean/SessionBean!com.aburak.sb.SessionBeanRemote");
            sbRemote.sessionBeanMethod();
    }
    public static Context getInitialContext() throws NamingException{
        Properties properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        properties.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        properties.setProperty(Context.PROVIDER_URL, "http://127.0.0.1:8080");

        return new InitialContext(properties);
    }
}
</code></pre>

<p>SessionBeanClient >> pom.xml</p>

<pre><code>&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.wildfly&lt;/groupId&gt;
        &lt;artifactId&gt;wildfly-ejb-client-bom&lt;/artifactId&gt;
        &lt;version&gt;8.2.1.Final&lt;/version&gt;
        &lt;type&gt;pom&lt;/type&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.wildfly&lt;/groupId&gt;
        &lt;artifactId&gt;wildfly-jms-client-bom&lt;/artifactId&gt;
        &lt;version&gt;8.2.1.Final&lt;/version&gt;
        &lt;type&gt;pom&lt;/type&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;
</code></pre>

<p>SessionBean >> pom.xml</p>

<pre><code>&lt;dependency&gt;
  &lt;groupId&gt;javax.ejb&lt;/groupId&gt;
  &lt;artifactId&gt;javax.ejb-api&lt;/artifactId&gt;
  &lt;version&gt;3.2&lt;/version&gt;
  &lt;scope&gt;compile&lt;/scope&gt;
&lt;/dependency&gt;
</code></pre>

<p>I follow <a href="https://www.youtube.com/watch?v=JrDT-PYhG20" rel="nofollow noreferrer">this tutorial video</a> but i change something app server etc.
and also search the error find <a href="https://stackoverflow.com/questions/36219951/error-casting-context-lookup-returned-object-to-ejb3-remote-object-interfac">this</a> but it didn't solve my problem.</p>

<p>This is my <a href="https://i.stack.imgur.com/ZZWdu.png" rel="nofollow noreferrer">Package explorer</a></p>

<p>Thanks four your help. </p>