-1

I got following JSF construct:

index.xhtml:

<h:form>
    <h:commandButton class="btn btn-success pull-left left-puffer right-puffer" value="Test" action="#{bean.debugCode()}" />
</h:form>

bean.java => bean which is used between view and DataBaseController

package db_container;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "bean")
@SessionScoped

public class Bean {
/*
 * VARIABLES
 */
// Database
private DataBaseController xy = null;

/*
 * CONSTRUCTOR
 */
public Bean() throws Exception {
    this.xy = new DataBaseController();     
}

/*
 * METHODS
 */

public void debugCode() {
    xy.DebugtoDB("DEBUG", "hallo", "welt", "neu");
 }
}

Stack Trace:

WARNING: #{bean.debugCode()}:
javax.el.MethodNotFoundException: /index.xhtml @330,139 action="
{bean.debugCode}": Method not found:
db_container.Bean@fda7ea.debugCode()
javax.faces.FacesException: #{bean.debugCode()}: javax.el.MethodNotFoundException: /index.xhtml @330,139 action="#{bean.debugCode}": Method not found: db_container.DetailsManager@fda7ea.debugCode()
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:110)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at net.sourceforge.spnego.SpnegoHttpFilter.doFilter(SpnegoHttpFilter.java:318)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

Now when I start the view and click on the button, the exception appears. Unfortunately it does not seem logic to me, since there is the function in the bean, which is ready to call.

What am I doing wrong?

Ronaldo-CH
  • 117
  • 1
  • 13
  • 1
    Make sure you're properly cleaning up (& republishing) your sever content before making those kind of tests. – Aritz Jul 31 '18 at 17:56
  • And what is your JSF and EL version. Is an actionMethod with () supported at all? – Kukeltje Aug 02 '18 at 19:32

1 Answers1

1

Your method expects a boolean value:

public void debugCode(Boolean test) {
    xy.DebugtoDB("DEBUG", "hallo", "welt", "neu");
 }

In that case, the method call in your xhtml must actually pass a true or false value like this:

<h:form>
    <h:commandButton class="btn btn-success pull-left left-puffer right-puffer" value="Test" action="#{bean.debugCode(true)}" />
</h:form>
Robert
  • 478
  • 6
  • 19
  • I see. I suggest you post the whole code for bean.java to get help with this problem. – Robert Jul 31 '18 at 09:59
  • Changed my answer now. I would like to add that I think it is a requirement for the bean to have a no-arguments default constructor. – Robert Jul 31 '18 at 10:30
  • sorry for the missunderstanding, ist not about the boolean thing, that was just my first try with a parameter, so forget about that! I changed my bean Code again. In Addition, the exception looks quit different concerning the boolean parameter. – Ronaldo-CH Jul 31 '18 at 10:51