Search code examples
jbossejb-3.0java-ee-5

JBoss 5 AS and EJB3 bean injection from servlets?


It was my understanding that JBossAS 5.x supported EJB3 bean injection in servlets with the @EJB3 annotation. I'm using the default configuration for JBossAS 5.0.1.GA and it's not working. I've added the mappedName argument to the @EJB annotation with the session beans JNDI name, and it just doesn't do anything. No apparent errors, the bean is just never injected.

The session beans are in the ejb-jar, the servlets in a war, everything is packaged in an ear. Manual JNDI lookups work just fine. Any ideas?


Solution

  • This may happen if your web.xml points to an older version of the spec. Ideally, it should be something like

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" 
             xmlns="http://java.sun.com/xml/ns/j2ee" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
    

    This link may help a little too.