I configured Jetty 9.2.5 + Weld 2.2.7 (currently the latest versions) as described in the Welding Documentation .
Everything works fine except for the BeanManager JNDI search. Finding other JNDI entries works as expected. I got an error (note that this is not javax.naming.NameNotFoundException )
javax.naming.NamingException: WELD-001300: Unable to locate BeanManager
The code I'm using is:
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;
The full test code can be found at https://github.com/rmuller/java8-examples/tree/master/jetty-maven-cdi
source share