简体   繁体   English

远程Tomcat部署的ANT获得500

[英]ANT to Remote Tomcat Deployment gets 500

So I made an ANT target to deploy our app to Tomcat on a remote development server. 因此,我制定了一个ANT目标,以将我们的应用程序部署到远程开发服务器上的Tomcat。 The ANT deploy to tomcat target works 100% perfect on a local Tomcat instance. 将ANT部署到tomcat目标在本地Tomcat实例上可以100%完美地工作。 When I deploy to the remote server I get a fat 500 error but the application actually deploys to the server and we can view and use it just fine as if there were no errors. 当我部署到远程服务器时,我遇到了一个严重的500错误,但是应用程序实际上已部署到服务器上,我们可以很好地查看和使用它,就像没有错误一样。

Super cool that it works but the 500 error causes the ANT target to say the build failed. 超级酷,它可以工作,但是500错误导致ANT目标说构建失败。 If ANT says the build failed, so will Hudson our build server, which means we will have sad red dots instead of happy green ones. 如果ANT表示构建失败,那么构建服务器Hudson也将失败,这意味着我们将拥有可悲的红色点,而不是快乐的绿色点。

We are using the latest and greatest ANT with Tomcat v9. 我们正在将最新和最出色的ANT与Tomcat v9一起使用。

Below is the error I get when I execute my "ant deploy-dev" target. 以下是执行“ ant deploy-dev”目标时遇到的错误。


[username@localhost app.directory]$ ant deploy-dev Buildfile: /home/username/git/app.directory/build.xml Trying to override old definition of datatype resources

deploy-dev: [echo] Deploying app to: https://dev.myapp.com BUILD FAILED /home/username/git/app.directory/build.xml:73: The following error occurred while executing this line: /home/username/git/app.directory/build.xml:146: java.io.IOException: Server returned HTTP response code: 500 for URL: https://dev.myapp.com/manager/text/deploy?path=%2Fmy-app%2F at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:254) at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:194) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405) at org.apache.tools.ant.Project.executeTarget(Project.java:1376) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1260) at org.apache.tools.ant.Main.runBuild(Main.java:854) at org.apache.tools.ant.Main.startAnt(Main.java:236) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)

deploy-dev: [echo] Deploying app to: https://dev.myapp.com BUILD FAILED /home/username/git/app.directory/build.xml:73: The following error occurred while executing this line: /home/username/git/app.directory/build.xml:146: java.io.IOException: Server returned HTTP response code: 500 for URL: https://dev.myapp.com/manager/text/deploy?path=%2Fmy-app%2F at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:254) at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:194) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405) at org.apache.tools.ant.Project.executeTarget(Project.java:1376) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1260) at org.apache.tools.ant.Main.runBuild(Main.java:854) at org.apache.tools.ant.Main.startAnt(Main.java:236) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)

Total time: 3 minutes 3 seconds


To get an idea of what is running, here is the important parts of the ANT build.xml. 为了了解正在运行的内容,这是ANT build.xml的重要部分。

 <property environment="env"/> <property file="build.properties"/> <!-- Import --> <import file="${env.CATALINA_HOME}/bin/catalina-tasks.xml" optional="true"/> <!-- The deploy to Tomcat target --> <target name="deploy-local" description="Deploy the app to local Tomcat"> <tomcat-deploy base-url="${url.base.local}"/> </target> <target name="deploy-dev" description="Deploy the app to dev Tomcat"> <tomcat-deploy base-url="${url.base.dev}"/> </target> <target name="undeploy-local" depends="stop-local" description="Undeploy the app from local Tomcat"> <tomcat-undeploy base-url="${url.base.local}"/> </target> <target name="undeploy-dev" depends="stop-dev" description="Undeploy the app from dev Tomcat"> <tomcat-undeploy base-url="${url.base.dev}"/> </target> <target name="stop-local" description="Stop the app on local Tomcat"> <tomcat-stop base-url="${url.base.local}"/> </target> <target name="stop-dev" description="Stop the app on dev Tomcat"> <tomcat-stop base-url="${url.base.dev}"/> </target> <macrodef name="tomcat-deploy"> <attribute name="base-url"/> <sequential> <echo>Deploying app to: @{base-url}</echo> <deploy url="@{base-url}/manager/text" username="${username}" password="${password}" path="/${app.name}" war="file:${war.path}.war"/> </sequential> </macrodef> <macrodef name="tomcat-undeploy"> <attribute name="base-url"/> <sequential> <echo>Un-deploying app from: @{base-url}</echo> <undeploy failonerror="no" url="@{base-url}/manager/text" username="${username}" password="${password}" path="/${app.name}" /> </sequential> </macrodef> <macrodef name="tomcat-stop"> <attribute name="base-url"/> <sequential> <echo>Stopping the app at: @{base-url}</echo> <stop url="@{base-url}/manager/text" username="${username}" password="${password}" path="/${app.name}" /> </sequential> </macrodef> 

Anyone have any idea why the deploy to remote works but still returns an error? 任何人都知道为什么部署到远程工作但仍然返回错误吗? The error I get is kind of vague so I don't know what I could do to debug it. 我得到的错误有点含糊,所以我不知道该如何调试。

The problem was the server was taking too long to deploy the app. 问题在于服务器部署该应用程序花费的时间太长。 Somewhere the Tomcat Deploy target is waiting for a response from the server saying the app was deployed. Tomcat Deploy目标正在某个地方等待服务器的响应,说明该应用程序已部署。 Unfortunately the only error is the 500 and there is nothing else to go on. 不幸的是,唯一的错误是500,没有别的可继续了。

The solution, I simply re-installed Tomcat with Version 9, up from 8, and everything turned on much faster and the build was successful. 解决方案是,我只是从版本8重新安装了Tomcat,而版本9则使一切打开得更快,并且构建成功。

I can't really say this is the best answer but I got everything working.Hopefully someone has a better solution one day. 我不能说这是最好的答案,但是我已经做好了一切。希望某天有更好的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM