0

Im trying to create a basic JSF application but can't seem to get it to work - I suspect something is missing, by default in the faces-config.xml file but I'm not sure what. I recieve this error:

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config

I googled it and found it to be a supposedly missing jar file. This I downloaded and added to the 'Build Path' of the project, refreshed and restarted the server but it still didn't work. The external JAR file is called 'jstl-1.2.jar.'

Here's a list of the error/s being reported:

HTTP Status 500 - javax/servlet/jsp/jstl/core/Config

type Exception report

message javax/servlet/jsp/jstl/core/Config

description The server encountered an internal error that prevented it from fulfilling     
this request.

exception 

javax.servlet.ServletException: javax/servlet/jsp/jstl/core/Config
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)


root cause 

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:345)
com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)


root cause 

java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:345)
com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:154)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)


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

Any ideas? This has to be a simple fix as it cannot be this complicated to get a simple HelloWorld popping out from a JSF application.

Cheers

Katana24
  • 8,706
  • 19
  • 76
  • 118
  • can you post what librarys (.jar) you have in your classpath – roel Nov 21 '12 at 11:59
  • Apache Tomcat v7.0. In the classpath are the following: jstl-1.2.jar, Apache Tomcat v7.0, EAR libraries, JRE System Library[jre7] and Web App Libraries – Katana24 Nov 21 '12 at 12:08
  • to begin with, I suggest you use some server that already includes JSF implementations, like JBoss or Glassfish. – SJuan76 Nov 21 '12 at 12:33
  • @SJuan76 that's not a good suggestion, you can write a JSF 2 application and deploy it on Tomcat 7 with no problems. – Luiggi Mendoza Nov 21 '12 at 13:51
  • It looks like you haven't set the JSTL library in your classpath (or isn't well configured). Make sure you have this (and other) jars in WEB-INF/lib directory and that they are available in the generated war. – Luiggi Mendoza Nov 21 '12 at 13:56
  • i moved the jar file to the lib folder in the WEB-INF folder. How do I generate the war file? – Katana24 Nov 21 '12 at 13:59
  • can you post the list of the jar files you added? – Sazzadur Rahaman Nov 21 '12 at 15:05

2 Answers2

2

This I downloaded and added to the 'Build Path' of the project, refreshed and restarted the server but it still didn't work.

This is not the correct approach. You should not touch the Build Path property of the project at all. You should just drop the JSTL JAR file straight into /WEB-INF/lib folder of the project. You should make sure that you undo every change you made in Build Path property in a careless attempt to "fix" this, otherwise the webapp will still be build/deployed with a broken classpath/library structure.

Why you need it is because JSF2 Facelets is requiring the JSTL dependency for functioning of all <c:xxx> tags as listed here. However, you're using Tomcat which is a barebones JSP/Servlet container which doesn't ship with JSTL out the box. You'd have to download and install it separately. On full fledged containers like Glassfish you don't have the need to do this (also not for JSF JAR files, by the way).

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Yeh I was looking at your other post about this about a half hour ago - will try it – Katana24 Nov 21 '12 at 16:39
  • One question though when I'm setting up a new Dynamic Web Project and get to the JSF capabilities window what do i select? I have two options and one must be selected: JSF 2.1(Mojarra 2.1.6-FCS) or JSTL - the library I mentioned above. Which to use? – Katana24 Nov 21 '12 at 16:49
  • You can also just choose to provide library yourself. You then just drop the necessary JSF and JSTL JARs in `/WEB-INF/lib` yourself. – BalusC Nov 21 '12 at 16:52
  • Thanks BalcusC - having messed around with Eclipse I found what I was looking for. I first tried dropping the jar's into the lib folder bit I coudln't do it - so I created a new project and selected 'Disable Library Configuration.' Then I was allowed to drop files into the lib folder. It worked from the Tomcat server when I had '*/faces/helloWorld.jsp.' I assume this is what you meant above? – Katana24 Nov 22 '12 at 09:47
0

Moving the jar file into the WEB-INF folder didn't fix the problem so after some searching I came across this tutorial. After following it's steps it didn't work either so what I had to do was this:

  1. Download the zip folder from the website above
  2. Extract it to wherever is handy for you - for me it was the Desktop
  3. Examine the lib folder and place the jar files in this into another folder
  4. Follow the normal steps for creating a project -> File -> New -> Dynamic Web Project
  5. Enter your project details
  6. When you get to the 'JSF Capabilities' page click on the 'Manage Libraries' icon, select 'New' and create a folder, calling it whatever you want. Add the jar files from earlier to this and select finish.

You should now be good to go!

Thanks for help

P.S Here's the list of JAR files, again they are in the WEB-INF/lib folder of the zip

  • commons-beanutils-1.7.0.jar
  • commons-chain-1.1.jar
  • commons-collections.jar
  • commons-digester-1.8.jar
  • commons-logging-1.0.4.jar
  • jsf-api.jar
  • jsf-impl.jar
  • jstl.jar
Katana24
  • 8,706
  • 19
  • 76
  • 118