1

I'm trying to build a JavaServer Faces 2.0 project (using Apache Myfaces 2.0.2 + Tomcat 7.0.25 via Eclipse Indigo). All seems to be set, Tomcat starts ok, but when I try to open a web page I get the error:

SEVERE: An exception occurred javax.faces.FacesException: java.lang.NoClassDefFoundError: com/sun/facelets/tag/jsf/ComponentHandler

As I understand, some jar(s) are missing, the one which has this class: com.sun.facelets.tag.jsf.ComponentHandler.

Jar finder tells me that I should have "jsf-facelets.jar" (http://www.jarfinder.com/index.php/java/info/com.sun.facelets.tag.jsf.ComponentHandler/).

However, there is no download section at http://facelets.java.net/.

Which jars do I need? Why isn't MyFaces enough?

INFO: Server startup in 20457 ms
10.02.2012. 15:51:03 org.apache.myfaces.renderkit.ErrorPageWriter handleThrowable
SEVERE: An exception occurred
javax.faces.FacesException: java.lang.NoClassDefFoundError: com/sun/facelets/tag/jsf/ComponentHandler
    at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241)
    at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:191)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1805)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/sun/facelets/tag/jsf/ComponentHandler
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2836)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1160)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1668)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.myfaces.shared_impl.util.ClassUtils.classForName(ClassUtils.java:178)
    at org.apache.myfaces.view.facelets.util.ReflectionUtil.forName(ReflectionUtil.java:67)
    at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig$LibraryHandler.createClass(TagLibraryConfig.java:475)
    at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig$LibraryHandler.endElement(TagLibraryConfig.java:373)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLNSDTDValidator.endNamespaceScope(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig.create(TagLibraryConfig.java:632)
    at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig.loadImplicit(TagLibraryConfig.java:670)
    at org.apache.myfaces.view.facelets.compiler.Compiler.initialize(Compiler.java:93)
    at org.apache.myfaces.view.facelets.compiler.Compiler.compileViewMetadata(Compiler.java:125)
    at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory._createViewMetadataFacelet(DefaultFaceletFactory.java:311)
    at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getViewMetadataFacelet(DefaultFaceletFactory.java:394)
    at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getViewMetadataFacelet(DefaultFaceletFactory.java:376)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage._getViewMetadataFacelet(FaceletViewDeclarationLanguage.java:1902)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.access$000(FaceletViewDeclarationLanguage.java:128)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage$FaceletViewMetadata.createMetadataView(FaceletViewDeclarationLanguage.java:2136)
    at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:161)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
    ... 18 more
Caused by: java.lang.ClassNotFoundException: com.sun.facelets.tag.jsf.ComponentHandler
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
    ... 58 more
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Danijel
  • 8,198
  • 18
  • 69
  • 133
  • Are you using RichFaces 3.x instead of 4.x or so? What JARs do you all have in `/WEB-INF/lib`? – BalusC Feb 10 '12 at 14:15
  • I'm using Myfaces 2.0.2. Jars are: commons-beanutils-1.8.3.jar commons-codec-1.3.jar commons-collections-3.2.jar commons-digester-1.8.jar commons-discovery-0.4.jar commons-logging-1.1.1.jar myfaces-api-2.0.2.jar myfaces-impl-2.0.2.jar And also JSTL jars: jstl-api-1.2.jar jstl-impl-1.2.jar – Danijel Feb 10 '12 at 14:21
  • Looks fine. Didn't you have manually put anything in Tomcat/lib or even JRE/lib or JRE/lib/ext? – BalusC Feb 10 '12 at 14:27
  • I also have Tomahawk jars and AXIS2 jars. But should they matter? – Danijel Feb 10 '12 at 14:29
  • Which jar contains com.sun.facelets? – Danijel Feb 10 '12 at 14:30
  • Tomahawk and AXIS2 don't have Facelets 1.x dependencies. Facelets 1.x is contained in `jsf-facelets.jar`, but you should **not** need to have it if you're using JSF 2.x, unless you're using for example RichFaces 3.x on JSF 2.x (which requires more hacks anyway). Can you please edit your question to include the full stacktrace? Perhaps it contains information about what dependency is requiring Facelets 1.x. – BalusC Feb 10 '12 at 14:32
  • OK, you are already helping me. The project, in fact, used to be JSF 1.x, and now I am converting it to JSF 2, so there must be some code left that is using 1.x. Is that the right direction? – Danijel Feb 10 '12 at 14:46
  • Updated the question with stack trace. – Danijel Feb 10 '12 at 14:55

2 Answers2

2

Relevant part from the stacktrace:

Caused by: java.lang.NoClassDefFoundError: com/sun/facelets/tag/jsf/ComponentHandler
    ...
    at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig$LibraryHandler.createClass(TagLibraryConfig.java:475)
    at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig$LibraryHandler.endElement(TagLibraryConfig.java:373)

There's somewhere a Facelets 1.x tag library in your webapp and I think it's a custom one as you don't seem to be using JSF 1.x targeted component libraries (such as RichFaces 3.x or Tomahawk for JSF 1.x). Look for *.taglib.xml files in your webapp (they're usually in /WEB-INF or /META-INF) and update its XML root declaration to comply Facelets 2.0 as follows:

<facelet-taglib 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
    version="2.0">

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • No, don't have any xmls like *.taglib.xml. – Danijel Feb 10 '12 at 15:20
  • Then it's in one of the JARs in the classpath. You have still not answered my question in the comment if you have ever touched Tomcat's or JRE's library. You've got to post a list of **all** JARs you have manually placed in the *entire* runtime classpath so that one can point out the offending JAR. – BalusC Feb 10 '12 at 15:31
  • No, I did not add anything to Tomcat/lib, nor JRE/lib. Where else should I look? – Danijel Feb 13 '12 at 11:32
  • Which tag libraries have you all imported in your view? In other words, show all XML namespaces you've declared in your view root. – BalusC Feb 13 '12 at 12:05
  • Seems like Tomahawk was the problem. I was removing jars package by package, and when I removed Tomahawk it stoped giving me that error. Now I went to http://myfaces.apache.org/tomahawk/download.html and I see there are separate versions for JSF 1.2 and 2.0. So, could we say Tomahawk needs to be upgraded? – Danijel Feb 13 '12 at 12:07
  • So you were using Tomahawk for JSF 1.2 instead of Tomahawk for JSF 2.0 while you're using JSF 2.0? Well, that's definitely the problem! – BalusC Feb 13 '12 at 12:08
  • Yes, sorry, I am new to this. It was a JSF 1.2 project, and now I am converting it step by step to JSF 2.0. Thanks for all the help. – Danijel Feb 13 '12 at 12:19
1

Ok, the problem was that I was using Tomahawk for JSF 1.2 instead of Tomahawk for JSF 2.0 while I was using JSF 2.0.

Danijel
  • 8,198
  • 18
  • 69
  • 133