4 Replies Latest reply on Apr 12, 2014 12:16 AM by sjljsw

    beans.xml missing -> very strange Exceptions

    drab

      Hi,

       

      I'm using WildFly 8 and I have an ear with 2 war files none of which use JSF. One of them was for REST services, but the initial version was still missing the beans.xml due to an error of mine.

      I could deploy this well without any error. But when I would rebuild it and redeploy, I would get following error:

       

      14:04:05,775 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Critical error during deployment: : org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type

      javax.faces.flow.builder.FlowDefinition

              at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:680) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]

              at org.jboss.weld.util.ForwardingBeanManager.getContext(ForwardingBeanManager.java:181) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]

              at com.sun.faces.application.ApplicationAssociate$PostConstructApplicationListener.loadFlows(ApplicationAssociate.java:323) [jsf-impl-2.2.5-jbossorg-3.jar:]

              at com.sun.faces.application.ApplicationAssociate$PostConstructApplicationListener.processEvent(ApplicationAssociate.java:303) [jsf-impl-2.2.5-jbossorg-3.jar:]

              at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108) [jboss-jsf-api_2.2_spec-2.2.5.jar:2.2.5]

              at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2187) [jsf-impl-2.2.5-jbossorg-3.jar:]

              at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2163) [jsf-impl-2.2.5-jbossorg-3.jar:]

              at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:296) [jsf-impl-2.2.5-jbossorg-3.jar:]

              at org.jboss.as.jsf.injection.weld.ForwardingApplication.publishEvent(ForwardingApplication.java:294) [wildfly-jsf-injection-8.0.0.Final.jar:8.0.0.Final]

              at com.sun.faces.config.ConfigManager.publishPostConfigEvent(ConfigManager.java:691) [jsf-impl-2.2.5-jbossorg-3.jar:]

              at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:253) [jsf-impl-2.2.5-jbossorg-3.jar:]

              at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]

              at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:187) [undertow-servlet-1.0.0.Final.jar:1.0.0.Final]

              at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:86)

              at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:71)

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]

              at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

       

      14:04:05,855 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./rest: org.jboss.msc.service.StartException in service jboss.underto

      w.deployment.default-server.default-host./rest: Failed to start service

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]

              at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

      Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.faces.flow.builder.FlowDefinition

              at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:216)

              at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:86)

              at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:71)

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]

              ... 3 more

      Caused by: java.lang.RuntimeException: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.faces.flow.builder.FlowDefinition

              at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:273)

              at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)

              at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:187)

              ... 7 more

      Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.faces.flow.builder.FlowDefinition

              at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:680)

              at org.jboss.weld.util.ForwardingBeanManager.getContext(ForwardingBeanManager.java:181)

              at com.sun.faces.application.ApplicationAssociate$PostConstructApplicationListener.loadFlows(ApplicationAssociate.java:323)

              at com.sun.faces.application.ApplicationAssociate$PostConstructApplicationListener.processEvent(ApplicationAssociate.java:303)

              at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108)

              at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2187)

              at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2163)

              at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:296)

              at org.jboss.as.jsf.injection.weld.ForwardingApplication.publishEvent(ForwardingApplication.java:294)

              at com.sun.faces.config.ConfigManager.publishPostConfigEvent(ConfigManager.java:691)

              at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:253)

              ... 9 more

       

       

      I also got following errors on shutdown:

       

      14:41:54,235 SEVERE [javax.faces] (MSC service thread 1-3) Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI?

      14:41:54,238 SEVERE [javax.faces] (MSC service thread 1-3) Unable to call @PreDestroy annotated methods because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?

       

      I got those 2 lines twice each if I redeployed.

       

      I figured out the problem as it was only the missing beans.xml file. But I thought I'd bring this up as it is highly misleading information from those exceptions. I kept wondering why there was a JSF error in a JSF-free project.

       

      I believe a missing beans.xml file is a typical newbie error, can there not be an exception at start up saying something like : "you're trying to use CDI, but you have no beans.xml"?

       

      Dirk

        • 1. Re: beans.xml missing -> very strange Exceptions
          mkouba

          Hi Dirk,

          don't you have a /WEB-INF/faces-config.xml file or some JSF component annotation (e.g. javax.faces.bean.ManagedBean or javax.faces.validator.Validator) in your webapp? In fact the JSF module dependency is automatically added to every WAR deployment, however JSF is only activated if required. This could be supressed with jboss-deployment-structure.xml (see https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly#ClassLoadinginWildFly-JBossDeploymentStructureFile). The strange thing is the bean.xml file is fixing the issue...

          Martin

          • 2. Re: beans.xml missing -> very strange Exceptions
            drab

            Hi Martin,

             

            I used to have a faces-config.xml in the other war, because it was auto-generated. But now I wanted to reproduce this and I could not reproduce the exception. ...so I guess there was more than just adding the beans.xml.

             

            I still get the errors on shutdown:

             

            17:58:24,331 SEVERE [javax.faces] (MSC service thread 1-3) Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI?

            17:58:24,331 SEVERE [javax.faces] (MSC service thread 1-3) Unable to call @PreDestroy annotated methods because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?

             

            but I guess that is not a WELD issue.

             

            Dirk

            • 3. Re: Re: beans.xml missing -> very strange Exceptions
              mkouba

              This issue might be related: https://issues.jboss.org/browse/WFLY-2594

               

              In any case, if you really don't use JSF in your WAR I recommend to exclude the JSF subsytem entirely. Simply put similar jboss-deployment-structure.xml in the WEB-INF dir:

              <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
                  <deployment>
                      <exclude-subsystems>
                          <subsystem name="jsf" />
                      </exclude-subsystems>
                  </deployment>
              </jboss-deployment-structure>
              
              • 4. Re: beans.xml missing -> very strange Exceptions
                sjljsw

                HI   dirk   Yourproblem is solvedyet?     I also encountered the same exception.   

                 

                I am a Chinese, my English is not good

                 

                My development environment is   :

                 

                1:JBOSS-EAP 6.1

                 

                2:JSF 2.2.6

                 

                3:

                <dependency>
                <groupId>org.jboss.weld</groupId>
                <artifactId>weld-core</artifactId>
                <version>2.1.2.Final</version>

                </dependency>

                 

                 

                4:deltaspike 0.6 

                 

                If you have any solution, please tell me please as soon as possible.

                Thank you!!!!