Hmm... I presume there is no "CDI support is enabled" logged by Jersey?
If so I am guessing that is because it cannot find the BeanManager.
The following code looks up the BeanManager:
public static void initialize(ResourceConfig rc, WebApplication
wa) {
try {
InitialContext ic =
InitialContextHelper.getInitialContext();
if (ic == null)
return;
Object beanManager = ic.lookup("java:comp/BeanManager");
// Some implementations of InitialContext return null
instead of
// throwing NamingException if there is no Object
associated with
// the name
if (beanManager == null) {
LOGGER.config("The CDI BeanManager is not available.
JAX-RS CDI support is disabled.");
return;
}
rc.getSingletons().add(new
CDIComponentProviderFactory(beanManager, rc, wa));
LOGGER.info("CDI support is enabled");
} catch (NamingException ex) {
LOGGER.log(Level.CONFIG, "The CDI BeanManager is not
available. JAX-RS CDI support is disabled.", ex);
}
}
Notice that it looks up the BeanManager with the JNDI name ""java:comp/
BeanManager" (which is the JNDI name specified by CDI).
Paul.
On Jan 25, 2011, at 4:49 PM, aaron_at_acsiri.com wrote:
> The exception went away, thanks!
>
> However, my @Injected bean is null.
>
> I have annotated both my resource and my bean with @RequestScoped and
> @Named. Should that be enough?
>
> Here is what the tomcat logs are showing
>
> ...
> Jan 25, 2011 10:37:09 AM org.jboss.weld.bootstrap.WeldBootstrap
> <clinit>
> INFO: WELD-000900 1.1.0 (Final)
> Jan 25, 2011 10:37:09 AM org.jboss.weld.bootstrap.WeldBootstrap
> startContainer
> INFO: WELD-000101 Transactional services not available. Injection of
> @Inject UserTransaction not available. Transactional observers will be
> invoked synchronously.
> Jan 25, 2011 10:37:10 AM org.jboss.weld.environment.servlet.Listener
> contextInitialized
> INFO: Tomcat 6 detected, CDI injection will be available in Servlets
> and Filters. Injection into Listeners is not supported
> Jan 25, 2011 10:37:10 AM
> org.jboss.interceptor.util.InterceptionTypeRegistry <clinit>
> WARNING: Class 'javax.ejb.PostActivate' not found, interception based
> on it is not enabled
> Jan 25, 2011 10:37:10 AM
> org.jboss.interceptor.util.InterceptionTypeRegistry <clinit>
> WARNING: Class 'javax.ejb.PrePassivate' not found, interception based
> on it is not enabled
> Jan 25, 2011 10:37:10 AM
> com.sun.jersey.api.core.PackagesResourceConfig
> init
> ...