我在服务器启动时遇到一个小问题,它无法找到web.xml上下文文件。 (documentation watch)
以下是例外:
oct. 24, 2013 5:04:17 PM org.apache.catalina.core.AprLifecycleListener init
Infos: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre7/bin/client;C:/Program Files (x86)/Java/jre7/bin;C:/Program Files (x86)/Java/jre7/lib/i386;C:\Ruby200\bin;C:\Python33\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Network Monitor 3\;C:\Program Files\nodejs\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\SlikSvn\bin;C:\Program Files\Sublime Text 2\;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\Users\Vincent\AppData\Roaming\npm;C:\Program Files (x86)\Nmap;D:\32bit\eclipse_4.3.1;;.
oct. 24, 2013 5:04:17 PM org.apache.coyote.AbstractProtocol init
Infos: Initializing ProtocolHandler ["http-bio-8080"]
oct. 24, 2013 5:04:17 PM org.apache.coyote.AbstractProtocol init
Infos: Initializing ProtocolHandler ["ajp-bio-8009"]
oct. 24, 2013 5:04:17 PM org.apache.catalina.startup.Catalina load
Infos: Initialization processed in 346 ms
oct. 24, 2013 5:04:17 PM org.apache.catalina.core.StandardService startInternal
Infos: Démarrage du service Catalina
oct. 24, 2013 5:04:17 PM org.apache.catalina.core.StandardEngine startInternal
Infos: Starting Servlet Engine: Apache Tomcat/7.0.42
oct. 24, 2013 5:04:17 PM org.apache.catalina.startup.HostConfig deployDescriptor
Infos: Déploiement du descripteur de configuration C:\Users\Vincent\workspace-kepler-pi\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\arsinoe_eng.xml
oct. 24, 2013 5:04:17 PM org.apache.catalina.startup.SetContextPropertiesRule begin
Avertissement: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:arsinoe_eng' did not find a matching property.
oct. 24, 2013 5:04:17 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
Avertissement: [SetPropertiesRule]{Context/Loader} Setting property 'useSystemClassLoaderAsParent' to 'false' did not find a matching property.
oct. 24, 2013 5:04:18 PM org.apache.catalina.core.ContainerBase addChildInternal
Grave: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/arsinoe_eng]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer
at org.apache.catalina.startup.ContextConfig.getServletContainerInitializer(ContextConfig.java:1654)
at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1562)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1270)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
oct. 24, 2013 5:04:18 PM org.apache.catalina.startup.HostConfig deployDescriptor
Grave: Erreur lors du déploiement du descripteur de configuration C:\Users\Vincent\workspace-kepler-pi\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\arsinoe_eng.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/arsinoe_eng]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
oct. 24, 2013 5:04:18 PM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["http-bio-8080"]
oct. 24, 2013 5:04:18 PM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["ajp-bio-8009"]
oct. 24, 2013 5:04:18 PM org.apache.catalina.startup.Catalina start
Infos: Server startup in 349 ms
这是我项目的构建:
\> arsinoe_eng - (project name)
\----> src
\----> build
\----> data (ressource)
\----> WebContent
\---->----> META-INF
\---->----> WEB-INF
\---->---->----> lib
\---->---->----> web.xml
\---->----> index.html
我的web.xml
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>
com.imagina.aten.engine.webservicev2.WebserviceApplication</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/REST/*</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>REST</web-resource-name>
<url-pattern>/REST/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>REST</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>JDE</realm-name>
</login-config>
<security-role>
<description>Description</description>
<role-name>REST</role-name>
</security-role>
<filter>
<filter-name>SobekEncodingFilter</filter-name>
<filter-class> com.imagina.sobek.engine.SobekEncodingFilter</filter-class>
</filter>
<filter>
<filter-name>SobekExpireFilter</filter-name>
<filter-class>com.imagina.sobek.engine.SobekExpireFilter</filter-class>
<init-param>
<param-name>expirationDelay</param-name>
<param-value>1440</param-value>
</init-param>
</filter>
<filter>
<filter-name>AjaxAnywhere</filter-name>
<filter-class>org.ajaxanywhere.AAFilter</filter-class>
</filter>
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>com.imagina.sobek.engine.SobekEngine</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class> org.apache.axis.transport.http.AxisServlet </servlet-class>
</servlet>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<servlet-class> org.apache.axis.transport.http.AdminServlet </servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<servlet-name>SOAPMonitorService</servlet-name>
<servlet-class> org.apache.axis.monitor.SOAPMonitorService </servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/axis/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
<filter-mapping>
<filter-name>SobekEncodingFilter</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>AjaxAnywhere</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping>
<!--<filter-mapping>
<filter-name>SobekExpireFilter</filter-name>
<url-pattern>*.js</url-pattern>
</filter-mapping>-->
<filter-mapping>
<filter-name>SobekExpireFilter</filter-name>
<url-pattern>*.gif</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>SobekExpireFilter</filter-name>
<url-pattern>*.jpg</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>SobekExpireFilter</filter-name>
<url-pattern>*.css</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>SobekExpireFilter</filter-name>
<servlet-name>invoker</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>SobekExpireFilter</filter-name>
<url-pattern>*.png</url-pattern>
</filter-mapping>
<mime-mapping>
<extension>manifest</extension>
<mime-type>text/cache-manifest</mime-type>
</mime-mapping>
<!-- log4j 2 conf (to remove if servlet version is upgraded to 3.0 or higher) -->
<!--<listener>
<listener-class>
org.apache.logging.log4j.core.web.Log4jServletContextListener</listener-class>
</listener>
<filter>
<filter-name>log4jServletFilter</filter-name>
<filter-class>
org.apache.logging.log4j.core.web.Log4jServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>log4jServletFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>-->
</web-app>
提前感谢您的帮助。
答案 0 :(得分:5)
当您的应用程序错误地捆绑Servlet API JAR时会发生这种情况。检查servlet-api.jar
的依赖项,并将其从/WEB-INF/lib
中删除。如果您使用Maven,只需将servlet依赖项标记为provided
:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>