title: EJB3 Injection failed on JBoss AS 5.1 Error: ClassLoaders of value and target are not equal
body: <p>I'm trying to inject a SLSB into a servlet but got the following error:</p>
  
  <p><code>ERROR [org.jboss.injection.lang.reflect.FieldBeanProperty] (HDScanner) failed to set value Proxy to jboss.j2ee:ear=contact.ear,jar=contact-ejb.jar,name=ContactServiceBean,service=EJB3 implementing [interface com.test.contactservice.ContactService] on field private com.test.contactservice.ContactServiceBean com.test.contactmanager.controller.ContactController.cBean; Reason: ClassLoaders of value and target are not equal</code></p>
  
  <p>Here is the annotation on the EJB:</p>
  
  <pre><code>@Stateless(name="ContactServiceBean")
  @Local
  public class ContactServiceBean implements ContactService {
  </code></pre>
  
  <p>The servlet has the following annotation:</p>
  
  <pre><code>@EJB(mappedName="contact/ContactServiceBean/local")
  private ContactServiceBean cBean;
  </code></pre>
  
  <p>My web.xml uses 2.5 schema:</p>
  
  <pre><code>&lt;web-app version="2.5"
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  </code></pre>
  
  <p>Could someone please take a look?  Any suggestion would be much appreciated. </p>
  
  <hr>
  
  <p>@AntonioP:  I thought packaging the EJB into the war only works in EJB3.1.  I believe it's not supported in JBoss 5.1.</p>
  
  <p>I've tried renaming the mappedName as you suggested but got NameNotFoundException.  I forgot to mention in my original post that the EJB is bounded to the following entry in Global JNDI:</p>
  
  <p>[org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] (HDScanner) Binding the following Entries in Global JNDI:</p>
  
  <pre><code>    contact/ContactServiceBean/local - EJB3.x Default Local Business Interface
      contact/ContactServiceBean/local-com.test.contactservice.ContactService - EJB3.x Local Business Interface
  </code></pre>
  
  <p>My EAR has the following directory structure:</p>
  
  <pre><code>contact.ear
   |
   ___META-INF
        |
        ___application.xml
   |
   ___contact.war
   |
   ___contact-ejb.jar
  </code></pre>
  
  <p>Thanks.</p>