我正在尝试使用ant-contrib远程启动ant任务。出于测试目的,我已经定义了一个服务器和一个带有以下文件的调用者。
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="RMI" basedir="." default="start.ant.server">
<target name="start.ant.server">
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<antserver port="12345" />
</target>
<target name="remoteant">
<echo message="hi"/>
</target>
</project>
和
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="RMI" basedir="." default="call.ant.server">
<target name="call.ant.server">
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<remoteant machine="localhost" port="12345">
<runtarget target="remoteant"/>
</remoteant>
</target>
</project>
当我启动服务器然后运行远程调用时,一切似乎都正常工作但调用者抛出异常:
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2498)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1273)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at net.sf.antcontrib.antserver.client.Client.sendCommand(Client.java:233)
at net.sf.antcontrib.antserver.client.ClientTask.execute(ClientTask.java:144)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
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:585)
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:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:811)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
有没有人发现类似的东西,有什么方法可以摆脱异常?
谢谢,
答案 0 :(得分:2)
这是ant-contrib已知问题,但您可以使用
忽略它<trycatch>
<try>
<remoteant machine="localhost" port="12345">
<runtarget target="remoteant"/>
</try>
<catch>
<echo>Ignoring known issue: EOF I.O. exception...</echo>
</catch>
</trycatch>