title: Classes of referenced EJB project not found in (the referencing) Web project
body: <p>I'm learning J2EE and EJB and I've run into a strange problem. This is my project setup:</p>
  
  <p>I'm using Glassfish 3.1 and Eclipse 3.7. I have two projects in Eclipse:</p>
  
  <ol>
  <li>An EJB 3.0 compliant project, <code>myEjbProject</code>  </li>
  <li>A Dynamic Web Project, <code>myWebProject</code></li>
  </ol>
  
  <p>I'm injecting an EJB session bean <code>mySessionBeanPackage.mySessionBean</code> from <code>myEjbProject</code> into a servlet <code>myServletPackage.myServlet</code> in <code>myWebProject</code> and then (in the servlet) calling a simple method defined in the session bean.</p>
  
  <p>I've provided <code>myWebProject</code> with a reference to <code>myEjbProject</code> (using the Properties -> Project References dialog). However, for some reason, the server is <strong>unable</strong> to find the session bean. The exact error I get is:</p>
  
  <blockquote>
    <p>SEVERE: Class [ LmySessionBeanPackage/mySessionBean ] not found. Error while loading [ class myServletPackage.myServlet ]</p>
  </blockquote>
  
  <p>Note that <em>both</em> the EJB project and the web project have been published to the server and I've double-checked that the class file generated for the bean is, in fact, present on the server (so I can't think of a reason why the server isn't able to find them).</p>
  
  <p>Can anyone tell me what I'm doing wrong?</p>
  
  <p>I've also tried</p>
  
  <ul>
  <li><p>adding the classes folder of <code>myEjbProject</code> explicitly to the Java Build Path -> Libraries list of <code>myWebProject</code>. This is in addition to the project reference (although I think adding a project reference should have sufficed in the first place). Anyway, it makes no difference (same error message as before).</p></li>
  <li><p>creating a JAR file from <code>myEjbProject</code> using the Export -> EJB Jar File option (I don't want to get into writing an Ant script at the moment). I then put this JAR in the Java Build Path -> Libraries section of <code>myWebProject</code>. This approach does not solve the problem either (same error message as before).</p></li>
  <li><p>modifying the session bean to have</p>
  
  <ul>
  <li>no interface</li>
  <li>a local interface</li>
  <li>a remote interface  </li>
  </ul>
  
  <p>and modifying the injection accordingly. E.g., for a bean with only a local interface, I used:  </p>
  
  <blockquote>
    <p><code>@EJB mySessionBeanPackage.mySessionBeanLocal myBean</code></p>
  </blockquote>
  
  <p>This approach did not solve the problem either (same error message as before).</p></li>
  <li><p>doing away with <code>myEjbProject</code> altogether and adding the session bean to <code>myWebProject</code> as <code>myServletPackage.mySessionBean</code> (same package as the servlet). In this case, I can inject the session bean successfully into the servlet using</p>
  
  <blockquote>
    <p><code>@EJB mySessionBeanPackage.mySessionBean myBean</code></p>
  </blockquote></li>
  <li><p>doing away with <code>myEjbProject</code> altogether and adding the session bean to <code>myWebProject</code> as <code>mySessionBeanPackage.mySessionBean</code> (a new package). In this case also, I can inject the session bean successfully into the servlet using    </p>
  
  <blockquote>
    <p><code>@EJB mySessionBeanPackage.mySessionBean myBean</code>    </p>
  </blockquote></li>
  </ul>