我試圖使用Jetty的WebAppProvider
來觀察WAR目錄並部署它們。似乎一切正常:Jetty報告說它將WAR部署到我期望的上下文中。但是當我嘗試訪問該頁面時,Jetty在那裏找不到任何東西。在Jetty 8中使用WebAppProvider,Jetty部署WAR並且無法找到它
我的服務器代碼是
public static void main(String[] args) throws Exception {
Server httpServer = new Server(3030);
DeploymentManager deploymentManager = new DeploymentManager();
httpServer.setDumpBeforeStop(true);
ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();
contextHandlerCollection.setServer(httpServer);
deploymentManager.setContexts(contextHandlerCollection);
WebAppProvider appProvider = new WebAppProvider();
appProvider.setMonitoredDirName("/tmp/wars/");
appProvider.setScanInterval(1);
appProvider.setDeploymentManager(deploymentManager);
appProvider.setExtractWars(true);
httpServer.addBean(deploymentManager);
httpServer.addBean(contextHandlerCollection);
httpServer.addBean(appProvider);
httpServer.start();
}
我的WAR文件部署的罰款,如果我使用碼頭亞軍罐子和單獨部署它們,但我上面的代碼,我看到這樣的輸出:
2013-01-16 15:34:30.571:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/sample,file:/private/var/folders/qg/1t5k32g9567cwwl7y6tfdhj40000gn/T/jetty-0.0.0.0-3030-sample.war-_sample-any-/webapp/},/private/tmp/wars/sample.war
2013-01-16 15:34:30.571:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/sample,file:/private/var/folders/qg/1t5k32g9567cwwl7y6tfdhj40000gn/T/jetty-0.0.0.0-3030-sample.war-_sample-any-/webapp/},/private/tmp/wars/sample.war
2013-01-16 15:34:30.571:DBUG:oejuc.AbstractLifeCycle:starting HelloServlet
(有很多更多的調試文本表明我的webapp已經啓動並且生活在/sample
)
當我訪問127.0.0.1:3030/sample
(我把服務器放在p ort 3030),我得到一個404消息,和碼頭日誌
2013-01-16 15:34:47.799:DBUG:oejs.Server:REQUEST /sample on [email protected],g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-5,l=10,c=0},r=1
2013-01-16 15:34:47.799:DBUG:oejs.Server:RESPONSE /sample 200 handled=false
我找不出我失蹤的東西。有沒有人有這種設置的工作示例?