面对tomcat的部署问题

时间:2012-02-12 15:01:36

标签: java tomcat

我想测试一个可以读取文件系统中特定目录的小应用程序。 当使用带有tomcat的eclipse时,它工作正常,但是当我尝试在我安装的tomcat.7的wepApps目录中部署war时,它会崩溃(请参阅下面的例外)。我还在catalina.policy中添加了对我的应用程序的权限,但没有任何改变。

许可:

//the permission used to grant read/write to test directory for readSystemFile
grant codeBase "file:${catalina.base}/webapps/readSystemFile/WEB-INF/classes/-" {
    permission java.io.FilePermission
         "D:/home/dev/test/*", "read, write";
};

例外:

GRAVE: Exception fixing docBase for context [/readSystemFile] 
java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\readSystemFile\META-INF\MANIFEST.MF (Le chemin d’accès spécifié est introuvable)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:403)
    at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:138)
    at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:721)
    at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:844)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:334)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:379)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:136)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:932)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:723)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:379)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:324)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
12 févr. 2012 15:35:25 org.apache.catalina.core.StandardContext postWorkDirectory
ATTENTION: Failed to create work directory [C:\Program Files\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\readSystemFile] for context [/readSystemFile]
12 févr. 2012 15:35:25 org.apache.catalina.loader.WebappLoader startInternal
GRAVE: LifecycleException 
java.io.IOException: Failed to create destination directory to copy resources
    at org.apache.catalina.loader.WebappLoader.setRepositories(WebappLoader.java:888)
    at org.apache.catalina.loader.WebappLoader.startInternal(WebappLoader.java:603)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5079)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:932)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:723)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:379)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:324)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
12 févr. 2012 15:35:25 org.apache.catalina.core.ContainerBase addChildInternal
GRAVE: ContainerBase.addChild: start: 

4 个答案:

答案 0 :(得分:0)

我建议接下来添加一个MANIFEST文件,因为这就是异常所抱怨的内容。

答案 1 :(得分:0)

你用什么来打包war文件?看起来你正在使用的任何程序都没有创建所需的清单文件(也可能是其他文件)。尝试使用eclipse的导出功能或使用ant。

答案 2 :(得分:0)

我有类似的问题。最有可能是权限设置错误。

答案 3 :(得分:0)

我遇到了类似的问题。放置在webapps文件夹中的War文件未得到部署。实际上,当我从雄猫的管理器控制台中看到它处于停止状态时。 当我尝试启动它时,它没有启动任何上下文,而是引发了Catalina Lifecycle异常,如下所示

失败-上下文路径/ proj-xyz中的应用程序无法启动 失败-遇到异常org.apache.catalina.LifecycleException:无法启动组件[StandardEngine [Catalina] .StandardHost [localhost] .StandardContext [/ proj-xyz]]

我的机器是ubuntu,问题是我已经在没有sudo的情况下启动了tomcat

./startup.sh
or
./catalina.sh start

我认为这是滞后的,因为tomcat不是从sudo开始的。但是后来我意识到并使用了

sudo ./startup.sh
or
sudo ./catalina.sh start

它固定了