java.lang.ClassNotFoundException:com.sun.facelets.tag.jsf.ComponentHandler 从 MyFaces 1.1 升级到 MyFaces 2.2 后

java.lang.ClassNotFoundException: com.sun.facelets.tag.jsf.ComponentHandler after upgrading from MyFaces 1.1 to MyFaces 2.2

我正在尝试将 Web 应用程序从 MyFaces 1.1 迁移到 2.2。

我基本上按照基本变化下的第一步从从JSF 1.1升级到JSF 2.2:

目前,我打算保留JSP并首先用Facelets替换它们,大概只是升级JSF的"painless"步骤是成功的。

Web 应用程序使用旧的 JSF 版本,但在执行上述步骤后,我收到以下错误和堆栈跟踪:

java.lang.NoClassDefFoundError: com/sun/facelets/tag/jsf/ComponentHandler
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access0(URLClassLoader.java:73)
    at java.net.URLClassLoader.run(URLClassLoader.java:368)
    at java.net.URLClassLoader.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1191)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1669)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.myfaces.shared.util.ClassUtils.classForName(ClassUtils.java:187)
    at org.apache.myfaces.view.facelets.util.ReflectionUtil.forName(ReflectionUtil.java:66)
    at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig.createClass(TagLibraryConfig.java:539)
    at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig.create(TagLibraryConfig.java:466)
    at org.apache.myfaces.view.facelets.compiler.FaceletsCompilerSupport.loadLibraries(FaceletsCompilerSupport.java:157)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.loadLibraries(FaceletViewDeclarationLanguage.java:2526)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.createCompiler(FaceletViewDeclarationLanguage.java:2172)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.initialize(FaceletViewDeclarationLanguage.java:2464)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.<init>(FaceletViewDeclarationLanguage.java:309)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguageStrategy.<init>(FaceletViewDeclarationLanguageStrategy.java:52)
    at org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl.initialize(ViewDeclarationLanguageFactoryImpl.java:104)
    at org.apache.myfaces.view.ViewDeclarationLanguageFactoryImpl.getViewDeclarationLanguage(ViewDeclarationLanguageFactoryImpl.java:73)
    at org.apache.myfaces.application.ViewHandlerImpl.getViewDeclarationLanguage(ViewHandlerImpl.java:183)
    at org.apache.myfaces.application.ViewHandlerImpl.createView(ViewHandlerImpl.java:255)
    at org.jenia.faces.template.handler.ViewHandler.createView(ViewHandler.java:251)
    at javax.faces.application.ViewHandlerWrapper.createView(ViewHandlerWrapper.java:100)
    at org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.createView(ResourceViewHandlerWrapper.java:70)
    at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:289)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:196)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:489)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:467)
    at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:412)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:201)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.sun.facelets.tag.jsf.ComponentHandler
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    ... 54 more

java.lang.NullPointerException
    at net.sf.jsfcomp.chartcreator.ChartListener.afterPhase(ChartListener.java:42)
    at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersAfter(PhaseListenerManager.java:117)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:211)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:489)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:467)
    at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:412)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:201)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

我们使用 Tomcat7 作为 servlet 容器,使用 IntelliJ Community Edition 作为 IDE,使用 Maven 作为构建管理器和依赖管理。

由于 "Tomahawk" 出现在堆栈跟踪中,根据 Which jars do I need in order to avoid "NoClassDefFoundError: com/sun/facelets/tag/jsf/ComponentHandler"?,我将 /WEB-INF/lib 中的 tomahawk-1.1.9.jar 替换为 tomahawk21-1.1.14.jar。不幸的是,它没有解决问题。

我也找不到专门用于 JSF 2.2 的战斧版本,无论是在 Maven 存储库中还是在其他任何地方。

在 MyFaces 2.2 中使用 tomahawk 是否有必要?

还是错误源于其他原因?

从堆栈跟踪中,我怀疑另一个 JSF 1.x 特定库导致了这个:

at org.jenia.faces.template.handler.ViewHandler.createView(ViewHandler.java:251)

因此请检查 'jenia' 库是什么并获取更新的 jsf 2 兼容版本或将其删除。