I configured Jetty 9.2.5 + Weld 2.2.7 (currently the latest versions) as described by the Weld documentation.
Everything works fine, except the lookup of the BeanManager by JNDI. Lookup of other JNDI entries just work as expected. I got the error (note this is not a javax.naming.NameNotFoundException
)
javax.naming.NamingException: WELD-001300: Unable to locate BeanManager
The code I use:
BeanManager beanManager = null;
try {
final Context ctx = new InitialContext();
try {
// JNDI name defined by spec
beanManager = (BeanManager) ctx.lookup("java:comp/BeanManager");
} catch (NameNotFoundException nf1) {
try {
// JNDI name used by Tomcat and Jetty
beanManager = (BeanManager) ctx.lookup("java:comp/env/BeanManager");
} catch (NameNotFoundException nf2) {
}
}
} catch (NamingException ex) {
System.err.println(ex);
}
return beanManager;
Complete test code can be found at https://github.com/rmuller/java8-examples/tree/master/jetty-maven-cdi
env-entry
forBeanManager
– Ojibwaweb-overwrite-jetty.xml
(as stated in the documentation). If I move it toweb.xml
same problem still there. However note that I useresource-env-ref
and notenv-entry
which cannot be used for a Reference type afaik. So now I am lost :) – Nomi