7 Replies Latest reply on Aug 16, 2011 7:59 AM by Lars Grote

    Beans not working on Jboss AS 7

    Lars Grote Newbie

      Hi,

      I'm trying to migrate my application from AS 6 to AS 7 for few days now. I have this one Issue and have no idear how to handle it.

       

      The application uses JEE6 + Seam 3 + RichFaces 4. Currently I'm deploying the whole thing as a single war file (just for development). When I deploy the war file I get no errors on log level 'info' and the log say's that the app is registered and ready. Which is kind of true. I can navigate to the index page and everything looks good. But as soon as I do something that involves a bean I get a NullPointerException. It looks like non of my beans are available.

      When I turn the log level to 'debug' I can see an exception during the deployment process.

       

      12:06:32,638 FEIN  [javax.enterprise.resource.webcontainer.jsf.application] (MSC service thread 1-5) java.lang.NoSuchMethodException: org.jboss.as.web.deployment.jsf.JandexAnnotationProvider.<init>(javax.servlet.ServletContext, com.sun.faces.spi.AnnotationProvider): java.lang.NoSuchMethodException: org.jboss.as.web.deployment.jsf.JandexAnnotationProvider.<init>(javax.servlet.ServletContext, com.sun.faces.spi.AnnotationProvider)
                at java.lang.Class.getConstructor0(Class.java:2706) [:1.6.0_26]
                at java.lang.Class.getDeclaredConstructor(Class.java:1985) [:1.6.0_26]
                at com.sun.faces.spi.ServiceFactoryUtils.getProviderFromEntry(ServiceFactory.java:83) [jsf-impl-2.1.2.jar:2.1.2-FCS]
                at com.sun.faces.spi.AnnotationProviderFactory.createAnnotationProvider(AnnotationProviderFactory.java:70) [jsf-impl-2.1.2.jar:2.1.2-FCS]
                at com.sun.faces.config.ConfigManager$AnnotationScanTask.<init>(ConfigManager.java:807) [jsf-impl-2.1.2.jar:2.1.2-FCS]
                at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:348) [jsf-impl-2.1.2.jar:2.1.2-FCS]
                at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225) [jsf-impl-2.1.2.jar:2.1.2-FCS]
                at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3368) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]
                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821) [jbossweb-7.0.1.Final.jar:7.1.0.Alpha1-SNAPSHOT]
                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.1.0.Alpha1-SNAPSHOT.jar:7.1.0.Alpha1-SNAPSHOT]
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
                at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
                at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
      
      

       

      My guess is that this Exception is the cause for my not working beans, but I don't know what to do with this. I found this Exception in another post http://community.jboss.org/thread/169432 but with a differnet topic. As shown in that post I tried to use Jboss 7.1 Alpha with JSF/Mojarra 2.1.2 but that didn't change anything. (The Exception above is from AS 7 Alpha with Mojarra but with AS 7 Final and Mojarra 2.0.4 it's exactly the same)

       

      If anyone has any idear or suggestion ...

       

      Thanks a lot, Lars

        • 1. Re: Beans not working on Jboss AS 7
          jaikiran pai Master

          Let's concentrate on the NullPointerException first. Can you please post the entire exception stacktrace and the relevant bean code and client code?

          • 2. Re: Beans not working on Jboss AS 7
            Lars Grote Newbie

            Hi,

            thanks for your quick reply. I don't think that those NullPointerExceptions ar very interessting because they occure on all beans. But here is one example.

             

             

            13:09:34,812 FEIN  [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-1) processAction(j_idt15)
            13:09:34,813 SCHWERWIEGEND [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-1) javax.el.PropertyNotFoundException: /WEB-INF/frag/headright.xhtml @9,81 action="#{languageSwitcher.setUserLocale('de')}": Target Unreachable, identifier 'languageSwitcher' resolved to null: javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /WEB-INF/frag/headright.xhtml @9,81 action="#{languageSwitcher.setUserLocale('de')}": Target Unreachable, identifier 'languageSwitcher' resolved to null
                      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:95) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118) [prettyfaces-jsf2-3.2.1.jar:]
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]
                      at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]
                      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
            Caused by: javax.el.PropertyNotFoundException: /WEB-INF/frag/headright.xhtml @9,81 action="#{languageSwitcher.setUserLocale('de')}": Target Unreachable, identifier 'languageSwitcher' resolved to null
                      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:107) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      ... 28 more
            
            13:09:34,817 WARNUNG [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-1) #{languageSwitcher.setUserLocale('de')}: javax.el.PropertyNotFoundException: /WEB-INF/frag/headright.xhtml @9,81 action="#{languageSwitcher.setUserLocale('de')}": Target Unreachable, identifier 'languageSwitcher' resolved to null: javax.faces.FacesException: #{languageSwitcher.setUserLocale('de')}: javax.el.PropertyNotFoundException: /WEB-INF/frag/headright.xhtml @9,81 action="#{languageSwitcher.setUserLocale('de')}": Target Unreachable, identifier 'languageSwitcher' resolved to null
                      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118) [prettyfaces-jsf2-3.2.1.jar:]
                      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]
                      at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]
                      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                      at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
            Caused by: javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /WEB-INF/frag/headright.xhtml @9,81 action="#{languageSwitcher.setUserLocale('de')}": Target Unreachable, identifier 'languageSwitcher' resolved to null
                      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:95) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      ... 27 more
            Caused by: javax.el.PropertyNotFoundException: /WEB-INF/frag/headright.xhtml @9,81 action="#{languageSwitcher.setUserLocale('de')}": Target Unreachable, identifier 'languageSwitcher' resolved to null
                      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:107) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                      ... 28 more
            
            13:09:34,820 DEBUG [org.jboss.seam.faces.event.PhaseEventBridge] (http--127.0.0.1-8080-1) Fired event [javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@3b5ccf46]] with qualifiers [[Ljava.lang.annotation.Annotation;@1d402894]
            13:09:34,820 DEBUG [org.jboss.seam.faces.transaction.TransactionPhaseListener] (http--127.0.0.1-8080-1) committing transaction after phase: INVOKE_APPLICATION 5
            13:09:34,821 DEBUG [org.jboss.seam.transaction.UTTransaction] (http--127.0.0.1-8080-1) committing JTA transaction
            13:09:34,821 FEIN  [javax.enterprise.resource.webcontainer.jsf.timing] (http--127.0.0.1-8080-1)  [TIMING] - [10ms] : Execution time for phase (including any PhaseListeners) -> INVOKE_APPLICATION 5
            13:09:34,850 FEIN  [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-1) render(com.sun.faces.context.FacesContextImpl@4786bc70)
            
            

             

            This is the server side exception from the Jboss server log. I attached the Facelets debug page.

            Thanks.

            • 3. Re: Beans not working on Jboss AS 7
              Stan Silvert Master

              You are trying to use JSF 2.1.  AS7 has JSF 2.0.  The SPI for the AnnotationProvider changed in JSF 2.1, so you get that error.

               

              Are you bundling JSF 2.1 with your WAR?  If so, take it out.

               

              JSF 2.1 integration is planned for AS7.1.

               

              Stan

              • 4. Re: Beans not working on Jboss AS 7
                Lars Grote Newbie

                Hi Stan,

                the problem I described occured with JSF 2.0. I used the standard release Jboss AS 7.0.0.Final

                Because of the Problem I tried to change the JSF Version to 2.1 but that did not help.

                 

                So the Problem occures with JSF 2.0 and 2.1 and with Jboss AS 7.0.0.Final and Jboss AS 7.1.0 AlphaX

                 

                Lars

                • 5. Re: Beans not working on Jboss AS 7
                  Lars Grote Newbie

                  @ jaikiran

                   

                  I forgot to mention that all this code worked with Jboss 6. Don't think there are problems with the my code. But anyway here is the Bean:

                   

                   

                  @Model
                  public class LanguageSwitcher {
                    
                    @Inject
                            private Logger log;
                  
                    @Inject
                    @Client
                            private Locale userLocale;
                  
                    @Inject
                    @Client
                    @Alter
                            Event<Locale> localeEvent;
                  
                            public void setUserLocale(String localeStr) {
                  
                                      Locale newLocale = new Locale(localeStr);
                                      localeEvent.fire(newLocale);
                    
                                      log.debug("New Lang: " + newLocale);
                  
                    // Sollte eigentlich nicht nötig sein
                                      FacesContext context = FacesContext.getCurrentInstance();
                                      context.getViewRoot().setLocale((Locale) newLocale);
                            }
                  
                            public Locale getUserLocale() {
                    return userLocale;
                            }
                  
                            public void setUserLocale(Locale userLocale) {
                                      this.userLocale = userLocale;
                            }
                  
                  }
                  
                  

                   

                   

                   

                  <?xml version="1.0" encoding="UTF-8"?>
                  <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html">
                  
                    <div id="headRight">
                         <h:form id="langForm">
                              <h:commandLink value="DE" action="#{languageSwitcher.setUserLocale('de')}" />
                              <h:outputText value=" " />
                              <h:commandLink value="EN" action="#{languageSwitcher.setUserLocale('en')}" />
                         </h:form>
                    </div>
                  </ui:composition>
                  
                  

                   

                   

                  Thanks, Lars

                  • 6. Re: Beans not working on Jboss AS 7
                    Nicklas Karlsson Master

                    And you see Weld boot? Do you see the bean registered if you raise debug level to DEBUG? Are there any CNFE:s floating around?

                    • 7. Re: Beans not working on Jboss AS 7
                      Lars Grote Newbie

                      Yes I do see Weld Boot, and there are no ClassNotFoundExceptions.

                      Everything looks good to that point (at least I my eyes)

                       

                      I attached a debug level startup log (except hibernate).

                       

                      edit: But the Bean 'languageSwitcher' is not registered'. At least I don't find the name in the log file.

                       

                      Lars