5 Replies Latest reply on Jul 20, 2007 3:10 PM by pettersonfp

    NoSuchMethodException when acessing protected methods in sup

    pettersonfp

      Hi,

      I having weird NoSuchMethodExceptions that I cannot understand, I made a very simple example that reproduces my problem. Someone can help me understand what I am doing wrong?

      Thanks in advance,
      Petterson

      Base.java

      public class Base {
      
       protected void printProtected() {
       System.out.println("printProtected");
       }
      
      }
      


      Derived.java
      import org.jboss.seam.annotations.Name;
      
      @Name("derived")
      public class Derived extends Base {
      
       @Override
       public void printProtected() {
       System.out.println("DerivedProtectedPrint");
       super.printProtected();
       }
      }
      


      testDerived.xhtml
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition 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:rich="http://richfaces.ajax4jsf.org/rich"
       template="layout/template.xhtml">
      
      <ui:define name="body">
      
       <h:messages styleClass="message"/>
      
       <h:form id="printTest">
      
       <div class="actionButtons">
       <h:commandButton value="Protected" action="#{derived.Protected}"/>
       </div>
      
       </h:form>
      
       </ui:define>
      </ui:composition>
      



      And the Stack Trace got when I press the button...
      ----
      00:59:24,562 ERROR [DebugPageHandler] redirecting to debug page
      javax.el.MethodNotFoundException: /testDerived.xhtml @18,79 action="#{derived.Protected}": Method not found: br.com.liax.test.Derived@199ae79.Protected()
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:72)
       at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
       at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
       at javax.faces.component.UICommand.broadcast(UICommand.java:383)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:346)
       at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:63)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:87)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:63)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:46)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      


        • 1. Re: NoSuchMethodException when acessing protected methods in
          pettersonfp

          Please, ignore this until my next post, I posted the wrong sample code.
          I'm fixing the sample and I'll post again.

          Sorry

          • 2. Re: NoSuchMethodException when acessing protected methods in
            pettersonfp

            Hello again,

            I was having a problem in a machine with linux / jboss 4.2.0.GA and seam 2.0.
            Now I am in home and the only difference is that I have windows xp.

            Instead of NoSuchMethodException now I am getting another one.

            Following are the code and the stack trace.

            Disregard my previous message.

            Thanks,
            Petterson

            Base.java

            public class Base {
            
             public final void execute() {
             System.out.println("Base->execute");
             doExecute(); // **** the error occurs here
             }
            
             protected void doExecute() {
             System.out.println("Base->doExecute");
             }
            
            
            }
            


            Derived.java
            import org.jboss.seam.annotations.Name;
            
            @Name("derived")
            public class Derived extends Base {
            
             @Override
             protected void doExecute() {
             System.out.println("Derived->doExecute");
             }
            
            }
            


            testDerived.xhtml
            <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <ui:composition 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:rich="http://richfaces.ajax4jsf.org/rich"
             template="layout/template.xhtml">
            
            <ui:define name="body">
            
             <h:messages styleClass="message"/>
            
             <h:form id="printTest">
            
             <div class="actionButtons">
             <h:commandButton value="Execute" action="#{derived.execute}"/>
             </div>
            
             </h:form>
            
             </ui:define>
            </ui:composition>
            
            


            Stack Trace [partial]
            Caused by: java.lang.IllegalAccessException: Class org.jboss.seam.util.Reflections can not access a member of class br.com.liax.test.Derived with modifiers "protected"
             at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
             at java.lang.reflect.Method.invoke(Method.java:578)
             at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
             at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
             at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
             at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
             at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
             at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
             at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
             at br.com.liax.test.Derived_$$_javassist_0.doExecute(Derived_$$_javassist_0.java)
             at br.com.liax.test.Base.execute(Base.java:8)
             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.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:325)
             at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:338)
             at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
             at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
             at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
             at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
             at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
             ... 44 more
            


            • 3. Re: NoSuchMethodException when acessing protected methods in
              pettersonfp

              Any Ideas?

              • 4. Re: NoSuchMethodException when acessing protected methods in
                pettersonfp

                I discovered that if I remove the final in the execute method the problems go away.

                Anybody knows what I'm doing wrong?

                • 5. Re: NoSuchMethodException when acessing protected methods in
                  pettersonfp

                  Is it wrong to use final in this case?