title: How can I inject an EJB from another application on the same GlassFish Server?
body: <p>I have two applications running on my local glassfish server. One to rent bicylces and one to buy train tickets. I now wanted to call a remote ejb from the train application to allow the rental of bicycles for the chosen time but I'm not really sure how to do it. I already tried a few different approaches. Both applications are in different packages and the train application has to know the bicycle remote interface but I don't know how to accomplish that.</p>
  
  <p>The remote interface (bicyle app):</p>
  
  <pre><code>@Remote
  public interface FahrradRemote {
      public List&lt;Fahrrad&gt; findAvaible(Date start, Date end);
      public void addAuftrag(Fahrrad fahrrad, Date startDate, Date endDate);
      public boolean login(String name, String passwort);
  }
  </code></pre>
  
  <p>Bicycle EJB I want to call:</p>
  
  <pre><code>@Stateless(name="FahrradService",mappedName="FahrradService")
  public class FahrradService implements javax.ejb.SessionBean, FahrradRemote, Serializable {
  
      @PersistenceContext
      private EntityManager em;
      Kunde customer;
  ...
  }
  </code></pre>
  
  <p>Beginning of the train app:</p>
  
  <pre><code>@Named
  @SessionScoped
  public class BahnPM implements Serializable {
  
      private String startStation;
      private String zielStation;
      private String loginName;
      private String loginPasswort;
      private String customerName;
      private String startDateString;
      private Date startDate;
      private List&lt;Fahrt&gt; available;
      private List stations;
  
  
      @EJB
      private BahnService service;
  
      @EJB(mappedName="FahrradService")
      private static FahrradRemote fahrradService;
  
      public BahnPM() {
      }
  
      ...
  }
  </code></pre>
  
  <p>Error I get is a class not found exception, which i can understand because it's a different application and my train app doesn't know "FahrradRemote" but how can I inject that EJB?</p>