14
我試圖按照this教程創建一個簡單的REST Web服務,但我可以在Tomcat中部署它,它拋出一個異常:的Tomcat未能部署的.war
FAIL - Application at context path /restful could not be started
FAIL - Encountered exception org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restful]]
我已經看了發現這question和one,他們讓我覺得這是一個servlet映射問題,但我不知道如何解決它!
這裏是我的日誌文件:
18/12/2012 9:57:16 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive /opt/tomcat7/webapps/restful.war
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restful]]
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.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
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:619)
這裏是我的web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"
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_3_0.xsd">
<servlet>
<servlet-name>RestfulContainer</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.mcnz.ws</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestfulContainer</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
</web-app>
,並在給你所有了太多的信息風險,這裏的LS我的文件夾結構:
.:
WEB-INF
./WEB-INF:
classes
lib
web.xml
./WEB-INF/classes:
com
./WEB-INF/classes/com:
mcnz
./WEB-INF/classes/com/mcnz:
ws
./WEB-INF/classes/com/mcnz/ws:
HelloWorldResource.class
HelloWorldResource.java
./WEB-INF/lib:
asm-3.1.jar
jackson-core-asl-1.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-mapper-asl-1.9.2.jar
jackson-xc-1.9.2.jar
jersey-client-1.16.jar
jersey-core-1.16.jar
jersey-json-1.16.jar
jersey-server-1.16.jar
jettison-1.1.jar
jsr311-api-1.1.1.jar
這裏是一個類似的帖子 - http://stackoverflow.com/questions/8512588/tomcat-lifecycleexception-when-demonstloying – EJK
是的,我知道,因爲我張貼在我的問題''我已經找過解決方案和發現這個問題「。」我只是不確定它是否是)一個servlet問題和b)我需要做些什麼來修復它 – Pete
對不起,沒有按照你發佈的鏈接。無論如何,這聽起來很像web.xml中的問題。如果我是你,我會嘗試以下方法...從web.xml中取出servlet和servlet映射元素。重新部署並查看是否出現相同的錯誤。如果不是,那麼你對根本原因有了更好的認識。您可能還想驗證您的WEB-INF/lib文件夾中的一個jar文件中是否存在com/sun/jersey/spi/container/servlet/ServletContainer.class(以jersey-server-1.16.jar開頭)。 – EJK