<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    JBoss EJB3 remote invocation from client app
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/zecas">zecas zecas</a> in <i>EJB 3.0</i> - <a href="http://community.jboss.org/message/545296#545296">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm trying to workout an EJB example with JBoss, but I'm having some trouble understanding some things, and making other things to work.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My Environment:<br/>- Windows XP;<br/>- JBoss 5.1.0.GA;<br/>- Eclipse.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The project is composed of an EAR with an EJB 3.0 and WAR module. Then I'll try to connect remotely in a client application to invoke the EJB.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So for a start, my EJB definition is:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>package</b></font> com.test;
&#160;
<font color="navy"><b>import</b></font> javax.ejb.Stateless;
&#160;
<font color="darkgreen">/**
 *&#160; Session Bean implementation class MyBean
 */</font>
@Stateless(name =&#160; <font color="red">"my-name"</font>, mappedName = <font color="red">"my-map"</font>)
<font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> MyBean implements&#160; MyRemote, MyLocal <font color="navy">{</font>
&#160;
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Default&#160; constructor. 
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> MyBean() <font color="navy">{</font>
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
&#160;&#160;&#160;&#160; <font color="navy"><b>public</b></font> String getMyCommon() <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> <font color="red">"My-Common"</font>;
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
&#160;&#160;&#160;&#160; <font color="navy"><b>public</b></font> String getMyRemote() <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> <font color="red">"My-Remote"</font>;
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
&#160;&#160;&#160;&#160; <font color="navy"><b>public</b></font> String getMyLocal() <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> <font color="red">"My-Local"</font>;
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>package</b></font> com.test;
&#160;
<font color="navy"><b>import</b></font> javax.ejb.Local;
&#160;
@Local
public&#160; <font color="navy"><b>interface</b></font> MyLocal <font color="navy">{</font>
&#160;
&#160;&#160;&#160; <font color="navy"><b>public</b></font> String getMyCommon();
&#160;&#160;&#160;&#160; <font color="navy"><b>public</b></font> String getMyLocal();
&#160;
<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>package</b></font> com.test;
&#160;
<font color="navy"><b>import</b></font> javax.ejb.Remote;
&#160;
@Remote
public&#160; <font color="navy"><b>interface</b></font> MyRemote <font color="navy">{</font>
&#160;
&#160;&#160;&#160; <font color="navy"><b>public</b></font> String getMyCommon();
&#160;&#160;&#160;&#160; <font color="navy"><b>public</b></font> String getMyRemote();
&#160;
<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><br/>My ejb-jar.xml in EJB module META-INF, has no definitions:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;?xml version="1.0" encoding="ASCII"?&gt;</span>
<span class="jive-xml-tag"><span>&lt;ejb-jar&#160; xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"&#160; xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>"&#160; xmlns:ejb="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" target="_blank">http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd</a><span>"&#160; xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>&#160; </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" target="_blank">http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd</a><span>" version="3.0"&gt;</span></span>
&#160;&#160; <span class="jive-xml-tag">&lt;display-name&gt;</span>my-ejb<span class="jive-xml-tag">&lt;/display-name&gt;</span>
<span class="jive-xml-tag">&lt;/ejb-jar&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My web.xml in WAR module has no reference to EJB:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="jive-xml-tag"><span>&lt;web-app&#160; xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"&#160; xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>"&#160; xmlns:web="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" target="_blank">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd</a><span>"&#160; xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>&#160; </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" target="_blank">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd</a><span>" id="WebApp_ID"&#160; version="2.5"&gt;</span></span>
&#160; <span class="jive-xml-tag">&lt;display-name&gt;</span>my-web<span class="jive-xml-tag">&lt;/display-name&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;welcome-file-list&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;welcome-file&gt;</span>index.html<span class="jive-xml-tag">&lt;/welcome-file&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;/welcome-file-list&gt;</span>
&#160; <span class="jive-xml-tag">&lt;servlet&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;servlet-name&gt;</span>Faces Servlet<span class="jive-xml-tag">&lt;/servlet-name&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;servlet-class&gt;</span>javax.faces.webapp.FacesServlet<span class="jive-xml-tag">&lt;/servlet-class&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;load-on-startup&gt;</span>1<span class="jive-xml-tag">&lt;/load-on-startup&gt;</span>
&#160; <span class="jive-xml-tag">&lt;/servlet&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;servlet-mapping&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;servlet-name&gt;</span>Faces&#160; Servlet<span class="jive-xml-tag">&lt;/servlet-name&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;url-pattern&gt;</span>/faces/*<span class="jive-xml-tag">&lt;/url-pattern&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;/servlet-mapping&gt;</span>
&#160; <span class="jive-xml-tag">&lt;servlet-mapping&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;servlet-name&gt;</span>Faces Servlet<span class="jive-xml-tag">&lt;/servlet-name&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;url-pattern&gt;</span>*.jsf<span class="jive-xml-tag">&lt;/url-pattern&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;/servlet-mapping&gt;</span>
<span class="jive-xml-tag">&lt;/web-app&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My application.xml describes the modules:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
<span class="jive-xml-tag"><span>&lt;application&#160; xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>"&#160; xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"&#160; xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>&#160; </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee/application_5.xsd" target="_blank">http://java.sun.com/xml/ns/javaee/application_5.xsd</a><span>" version="5"&gt;</span></span>
&#160;&#160; <span class="jive-xml-tag">&lt;display-name&gt;</span>my-ear<span class="jive-xml-tag">&lt;/display-name&gt;</span>
&#160; <span class="jive-xml-tag">&lt;module&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;web&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;web-uri&gt;</span>my-web-0.0.1-SNAPSHOT.war<span class="jive-xml-tag">&lt;/web-uri&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;context-root&gt;</span>/my-web<span class="jive-xml-tag">&lt;/context-root&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/web&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;/module&gt;</span>
&#160; <span class="jive-xml-tag">&lt;module&gt;</span>
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;ejb&gt;</span>my-ejb-0.0.1-SNAPSHOT.jar<span class="jive-xml-tag">&lt;/ejb&gt;</span>
&#160; <span class="jive-xml-tag">&lt;/module&gt;</span>
<span class="jive-xml-tag">&lt;/application&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The WAR has a small test page, that injects the @EJB local interface, and successfully gets data, so I assume no other config should be necessary (for now, at least).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For deployment, I just copied the EAR to deploy directory. No errors, and checking JMX Console I can find the following info:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">jboss.deployment
#&#160; id="jboss.j2ee:ear=my-ear-0.0.1-SNAPSHOT.ear,jar=my-ejb-0.0.1-SNAPSHOT.jar,name=my-name,service=EJB3",type=Component
#&#160;&#160; id="jboss.j2ee:ear=my-ear-0.0.1-SNAPSHOT.ear,jar=my-ejb-0.0.1-SNAPSHOT.jar,name=my-name,service=EJB3_endpoint",type=Component
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I then created a small standalone project, with following code:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Hashtable environment = <font color="navy"><b>new</b></font> Hashtable();
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; environment.put(Context.INITIAL_CONTEXT_FACTORY,&#160; <font color="red">"org.jnp.interfaces.NamingContextFactory"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; environment.put(Context.URL_PKG_PREFIXES,&#160; <font color="red">"org.jboss.naming:org.jnp.interfaces"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; environment.put(Context.PROVIDER_URL, <font color="red">"jnp://127.0.0.1:1099"</font>); <font color="darkgreen">// remote&#160; machine IP</font>
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; InitialContext context = <font color="navy"><b>null</b></font>;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>try</b></font> <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; context = <font color="navy"><b>new</b></font> InitialContext(environment);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Object obj = context.lookup(<font color="red">"my-name"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(<font color="red">"--&gt;&gt; lookup object successfully"</font>);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>catch</b></font>(Throwable ex) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ex.printStackTrace();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>finally</b></font> <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>if</b></font>( context!=<font color="navy"><b>null</b></font> ) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; context.close();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When executing, I get the exception:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">javax.naming.NameNotFoundException: my-name not bound
&#160;&#160;&#160; at&#160; org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
&#160;&#160;&#160; at&#160; org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
&#160;&#160;&#160; at&#160; org.jnp.server.NamingServer.getObject(NamingServer.java:785)
&#160;&#160;&#160; at&#160; org.jnp.server.NamingServer.lookup(NamingServer.java:443)
&#160;&#160;&#160; at&#160; sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
&#160;&#160;&#160; at&#160; sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
&#160;&#160;&#160;&#160; at&#160; sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
&#160;&#160;&#160;&#160; at java.lang.reflect.Method.invoke(Method.java:597)
&#160;&#160;&#160; at&#160; sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
&#160;&#160;&#160;&#160; at sun.rmi.transport.Transport$1.run(Transport.java:159)
&#160;&#160;&#160; at&#160; java.security.AccessController.doPrivileged(Native Method)
&#160;&#160;&#160; at&#160; sun.rmi.transport.Transport.serviceCall(Transport.java:155)
&#160;&#160;&#160; at&#160; sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
&#160;&#160;&#160;&#160; at&#160; sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
&#160;&#160;&#160;&#160; at&#160; sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
&#160;&#160;&#160;&#160; at&#160; java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
&#160;&#160;&#160;&#160; at&#160; java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
&#160;&#160;&#160;&#160; at java.lang.Thread.run(Thread.java:619)
&#160;&#160;&#160; at&#160; sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
&#160;&#160;&#160;&#160; at&#160; sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
&#160;&#160;&#160;&#160; at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
&#160;&#160;&#160; at&#160; org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
&#160;&#160;&#160; at&#160; org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
&#160;&#160;&#160;&#160; at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
&#160;&#160;&#160;&#160; at javax.naming.InitialContext.lookup(InitialContext.java:392)
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Changing the lookup to:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">Object obj = context.lookup(<font color="red">"my-map"</font>);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Works ok. Lookup goes successfull.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Replacing with:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">MyRemote myRemote = (MyRemote) context.lookup(<font color="red">"my-map"</font>);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Will return:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">java.lang.ClassCastException: javax.naming.Reference cannot be cast to&#160; com.test.MyRemote
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My client application has dependency to the EJB client jar, which only has MyRemote and MyLocal classes, and a dependency to jbossall-client-3.2.3.jar.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If I narrow:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">MyRemote myRemote = (MyRemote) PortableRemoteObject.narrow(
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; context.lookup(<font color="red">"my-map"</font>),
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; MyRemote.class
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; );
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'll get:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">java.lang.ClassCastException
&#160;&#160;&#160; at&#160; com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
&#160;&#160;&#160;&#160; at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
&#160;&#160;&#160;&#160; ... 2 more
Caused by: java.lang.ClassCastException:&#160; javax.naming.Reference cannot be cast to org.omg.CORBA.Object
&#160;&#160;&#160; at&#160; com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
&#160;&#160;&#160;&#160; ... 3 more
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>What am I doing wrong?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/545296#545296">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB 3.0 at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>