1
votes

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
2
Are you using RichFaces 3.x instead of 4.x or so? What JARs do you all have in /WEB-INF/lib?BalusC
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.jarDanijel
Looks fine. Didn't you have manually put anything in Tomcat/lib or even JRE/lib or JRE/lib/ext?BalusC
I also have Tomahawk jars and AXIS2 jars. But should they matter?Danijel
Which jar contains com.sun.facelets?Danijel

2 Answers

2
votes

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:

1
votes

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.