运行:Apache Tomcat 7.0.47 OmniFaces 1.6.3 JSF Mojarra 2.1.26 CDI Weld 2.1.0.Final
RuntimeException通过访问JNDI"java:comp/BeanManager",Threre是Apache Tomcat 7.0.47上的一个.CDI BenManager必然会java:comp/env/BeanManager在您的BeanManager类中无法到达.
/**
* Perform automatic initialization whereby the bean manager is looked up from the JNDI. If the bean manager is
* found, then invoke {@link #init(Object)} with the found bean manager.
*/
private void init() {
if (!initialized.getAndSet(true)) {
try {
Class.forName("javax.enterprise.inject.spi.BeanManager"); // Is CDI present?
Class.forName("javax.naming.InitialContext"); // Is JNDI present? (not on Google App Engine)
}
catch (Exception e) {
return; …Run Code Online (Sandbox Code Playgroud)