So I overrode ServletContainer with the following code and changed
web.xml to use it:
public class TomcatCDIServlet extends ServletContainer {
private static final long serialVersionUID = 1L;
private static final Logger LOG =
Logger.getLogger(TomcatCDIServlet.class);
@Override
protected void initiate(ResourceConfig rc, WebApplication wa) {
super.initiate(rc, wa);
InitialContext ic =
InitialContextHelper.getInitialContext();
if (ic == null)
return;
try {
Object beanManager =
ic.lookup("java:comp/env/BeanManager");
if (beanManager == null) {
LOG.info("The CDI BeanManager is not
available. JAX-RS CDI support is disabled");
return;
}
rc.getSingletons().add(new
CDIComponentProviderFactory(beanManager,rc,wa));
LOG.info("JAX-RS CDI support is enabled");
} catch (NamingException e) {
LOG.log(Level.WARNING, "The CDI BeanManager is
not available. JAX-RS CDI support is disabled.", e);
}
}
}
It now reports "JAX-RS CDI support is enabled" in the log but my bean
is still @Injecting null.
-Aaron