Tomcat v7.023无法部署JSF2.0 Web应用程序

时间:2012-12-13 10:05:26

标签: jsf tomcat

我们正在尝试将JSF2.0 Web应用程序部署到Apache Tomcat / 7.0.23中。我们收到以下错误:


INFO: Initializing Mojarra 2.0.4 (FCS b09) for context '/WSNzControl'
Dec 13, 2012 9:54:28 AM com.sun.faces.config.ConfigureListener contextInitialized
SEVERE: Critical error during deployment: 
java.lang.NoClassDefFoundError: com/sun/faces/spi/DiscoverableInjectionProvider
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1675)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
    at com.sun.faces.util.Util.loadClass(Util.java:291)
    at com.sun.faces.spi.InjectionProviderFactory.getProviderFromEntry(InjectionProviderFactory.java:315)
    at com.sun.faces.spi.InjectionProviderFactory.findProviderClass(InjectionProviderFactory.java:283)
    at com.sun.faces.spi.InjectionProviderFactory.createInstance(InjectionProviderFactory.java:114)
    at com.sun.faces.application.ApplicationAssociate.<init>(ApplicationAssociate.java:209)
    at com.sun.faces.application.ApplicationImpl.<init>(ApplicationImpl.java:210)
    at com.sun.faces.application.ApplicationFactoryImpl.getApplication(ApplicationFactoryImpl.java:107)
    at com.sun.faces.config.processor.AbstractConfigProcessor.getApplication(AbstractConfigProcessor.java:130)
    at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:252)
    at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
    at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:116)
    at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:216)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:338)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:226)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:842)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: com.sun.faces.spi.DiscoverableInjectionProvider
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 44 more

应用程序在本地(Win)中在Tomcat v7.023中部署正常,但在Linux服务器中部署在Tomcat v7.023中时失败: Apache Tomcat / 7.0.23 JVM 1.6.0_26-b03 Sun Microsystems Inc. 红帽4.4.6-3

JSF库是版本mojarra-2.0.4-FCS,我们在Web应用程序的WEB-INF \ lib文件夹中包含了jsf-api.jar和jsf-impl.jar。

这是web.xml:


    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>WSNzControl</display-name>
  <welcome-file-list>
    <welcome-file>faces/resources/views/Main.xhtml</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
     </context-param>
   <listener>
   <listener-class>
   com.sun.faces.config.ConfigureListener
   </listener-class>
   </listener> 
   </web-app>

有什么可能导致此错误的提示?

1 个答案:

答案 0 :(得分:4)

当有问题的Tomcat实例本身已经捆绑在其/lib文件夹或其他地方的JSF库时,可能会发生这种情况,这些文件夹由Tomcat的通用类加载器或者甚至是引导类加载器(这可能是非常糟糕的)覆盖设置)。

您可以通过从Web应用程序中删除JSF库并进行部署来确认这一点。如果它可以工作,那么联系负责的服务器管理员为什么Tomcat配置如此。没有办法告诉Tomcat不加载它的捆绑JSF,所以如果你打算在WAR中部署一个更新的JSF版本,那么你完全陷入困境并依赖于服务器管理员。在像Glassfish和JBoss这样更完善的Java EE容器中,可以通过一个简单的配置条目,通过WAR提供的JSF实现来覆盖容器提供的JSF实现。