Linux 将 .WAR 部署到 tomcat 时遇到问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4590614/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
trouble deploying .WAR to tomcat
提问by David
im having trouble deploying a war file on tomcat.
我在 tomcat 上部署 war 文件时遇到问题。
i have written a webapp in netbeans on my windows machine. it all runs fine. what i want to do is deploy the application on my linux computer that is acting as my server. once the application is built, i copy the war file from the dist folder in my project directory onto a pendrive. i then copy this onto the desktop of my linux computer.
我在我的 Windows 机器上用 netbeans 编写了一个 webapp。一切正常。我想要做的是在充当我的服务器的 Linux 计算机上部署该应用程序。构建应用程序后,我将项目目录中的 dist 文件夹中的 war 文件复制到随身碟上。然后我将其复制到我的 linux 计算机的桌面上。
i then start tomcat and using the application manager i browse the war file to deploy, then click deploy. i get a message at the top of the browser saying 'OK'. yet if i look at my tomcat output in the terminal window i have the following error:
然后我启动tomcat并使用应用程序管理器浏览要部署的war文件,然后单击部署。我在浏览器顶部收到一条消息,说“确定”。但是,如果我在终端窗口中查看我的 tomcat 输出,则会出现以下错误:
4/01/2011 5:09:07 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive Kingdoms.war
4/01/2011 5:09:07 PM org.apache.catalina.startup.ContextConfig init
SEVERE: Exception fixing docBase for context [/Kingdoms]
java.util.zip.ZipException: invalid CEN header (bad signature)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.jar.JarFile.<init>(JarFile.java:135)
at java.util.jar.JarFile.<init>(JarFile.java:72)
at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:72)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:48)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:70)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:104)
at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:71)
at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:111)
at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:706)
at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:829)
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.setState(LifecycleBase.java:328)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:308)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:131)
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:570)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:891)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1322)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1467)
at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:332)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:209)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:561)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:237)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
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:662)
4/01/2011 5:09:07 PM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Invalid or unreadable WAR file : invalid CEN header (bad signature)
at org.apache.naming.resources.WARDirContext.setDocBase(WARDirContext.java:142)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4657)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4815)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
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:570)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:891)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1322)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1467)
at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:332)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:209)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:561)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:237)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
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:662)
4/01/2011 5:09:07 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error in resourceStart()
4/01/2011 5:09:07 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error getConfigured
4/01/2011 5:09:07 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Kingdoms] startup failed due to previous errors
also i can now see in the applications list, my app. i click start in the commands for the app but get a message at the top of the screen saying 'FAIL - Application at context path /Kingdoms could not be started'
我现在也可以在应用程序列表中看到我的应用程序。我在应用程序的命令中单击开始,但在屏幕顶部收到一条消息,提示“失败 - 上下文路径中的应用程序/Kingdoms 无法启动”
what am i doing wrong? how to fix this?
我究竟做错了什么?如何解决这个问题?
采纳答案by pstanton
the war archive is corrupt or invalid.
战争档案已损坏或无效。
check that the war generation procedure is not failing and that the war file is a valid zip file prior to copying to your pen drive etc.
在复制到您的笔式驱动器等之前,请检查 war 生成程序没有失败,并且 war 文件是有效的 zip 文件。
if you're on windows you can do this by changing the file extension to .zip and opening with a zip program such as winzip or winrar.
如果您使用的是 Windows,您可以通过将文件扩展名更改为 .zip 并使用诸如 winzip 或 winrar 之类的 zip 程序打开来完成此操作。
if you're on another operating system you probably don't need to change the extension.
如果您使用的是其他操作系统,则可能不需要更改扩展名。
if the war is a valid zip it's probably being corrupted as a result of your transfer process ie going onto or from your pen drive.
如果 war 是一个有效的 zip,它可能是由于您的传输过程而损坏的,即进入或离开您的笔式驱动器。
回答by Ratna Dinakar
This might be due to one of the following reasons.
这可能是由于以下原因之一。
- Corrupted WAR file
- Corrupted JAR files under WEB-INF/lib folder
- 损坏的 WAR 文件
- WEB-INF/lib 文件夹下损坏的 JAR 文件
回答by Helmut
It could be a file protection issue, which you can fix by issuing something like: chmod 755 webapp.war
这可能是一个文件保护问题,您可以通过发出类似以下内容来解决该问题:chmod 755 webapp.war
it happened to me that my sftp would just slap a 700 on the file transferred, causing that error.
我碰巧我的 sftp 只会在传输的文件上打一个 700,从而导致该错误。
回答by Ivan
have same error - with war all ok, restarting Tomcat resolve problem so i think it's becouse Tomcat start deploy war before it fully uploaded
有同样的错误 - 战争一切正常,重新启动 Tomcat 解决问题,所以我认为这是因为 Tomcat 在完全上传之前开始部署战争
回答by brokethebuildagain
I had the same problem, and rebuilding/uploading the war was NOT fixing the problem. What I ended up doing to fix it was uploading the war under a different name, then renaming the war once it had successfully deployed. A bit bizarre that this would work, but it was a better solution for me than restarting tomcat.
我遇到了同样的问题,重建/上传战争并没有解决问题。我最终为修复它所做的是以不同的名称上传战争,然后在成功部署后重命名战争。这会起作用有点奇怪,但对我来说这是比重新启动 tomcat 更好的解决方案。
回答by Ian
also possibly because of an incorrect entry in solr.xml It must point to where the .war file is located.
也可能是因为 solr.xml 中的条目不正确,它必须指向 .war 文件所在的位置。
回答by 302Found
Also look out for file permissions of the .war file you have deployed. For me that was the cause.
还要注意您部署的 .war 文件的文件权限。对我来说,这就是原因。
回答by czupe
In my case it was the manifest file.
就我而言,它是清单文件。
Class-Path:
should followed by a whitespace.
后面应该跟一个空格。
回答by kazy
First thing to check is if you have free space on your disk. If your partition is 100% full, then it will be impossible to extract the .WAR file.
首先要检查的是您的磁盘上是否有可用空间。如果您的分区 100% 已满,则无法提取 .WAR 文件。