4 Replies Latest reply on May 25, 2007 2:22 AM by cormet

    Error in trying to injecting the bean

    cormet

      Hi All,

      I am quite new to jboss and Currently, i am using hibernate 3.2.1, seam 1.2.1 GA. my problem is that i would like to inject the bean called "generalJournal" when it is submited. However I got error saying that:


      javax.faces.el.EvaluationException: Exception while invoking expression #{accountAction.recordJournal}
      at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:156)
      at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
      at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
      at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:148)
      at org.jboss.seam.pages.Page.enter(Page.java:229)
      at org.jboss.seam.core.Pages.enterPage(Pages.java:276)
      at org.jboss.seam.jsf.AbstractSeamPhaseListener.enterPage(AbstractSeamPhaseListener.java:276)
      at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:214)
      at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:56)
      at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:73)
      at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:126)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:183)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
      at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.seam.RequiredException: In attribute requires non-null value: accountAction.generalJournal
      at org.jboss.seam.Component.getValueToInject(Component.java:1919)
      at org.jboss.seam.Component.injectAttributes(Component.java:1368)
      at org.jboss.seam.Component.inject(Component.java:1195)
      at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
      at com.medansoft.accountingsystem.controller.AccountAction_$$_javassist_1.recordJournal(AccountAction_$$_javassist_1.java)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
      ... 42 more

      It complaint that the "generalJournal" is null, but i do put "create=true" which asking seam to create when it is null. iam quite confuse with the documentation provided :(. Can anyone give me some guideline about it?

      Cheers,

      here are my code:

      home.xhtml

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:c="http://java.sun.com/jsp/jstl/core"
       xmlns:rich="http://richfaces.ajax4jsf.org/rich"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
      <body>
       <ui:composition template="/WEB-INF/pages/templates/master.xhtml">
       <ui:define name="body">
       <s:link value="Account List" view="/pages/account/home.xhtml"/>
       <s:link value="Record Journal" view="/pages/account/journal/record.xhtml"/>
       </ui:define>
       </ui:composition>
      </body>
      </html>
      


      record.xhtml:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:c="http://java.sun.com/jsp/jstl/core"
       xmlns:rich="http://richfaces.ajax4jsf.org/rich"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
       xmlns:jp="http://www.jenia.org/jsf/popup">
      <body>
       <ui:composition template="/WEB-INF/pages/templates/master.xhtml">
       <ui:define name="body">
       <h:form>
       <s:decorate id="journalDecorate" template="edit.xhtml">
       <ui:define name="label">General Journal #:</ui:define>
       <h:inputText id="journal" value="#{generalJournal.number}" required="true">
      
       </h:inputText>
       </s:decorate>
       <s:decorate id="dateDecorate" template="edit.xhtml">
       <ui:define name="label">Date:</ui:define>
       <h:inputText id="date" value="#{generalJournal.date}" required="true" readonly="true">
      
       </h:inputText>
       <jp:popupCalendar for="date" format="dd/MM/yyyy">
       <h:outputText value="Popup calendar" />
       </jp:popupCalendar>
       </s:decorate>
       <s:decorate id="memoDecorate" template="edit.xhtml">
       <ui:define name="label">Memo:</ui:define>
       <h:inputText id="menu" value="#{generalJournal.memo}" required="true">
      
       </h:inputText>
       </s:decorate>
      
       <div class="buttonBox">
       <h:commandButton id="create" type="submit" value="Create" action="#{accountAction.createGeneralJournal}"/>
      
       <s:button id="cancel" value="Cancel" view="/pages/home/home.xhtml"/>
       </div>
      
       </h:form>
       </ui:define>
       </ui:composition>
      </body>
      </html>
      


      pages.xml
      <!DOCTYPE pages PUBLIC
       "-//JBoss/Seam Exceptions Configuration DTD 1.2//EN"
       "http://jboss.com/products/seam/pages-1.2.dtd">
      
      <pages login-view-id="/login.xhtml">
       <page view-id="/pages/account/home.xhtml" action="#{accountAction.accountHome}"/>
       <page view-id="/pages/account/journal/record.xhtml" action="#{accountAction.recordJournal}"/>
      
      
       <page view-id="/pages/*" login-required="true"/>
      
       <exception class="org.jboss.seam.security.NotLoggedInException">
       <redirect view-id="/login.xhtml">
       <message>You must be logged in to perform this action</message>
       </redirect>
       </exception>
      
       <exception class="org.jboss.seam.security.AuthorizationException">
       <end-conversation/>
       <redirect view-id="/security_error.xhtml">
       <message>You do not have the necessary security privileges to perform this action.</message>
       </redirect>
       </exception>
      </pages>
      


      AccountAction.java
      @Name("accountAction")
      @Scope(EVENT)
      public class AccountAction implements Serializable{
       private static final long serialVersionUID = 5884510664142728026L;
      
       @Logger
       private Log log;
      
       @In("#{accountDao}")
       AccountDao accountDao;
      
       @In("#{me}")
       User me;
      
       @Out(value="accountTreeList", required=false)
       private AccountTreeDisplay parentAccountDisplay;
      
       @DataModel(value="accountList")
       private List<AccountTreeDisplay> accountList;
      
       @In(create=true)
       private GeneralJournal generalJournal;
      
       public void recordJournal() throws Exception {
       if(journalId == null || journalId.equals("")) {
       // recording new journal
       } else {
       // reload existing journal
       }
       }
      
       public String createGeneralJournal() throws Exception {
       log.debug("createGeneralJournal :: # :: " + generalJournal.getNumber());
       return null;
       }


        • 1. Re: Error in trying to injecting the bean
          cormet

          anyone???

          • 2. Re: Error in trying to injecting the bean
            tony.herstell1

            The scope is event?
            @Scope(EVENT)
            Is that right?
            Don't you not want this to be in a Conversation (preferred) or Session?
            What is behind your choice of Event Scope?

            Are you just jumping straight into the page (i.e. main page)?
            You might not have been near the bean yet if so and not had a generalJournal created for you.

            Also, you are not Outjecting the bean to your view...

            @In(create=true)
             private GeneralJournal generalJournal;
            


            so

            value="#{generalJournal.number}"
            

            might have a hard job finding it in the view!

            You have two choices here
            Outject it...
            @In(create=true) @Out
             private GeneralJournal generalJournal;
            

            or
            have a method on AccountAction that exposes a calss variable that contains it.

            Both seem to work... but you have to do:
            value="#{accountAction.generalJournal.number}"
            to access the number.

            I hope this helps you track down the problem.



            • 3. Re: Error in trying to injecting the bean
              cormet

              Hi tony,

              THanks for the reply. I changed the code by adding outjecting annotation and still using EVENT scope:

              AccountAction.java:

              @Scope(EVENT)
              @Name("accountAction")
              public class AccountAction implements Serializable{
               private static final long serialVersionUID = 5884510664142728026L;
              
               @Logger
               private Log log;
              
               @In("#{accountDao}")
               AccountDao accountDao;
              
               @In("#{me}")
               User me;
              
               @Out(value="accountTreeList", required=false)
               private AccountTreeDisplay parentAccountDisplay;
              
               @DataModel(value="accountList")
               private List<AccountTreeDisplay> accountList;
              
               @In(create=true) @Out
               private GeneralJournal generalJournal;
              
              public void recordJournal() throws Exception {
               if(journalId == null || journalId.equals("")) {
               // recording new journal
               } else {
               // reload existing journal
               }
               }
              
               public String createGeneralJournal() throws Exception {
               log.debug("createGeneralJournal :: # :: " + generalJournal.getNumber());
               return null;
               }
              }
              


              and i got these error which saying that generalJournal is null and looks like @In(create=true) is ignoring the object creation. Do u think i am should used conversation instead of event????

              3:41:57,821 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
              javax.faces.el.PropertyNotFoundException: /pages/account/journal/record.xhtml @18,81 value="#{generalJournal.number}": Target Unreachable, identifier 'generalJournal' resolved to null
              at com.sun.facelets.el.LegacyValueBinding.getType(LegacyValueBinding.java:96)
              at org.apache.myfaces.shared_impl.renderkit._SharedRendererUtils.findUIOutputConverter(_SharedRendererUtils.java:58)
              at org.apache.myfaces.shared_impl.renderkit.RendererUtils.findUIOutputConverter(RendererUtils.java:310)
              at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedUIOutputValue(RendererUtils.java:604)
              at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.getConvertedValue(HtmlTextRendererBase.java:191)
              at javax.faces.component.UIInput.getConvertedValue(UIInput.java:396)
              at javax.faces.component.UIInput.validate(UIInput.java:350)
              at javax.faces.component.UIInput.processValidators(UIInput.java:184)
              at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:627)
              at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:627)
              at javax.faces.component.UIForm.processValidators(UIForm.java:73)
              at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:627)
              at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:149)
              at org.ajax4jsf.framework.ajax.AjaxViewRoot.access$201(AjaxViewRoot.java:53)
              at org.ajax4jsf.framework.ajax.AjaxViewRoot$3.invokeRoot(AjaxViewRoot.java:315)
              at org.ajax4jsf.framework.ajax.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:53)
              at org.ajax4jsf.framework.ajax.AjaxContext.invokeOnRegionOrRoot(AjaxContext.java:191)
              at org.ajax4jsf.framework.ajax.AjaxViewRoot.processValidators(AjaxViewRoot.java:329)
              at org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:32)
              at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
              at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:183)
              at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
              at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
              at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
              at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
              at java.lang.Thread.run(Thread.java:595)

              • 4. Re: Error in trying to injecting the bean
                cormet

                Hi All,

                Another update for the problem. I used the getter and setter in accountAction to expose the generalJournal in record.xhtml.

                This is problem works fine. However, my question is why using @In(create=true) not working??? coz i am using seam which mean i prefer to stick with seam technology rather getter and setter old way of JSF.

                Can anyone let me know why injection is not working??? i prefer to used @In if i have choice to use it :).

                Cheers,