我一直在我的计算机上编写代码并将该代码导入其他计算机。但是当我部署代码并在另一台机器上运行它时,tomcat 无法正常启动并抛出错误。
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" 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>Try</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>
<description>Apache CXF Endpoint</description>
<display-name>cxf</display-name>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/services/ *</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<servlet>
<description>JAX-RS Tools Generated - Do not modify</description>
<servlet-name>JAX-RS Servlet</servlet-name>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/jaxrs/*</url-pattern>
</servlet-mapping>
</web-app>
控制台日志:
Jan 11, 2017 1:33:12 AM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Try' did not find a matching property. Jan 11, 2017 1:33:12 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server version: Apache Tomcat/8.0.39
SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Try]] at java.util.concurrent.FutureTask.report(FutureTask.java:122)Blockquote
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Try]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) ... 6 more Caused by: java.lang.IllegalArgumentException: Unable to create an instance of type [com.sun.faces.config.ConfigureListener] at org.apache.catalina.core.ApplicationContext.addListener
Caused by: java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
我在 Stack Exchange 上尝试过针对同一问题的其他解决方案。但对我来说没有任何用处。
最佳答案
似乎引起类com.sun.faces.config.ConfigureListener
存在于您的计算机中,但不存在于目标计算机中。这个类通常属于jsf-impl.jar
或 jsf-ri.jar
图书馆。
由于您在两台机器上部署了相同的 war (我假设),所以这些库显然没有进入 war ,因此它们很可能进入您计算机的 Tomcat 运行时:在目录 <tomcat>/lib
中查找它。复制到目标机器的Tomcat lib目录下。
关于java - Tomcat 8 抛出错误 : 'A child container failed during start' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41565183/