因此,我制定了一个蚂蚁目标,将我们的应用程序部署到远程开发服务器上的tomcat。蚂蚁部署到Tomcat Target上在本地Tomcat实例上工作100%。当我部署到远程服务器时,我会收到一个胖500错误,但是该应用程序实际上将其部署到服务器,我们可以查看和使用它,就像没有错误一样。
超级酷可起作用,但500个错误导致蚂蚁目标说构建失败。如果Ant说构建失败了,那么Hudson我们的构建服务器也会失败,这意味着我们将拥有悲伤的红点,而不是快乐的绿色点。
我们正在使用Tomcat V9的最新和最伟大的蚂蚁。
以下是执行" 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)
Total time: 3 minutes 3 seconds
要了解正在运行的内容,这是蚂蚁构建的重要部分。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>
有人知道为什么部署到遥控器有效但仍然返回错误?我得到的错误有点含糊,所以我不知道我该怎么做来调试它。
问题是服务器花费的时间太长,无法部署应用程序。Tomcat部署目标的某个地方正在等待服务器的响应,说该应用已部署。不幸的是,唯一的错误是500,没有其他事情要进行。
解决方案,我只是将tomcat重新安装了版本9,从8版开始,一切都更快地打开了,构建成功。
我不能真正说这是最好的答案,但是我得到了一切正常。希望有人有一个更好的解决方案。