Two Laptop Bag*
The moose likes JSF and the fly likes jsf exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "jsf exception " Watch "jsf exception " New topic
Author

jsf exception

Essam AbdelAziz
Ranch Hand

Joined: Mar 10, 2007
Posts: 34
I'm getting this error trying to
bind a method to the action property of my component:

exception

javax.servlet.ServletException: #{customer.addNewUser}: javax.faces.el.MethodNotFoundException: addNewUser: com.corejsf.CustomerBean.addNewUser()
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)


root cause

javax.faces.FacesException: #{customer.addNewUser}: javax.faces.el.MethodNotFoundException: addNewUser: com.corejsf.CustomerBean.addNewUser()
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
javax.faces.component.UICommand.broadcast(UICommand.java:312)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)


note The full stack trace of the root cause is available in the Tomcat logs.


and thsi is my component

<h:commandButton value="NewUser" action="#{customer.addNewUser}" />


so where is my error
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

Let us see how you defined the addNewUser method in com.corejsf.CustomerBean.

It should be a public no-argument method returning a java.lang.String. If it isn't the method signature won't match what the JSF framework is expecting.


Customer surveys are for companies who didn't pay proper attention to begin with.
Essam AbdelAziz
Ranch Hand

Joined: Mar 10, 2007
Posts: 34
here's my method
i'm still facing the same exception
public String addNewUser() throws SQLException, NamingException {
try {
open();

Statement stmt = conn.createStatement();
ResultSet result = stmt.executeQuery("SELECT * FROM USERS ");
//Name name=new Name("essam","ahmed");

return "AddSuccess";
} finally {
close();
}



}
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

Hmmmm. I'm not sure it's OK to list thrown exceptions. It seems unlikely, since the JSF framework isn't written to expect them. I think you're going to have to wrap your exceptions and rethrow them as JSF exceptions. JSF exceptions are unchecked exceptions, so you don't declare them in the method declaration.
Essam AbdelAziz
Ranch Hand

Joined: Mar 10, 2007
Posts: 34
i removed all exeptions handling even i removed any code line form the method body amd i'm still stuck what should i do again


appreciate your help
Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
you can throw checked exceptions. It shouldn't matter. The problem is somewhere in your class declaration. How did you declare your managed bean and in which package is it?
Essam AbdelAziz
Ranch Hand

Joined: Mar 10, 2007
Posts: 34
here's my all bean



thank you very much
Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
your class and the method look ok... the only thing left then is, check your classpath. looks like there is some other CustomerBean in your classpath and this one does not have addNewUser() method. Also check if you have the latest class in your tomcat webapps.
A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
Everything looks okay except the throws part in your action method. Did you try removing it?
For exceptions in the action and actionListener methods, what I normally do is catch them, log them, add an appropriate FacesMessage to FacesContext so the users know about it and finally return ""(for action methods) or return(for actionListener methods).
Hope this helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsf exception