Error deploying war in tomcat: com.sun.faces.config.ConfigurationException

Pablo picture Pablo · May 31, 2013 · Viewed 12k times · Source

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.

While trying to deploy a war in tomcat 6.0.18 using the tomcat manager, I get the following error:

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:

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.access$400(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.

This is my 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.

Library versions: Myfaces (2.0.2) and Tomahawk (1.1.11).

Answer

BalusC picture BalusC · Jun 3, 2013

Library versions: 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.

You can't mix different JSF implementations. Cleanup the one or the other.