views:

1363

answers:

2

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?

A: 

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"&gt;

This link may help a little too.

Antonio
Thanks! One small caveat, it appears the name-space should be http://java.sun.com/xml/ns/javaee, not http://java.sun.com/xml/ns/j2ee.So I changed to: xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_2_5.xsd"
joshz
A: 

You should also check the jar file needed for EJB3 deployment in the classpath.JAr file is jboss-ejb3-ext-api.jar.