title: Configuring one ear to call remote ejb3 on another ear in JBoss
body: <p>I am new to EJB3 and am missing something when it comes to accessing a @Remote @Stateless bean deployed as an ejb module inside an ear file.  I want to access a remote bean in lima.ear from soup.ear.</p>
  
  <p>Here is what I am doing now (somewhat abbreviated):</p>
  
  <pre><code>//deployed under lima.ear
  @Remote
  @Stateless
  public interface LimaBean {
      String sayName();
  }
  </code></pre>
  
  <p>I want to put LimaBean in the Soup:</p>
  
  <pre><code>//deployed in soup.ear
  @Stateless
  public class Soup implements SoupLocal {
  
      @EJB
      private LimaBean limaBean;
  
      public String taste() {
          return limaBean.sayName();
      }
  
   }
  </code></pre>
  
  <p>When I start JBoss I get the following error:</p>
  
  <p>java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container Soup: reference class: com.example.LimaBean ejbLink:  not used by any EJBs</p>
  
  <p>I have had a hard time finding out what this ejbLink is about, if that is the right path to go down.</p>
  
  <p><strong>If I deploy LimaBean as a jar file in jboss then everything works great!</strong></p>
  
  <p>I ran accross an article that had a section called "2.5.3. References between beans in different jars and different ears"</p>
  
  <p>(<a href="http://jonas.ow2.org/doc/howto/jboss2_4-to-jonas3_0/html/x111.html" rel="nofollow noreferrer">http://jonas.ow2.org/doc/howto/jboss2_4-to-jonas3_0/html/x111.html</a>)</p>
  
  <p>Example of jboss.xml file for SB_BrowseRegions:</p>
  
  <pre><code>&lt;jboss&gt;
      &lt;session&gt;
          &lt;ejb-name&gt;SB_BrowseRegions&lt;/ejb-name&gt;
          &lt;ejb-ref&gt;
              &lt;ejb-ref-name&gt;ejb/Region&lt;/ejb-ref-name&gt;
              &lt;jndi-name&gt;protocol://serverName/directory/RegionHome&lt;/jndi-name&gt;
          &lt;/ejb-ref&gt;
      &lt;/session&gt;
  &lt;/jboss&gt;
  </code></pre>
  
  <p>If I touch the soup.ear, after JBoss starts up then it deploys fine, so I am assuming I need to specify a dependency like the above article says.</p>
  
  <p>But even after it deploys then I get an error when accessing the remote LimaBean:</p>
  
  <p>Caused by: java.lang.IllegalArgumentException: Can not set com.soup.LimaBean field com.soup.Soup.limaBean to $Proxy147
      at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
      at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
      at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
      at java.lang.reflect.Field.set(Field.java:657)
      at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:115)
      ... 49 more</p>
  
  <p>I have tried a few things but, if anyone can point me in the right direction about this I would appreciate it.</p>