java 在 tomcat 中部署战争时出错:com.sun.faces.config.ConfigurationException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16854309/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error deploying war in tomcat: com.sun.faces.config.ConfigurationException
提问by Pablo
This application works properly when I execute it from NetBeans (the proyect in NetBeans is configured to use a tomcat 6 in localhost to deploy it). The problem happens when I try to deploy the war in another tomcat.
当我从 NetBeans 执行这个应用程序时它可以正常工作(NetBeans 中的项目被配置为使用本地主机中的 tomcat 6 来部署它)。当我尝试在另一个 tomcat 中部署War时会出现问题。
While trying to deploy a war in tomcat 6.0.18 using the tomcat manager, I get the following error:
在尝试使用 tomcat 管理器在 tomcat 6.0.18 中部署War时,我收到以下错误:
30-may-2013 16:19:48 org.apache.catalina.core.StandardContext start
GRAVE: Error listenerStart
This is too broad, so I searched around how to get a more specific error, and after adding logging.properties
to WEB-INF
, I got this stack trace:
这太宽泛了,所以我搜索了如何获得更具体的错误,在添加logging.properties
到之后WEB-INF
,我得到了这个堆栈跟踪:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! org.apache.myfaces.webapp.filter.TomahawkFacesContextFactory
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:213)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:196)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:515)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1231)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1471)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:243)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:347)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.InstantiationException: org.apache.myfaces.webapp.filter.TomahawkFacesContextFactory
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:537)
at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:405)
at javax.faces.FactoryFinder.access0(FactoryFinder.java:135)
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:717)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:239)
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:186)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:131)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:203)
... 34 more
The root cause is java.lang.InstantiationException: org.apache.myfaces.webapp.filter.TomahawkFacesContextFactory. This exception is thrown when Class.newInstance()is called. Lookig at the javadoc, the main causes for this exception are "the class object represents an abstract class, an interface, an array class, a primitive type, or void" and "the class has no nullary constructor". TomahawkFacesContextFactory doesn't have a constructor without arguments, so I think that's why the exception is thrown. And here is where I'm stuck, I don't know how to fix this.
根本原因是java.lang.InstantiationException: org.apache.myfaces.webapp.filter.TomahawkFacesContextFactory。调用Class.newInstance()时会抛出此异常。查看javadoc,此异常的主要原因是“类对象表示抽象类、接口、数组类、原始类型或void”和“该类没有空构造函数”。TomahawkFacesContextFactory 没有没有参数的构造函数,所以我认为这就是抛出异常的原因。这就是我卡住的地方,我不知道如何解决这个问题。
This is my web.xml:
这是我的 web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>XXXX</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</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>
<servlet>
<description></description>
<display-name>servlet</display-name>
<servlet-name>servlet</servlet-name>
<servlet-class>servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servlet</servlet-name>
<url-pattern>/servlet</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<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>
<description>
This parameter tells MyFaces if javascript code should be allowed in
the rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default is 'true'</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
If true, rendered HTML code will be formatted, so that it is 'human-readable'
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default is 'true'</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default is 'false'
</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
</web-app>
The tomcat is executing on RedHatEnterpriseServer 5.2. It uses Java 1.6.0_10.
tomcat 正在 RedHatEnterpriseServer 5.2 上执行。它使用 Java 1.6.0_10。
Library versions: Myfaces (2.0.2) and Tomahawk (1.1.11).
库版本:Myfaces (2.0.2) 和 Tomahawk (1.1.11)。
回答by BalusC
Library versions: Myfaces (2.0.2)
库版本:Myfaces (2.0.2)
The involvement of com.sun.faces
in the stack trace however indicates that Mojarra is actually been used. If you're absolutely positive that your webapp bundles MyFaces, then that can only mean that Mojarra is installed elsewhere in the webapp's runtime classpath which has equal or higher classloading precedence over the webapp-supplied libraries, such as locations identified by shared.loader
property of Tomcat's /conf/catalina.properties
.
com.sun.faces
然而,堆栈跟踪中的 参与表明实际上使用了 Mojarra。如果你绝对肯定你的 webapp 捆绑了 MyFaces,那么这只能意味着 Mojarra 安装在 webapp 的运行时类路径中的其他地方,它具有与 webapp 提供的库相同或更高的类加载优先级,例如由shared.loader
Tomcat 的/conf/catalina.properties
.
You can't mix different JSF implementations. Cleanup the one or the other.
您不能混合不同的 JSF 实现。清理其中一个。