2012-03-01 49 views
2

我試圖能夠使用ant-contrib遠程啓動一個ant任務。出於測試目的,我已經用以下文件定義了一個服務器和一個調用者。從ant-contrib執行遠程任務時發生EOFException

<?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) 

有沒有人發現類似的東西,任何方式來擺脫例外?

感謝,

+1

忽略它似乎是一個版本中的問題。 Ant 1.8.1與ant-contrib 1.0.3b。 http://sourceforge.net/tracker/?func=detail&aid=3323778&group_id=36177&atid=416920給那些想要跟蹤這個bug的狀態的人。 – pedromarce 2012-03-02 15:57:10

回答

2

這是螞蟻的contrib已知的問題,但你可以

<trycatch> 
     <try> 
      <remoteant machine="localhost" port="12345"> 
      <runtarget target="remoteant"/> 
     </try> 
     <catch> 
      <echo>Ignoring known issue: EOF I.O. exception...</echo> 
     </catch> 
</trycatch> 
+0

但是,這也會導致遠程主機出現問題,您可能需要處理該問題,例如遠程服務器未處於活動狀態。不是嗎? – pedromarce 2013-08-08 16:15:48

相關問題