3

After build a lot of converters in my JSF app, I turned my attention to Omnifaces and everything's working like a charm. The problem arises when I deploy my application. The first time I access to my login page, it throws the next exception:

    SEVERE: BeanManager enum singleton failed to initialize.
    java.lang.IllegalStateException: javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Error retrieving java:comp/BeanManager [Root exception is java.lang.IllegalStateException: Cannot resolve bean manager]]
            at org.omnifaces.util.JNDI.lookup(JNDI.java:87)
            at org.omnifaces.config.BeanManager.init(BeanManager.java:76)
            at org.omnifaces.config.BeanManager.getReference(BeanManager.java:115)
            at org.omnifaces.application.OmniApplication.createValidator(OmniApplication.java:105)
            at com.sun.faces.component.validator.ComponentValidators.addValidatorsToComponent(ComponentValidators.java:280)
            at com.sun.faces.component.validator.ComponentValidators.addDefaultValidatorsToComponent(ComponentValidators.java:147)
            at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.processValidators(ComponentTagHandlerDelegateImpl.java:550)
            at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.privateOnComponentPopulated(ComponentTagHandlerDelegateImpl.java:531)
            at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:195)
            at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
            at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
            at com.sun.faces.facelets.tag.jsf.core.MetadataHandler.apply(MetadataHandler.java:104)
            at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
            at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
            at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
            at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
            at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:116)
            at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:233)
            at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
            at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
            at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
            at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
            at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:809)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:671)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:505)
            at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:476)
            at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:355)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:305)
            at org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormAuthenticator.java:464)
            at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:253)
            at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1333)
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:551)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:623)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
            at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
            at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
            at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
            at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
            at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
            at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
            at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
            at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
            at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
            at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
            at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
            at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
            at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
            at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Error retrieving java:comp/BeanManager [Root exception is java.lang.IllegalStateException: Cannot resolve bean manager]]
            at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
            at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
            at javax.naming.InitialContext.lookup(InitialContext.java:392)
            at javax.naming.InitialContext.lookup(InitialContext.java:392)
            at org.omnifaces.util.JNDI.lookup(JNDI.java:83)
            ... 53 more
    Caused by: javax.naming.NamingException: Error retrieving java:comp/BeanManager [Root exception is java.lang.IllegalStateException: Cannot resolve bean manager]
            at org.glassfish.weld.BeanManagerNamingProxy.handle(BeanManagerNamingProxy.java:129)
            at com.sun.enterprise.naming.impl.NamedNamingObjectManager.tryNamedProxies(NamedNamingObjectManager.java:89)
            at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:174)
            at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498)
            ... 57 more
    Caused by: java.lang.IllegalStateException: Cannot resolve bean manager
            at org.glassfish.weld.BeanManagerNamingProxy.handle(BeanManagerNamingProxy.java:119)
            ... 60 more

However, when I refresh my page, everything works fine.

Any ideas? Regards !!!

I'm using Glassfish 3.1.2.2 with JSF 2.1

2
  • Do you have beans.xml under your WEB-INF folder? Commented Feb 25, 2014 at 22:37
  • No, I don't. I just added omnifaces-1.7.jar to my classpath, and use the converter, just like the Omnifaces showcase shows Commented Feb 26, 2014 at 14:58

2 Answers 2

4

This will be thrown when the webapp is not explicitly CDI-enabled while it's deployed to an implicitly CDI-enabled server (such as GlassFish 3 in your case). This is fixed since OmniFaces 1.8. An alternative is to explicitly enable CDI in your webapp by creating a /WEB-INF/beans.xml file.

Sign up to request clarification or add additional context in comments.

1 Comment

Hey buddy.. could u look at this question. I now its not good to ask help on someone else question thread but I am in hurry. stackoverflow.com/questions/22985468/…
0

I was getting this exception while trying to run my Payara 4.1 application. Actually I was interchangeably getting the following 2:

Exception 0 :
org.jboss.weld.exceptions.UnserializableDependencyException: WELD-001413: The bean Managed Bean [class com.baw.website.beans.quality.ui.AuditBean] with qualifiers [@Default @Any @Named] declares a passivating scope but has a non-passivation-capable dependency Managed Bean [class com.baw.website.rest.clients.AuthUtil] with qualifiers [@Any @Default]

and

Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Error retrieving java:comp/BeanManager [Root exception is java.lang.IllegalStateException: Cannot resolve bean manager]]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at org.omnifaces.util.JNDI.lookup(JNDI.java:90)

After analyzing, I found that I had 2 classes with the same name in different packages:

com.mycompany.mypackageone.Myclass

com.mycompany.mypackagetwo.Myclass

One of them was being CDI-injected into a ManagedBean which was related to a JSF page that used Omnifaces. I'm not sure where the conflict was occurring (I do have a beans.xml). But for me, stop/starting Payara, and renaming one of the 2 identically-named classes did the trick and got rid of the errors.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.