java.lang.NoClassDefFoundError: javax/faces/context/FacesContext error
Hi ,
In web.xml , i have the following mapping :
--
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
--
In the managed bean , I have following method
--
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
if ((context == null) || (component == null)) {
throw new NullPointerException();
}
if (value != null) {
String val = (String) value;
if (val == null || val.trim().length() == 0) {
throw new ValidatorException(MessageFactory.getMessage(context, "Name should not be empty" ,
new Object[] {val} ));
}
}
}
--
This method is for validation and it uses FacesConteact and it fails here. I have all the needed jars. The application works fine as long as FacesContext is not used in managed bean code
I
Any ideas ?
Hmm... Ok. Do all your web pages end in .jsf? Since you've set in your web.xml that everything with the URL pattern of *.jsf will pass through the faces servlet, you need your file to have a jsf extension.
i.e. http://localhost/contextRoot/myPage.jsf
And of course, in your web.xml, you have the following lines right?
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>-1</load-on-startup>
</servlet>
CowKing
Hi ,
I have the following in web.xml :
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
It is PLUS ONE instead of MINUS ONE for <load-on-startup>
Yes, that all sounds right. Hmm...
Probably a silly question, but have you ensured that the jsf-api and jsf-impl JARs are in the WEB-INF/lib directory?
This has me a bit stumped, I'm sorry to say. It's probably something small that is easily overlooked. Try watching your punctuation. Maybe try mapping the Faces Servlet to /faces/* and see if that makes a difference (of course, you'll have to adjust your URL appropriately).
Out of curiousity, where exactly does this fail? Have you been able to narrow it down to the exact call?
CowKing
I got it to work.
Managed Bean class was in two places - one inside the WAR file and second one outside of the war along with some other classes in the EAR file.
managed bean from other classes in the EAR file was getting picked which did not have any idea of the FacesServlet or any other Faces classes.
I excluded the managed bean from second place in the build script and eevrything seems to be working fine.
Thanks for your help !!