5 Replies Latest reply on Mar 10, 2011 2:33 AM by nimo stephan

    Method not found ??

    nimo stephan Master

      I have a method with a string-property:

       

      public void methodWithParam(String test) {

      .

      }

       

      <a4j:commandLink value="click" action="#{myBean.methodWithParam('mystring')}" ../>

       

      But when using this, I get this exception:

       

      15:04:07,981 ERROR [STDERR] Caused by: javax.el.MethodNotFoundException: /home.xhtml @151,136 action="#{myBean.methodWithParam(test)}": Method not found: com.MyBean@56bc05.methodWithParam()

       

      15:04:07,981 ERROR [STDERR]      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:106)

       

      15:04:07,981 ERROR [STDERR]      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)

       

      15:04:07,981 ERROR [STDERR]      ... 32 more

       

      However, I definitly have this method in my class !

       

      The same code works in JSF 1.2 but not in JSF 2.0. When using a method without parameters, it works. What is wrong?

        • 1. Re: Method not found ??
          nimo stephan Master

          I found the error. I use weld and inject a bean A (which has this method) into another bean B which I referenced by @Named.

           

          You can reproduce the error by doing these steps:

           

          @Named

          class A{

          public void methodWithParam(String s){}


          public void methodWithoutParam(){}

          }

           

          @Named

          class B{

           

          @Inject A injectedA:

           

          }

           

          Now, I reference my method within the view:

           

          This does work:

           

          <a4j:commandLink value="click" action="#{b.injectedA.methodWithoutParam}" ../>

           

          This does NOT work (because it has parameters):

           

          <a4j:commandLink value="click" action="#{b.injectedA.methodWithParam('mystring')}" ../>

           

          But when using this, the method with parameters works:

           

          <a4j:commandLink value="click" action="#{a.methodWithParam('mystring')}" ../>

           

          This is very strange ! Is that a bug in weld ?

          • 2. Re: Method not found ??
            Ilya Shaikovsky Master

            need to check more still not looked more deeply.. but think not in Weld but at EL-evaluation at some level.

             

            B.t.w. does it works with h:command ?

            • 3. Re: Method not found ??
              nimo stephan Master

              It does also not work with h:commandLink. So it is not a rf-issue.

               

              If I change bean A to a stateless ejb, the indirect call of the methodWithParam via bean B will work.

              If I reference the methodWithParam directly from bean A, then it will also work.

               

              But injecting the (non ejb) managed bean A into B (which both are session scoped beans) and calling methodWithParam indirectly via b.injectedA.methodWithParam('mystring') will definitly not work - it only works for methods without params.

              When changing bean A to a stateless ejb, the indirect call of b.injectedA.methodWithParam('mystring') via bean B will work. Strange.

              .methodWithParam
              • 4. Method not found ??
                geschtli Newbie

                Hi Stephan

                 

                Have you test it with

                @Named

                @SessionScoped

                class A.....

                 

                 

                It can be, that in your next call, the bean is not more.

                • 5. Re: Method not found ??
                  nimo stephan Master
                   {quote}But injecting the (non ejb) managed bean A into B (which both are session scoped beans) and calling methodWithParam indirectly {quote}

                   

                  Bean A was already declared with SessionScoped.