Failed to initialize FacesServlet in Tomcat 7 - ClassNotFoundException

I tried a simple hello world application in JSF, but based on the exception thrown by tomcat at startup, I see that FacesServlet not getting initialized. I have the necessary jar files myfaces-api, bundle, impl and commons beanutils, codecs, collections, digester, logging. In addition, I read another question about SO, which would also require jsf-api.jar and jsf-impl.jar , which I also posted to WEB-INF/lib and added to the build path

Still out of luck. I am developing on Ubuntu using Eclipse and Tomcat 7

Here is my web.xml

 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>Doom</display-name> <display-name>JavaServerFaces</display-name> <!-- Change to "Production" when you are ready to deploy --> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param> <!-- Welcome page --> <welcome-file-list> <welcome-file>faces/welcome.xhtml</welcome-file> </welcome-file-list> <!-- JSF mapping --> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Map these files with JSF --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.faces</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> </web-app> 

This is an exception

 java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1062) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4935) at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5262) at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5257) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) 
+6
source share
3 answers

After 2 weeks, I found the answer. very simple, as always, at the end. you need to copy both

 jsf-api.jar jsf-impl.jar 

To tomcat lib . having it in project lib doesn't work.

+15
source

I had the same issue while working with Eclipse Juno and Tomcat 7 - Tomee 1.6.0.

I want to use mojarra 2.0.3, and I found a lot of problems when deploying the server. I decided to delete the text files - *. Jar in Tomcat lib; then add mojarra lib to the Tomcat directory and then start the server. Now everything is in order, it works.

After many configuration changes, I saw that it actually works, installed by the library in the Tomcat directory, directly ignoring the Eclipse configurations. maybe a mistake?

Finally, I decided to solve the problem myself, changing the Tomcat library myself. I do not think this will be a problem in the future.

+1
source

This dependency contains the required libraries and may solve your problem.

 'org.glassfish:javax.faces:2.3.0' 
0
source

Source: https://habr.com/ru/post/950945/


All Articles