2

I am trying to be able to launch an ant task remotely using ant-contrib. For testing purposes I have defined a server and a caller with following files.

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

And

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

When I start the server and then run the remote call, everything seems to be working fine but the caller throws an exception:

    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)

Has anyone found something similar, any way to get rid of the exception?

Thanks,

pedromarce
  • 5,651
  • 2
  • 27
  • 27
  • 1
    Seems to be a problem with versions. Ant 1.8.1 with ant-contrib 1.0.3b. http://sourceforge.net/tracker/?func=detail&aid=3323778&group_id=36177&atid=416920 to whoever that want to track the status of this bug. – pedromarce Mar 02 '12 at 15:57

1 Answers1

2

It is ant-contrib known issue, but you can ignore it with

<trycatch>
       <try>
             <remoteant machine="localhost" port="12345"> 
             <runtarget target="remoteant"/>
        </try>
        <catch>
            <echo>Ignoring known issue: EOF I.O. exception...</echo>
        </catch>
</trycatch>
kmkdz
  • 36
  • 2
  • But that would also catch an issue with the remote host, something that you might want to deal with it, for instance the remote server not being active. Wouldn't it? – pedromarce Aug 08 '13 at 16:15