WELD-001300 when trying to lookup BeanManager by JNDI
Asked Answered
N

1

2

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

Nomi answered 27/12, 2014 at 11:12 Comment(6)
You don't have an env-entry for BeanManagerOjibwa
Yes, I have: github.com/rmuller/java8-examples/blob/master/jetty-maven-cdi/… (copied from the Weld documentation page)Nomi
I don't see it here.. github.com/rmuller/java8-examples/blob/master/jetty-maven-cdi/…Ojibwa
It is in the web-overwrite-jetty.xml (as stated in the documentation). If I move it to web.xml same problem still there. However note that I use resource-env-ref and not env-entry which cannot be used for a Reference type afaik. So now I am lost :)Nomi
I reviewed all code carefully again and made some modifications, so check the updated repo for details. Should be okay now, but reported problem still exists.Nomi
I have the save problem.#34867182Kowalewski
E
0

This has similar symptoms to a problem I ran into with Tomcat 7/8 and Weld 2.2.6. In my case, it was related to a bug in WELD, which was fixed in 2.2.7. So it shouldn't have been affecting the original poster's setup.

https://issues.jboss.org/browse/WELD-1776

Elvera answered 27/3, 2015 at 18:29 Comment(1)
Thanks, but i do not think this bug is related. My problem still exists with Weld version 2.2.9 and 3 (alpha1). Currently i do not use jdni lookup anymore (using CDI.current().getBeanManager())Nomi

© 2022 - 2024 — McMap. All rights reserved.