Hi all,<br><br>I am  newbie in DBus programming using java. I am trying to call a method &quot;myfun&quot; on an object class &quot;Demo&quot; in a simple java program (TestDBus.java) from another java program (TestDBus1.java) using DBus Connection. I am able to connecct both these applications to DBus but my code is not able to call method &quot;myfun&quot; and I got some exception. My code and run time exception are as below :<br>
&lt;-------------------------------------------- <b>Demo.java </b>-----------------------------------------------------------------&gt;<br><br>package pack;<br>import org.freedesktop.DBus;<br>import org.freedesktop.dbus.DBusConnection;<br>
import org.freedesktop.dbus.exceptions.DBusException;<br>import org.freedesktop.dbus.DBusInterface;<br><br>interface TestDBusInt extends DBusInterface{<br>public void myfun();<br>}<br><br>public class Demo implements TestDBusInt{<br>
    public Demo(){}<br>    public boolean isRemote(){return false;}<br>    public void myfun(){<br>        System.out.println(&quot;Within myfun of Demo class within TestDBus.class&quot;);<br>    }    <br>}<br><br><br> &lt;-----------------------------------------  <b>TestDBus.java</b> ----------------------------------------------------------&gt;<br>
<br>import org.freedesktop.DBus;<br>import org.freedesktop.dbus.exceptions.DBusException;<br>import org.freedesktop.dbus.*;<br>import pack.Demo;<br><br>public class TestDBus{<br><br>        public static void main(String[] args) throws org.freedesktop.dbus.exceptions.DBusException {<br>
                DBusConnection bus = null;<br><br>               // Getting the Bus Connection.<br><br>        System.out.println(&quot;Connecting Bus........&quot;);<br><br>                bus = DBusConnection.getConnection(DBusConnection.SESSION);<br>
<br>                System.out.println(&quot;Bus Connection Established.&quot;);<br><br>        //Getting Unique name of this connection.<br>        String conName=bus.getUniqueName();<br>        System.out.println(&quot;Unique Name of this Bus Connection =&gt; &quot;+conName);<br>
        <br>        <br>        //Requesting Bus Name.<br>        bus.requestBusName(&quot;My.FirstBus&quot;);<br><br>        <br>        //Getting the names owned by this connection.<br>        System.out.println(&quot;Names owned by this Bus Connection are =&gt;&quot;);<br>
        String []bnames1=bus.getNames();<br>        for(int i=0;i&lt;bnames1.length;i++)<br>            System.out.println(bnames1[i]);<br>        <br><br>        //exporting the Demo class object on the path “/Test”<br>        <br>
        DBusInterface db1=new Demo();<br>        bus.exportObject(&quot;/Test&quot;, db1);<br>                   <br>        while(true){}<br>       <br>        }    <br>}<br><br clear="all"> &lt;-----------------------------------------  <b>TestDBus1.java</b> ----------------------------------------------------------&gt;<br>
<br>import org.freedesktop.DBus;<br>import org.freedesktop.dbus.*;<br>import java.lang.reflect.*;<br>import org.freedesktop.DBus.Introspectable;<br>import org.freedesktop.*;<br>import pack.Demo;<br><br><br>public class TestDBus1 {<br>
    <br>        public static void main(String[] args) throws org.freedesktop.dbus.exceptions.DBusException {<br>        DBusConnection bus1 = null;<br>        DBusConnection bus2=null;<br>                <br>                System.out.println(&quot;Establishing Bus Connection.......&quot;);<br>
<br>                bus1 = DBusConnection.getConnection(DBusConnection.SESSION);<br>              <br>                 System.out.println(&quot;Bus Connection Established.&quot;);<br><br>        //Getting Unique name of this connection.<br>
        String conName1=bus1.getUniqueName();<br>        System.out.println(&quot;Unique Name of this Bus Connection =&gt; &quot;+conName1);<br>        <br><br>        // Getting and Displaying Introspection data on Remote Object.<br>
        Introspectable intro = (Introspectable) bus1.getRemoteObject(<br>                              &quot;My.FirstBus&quot;, &quot;/Test&quot;,<br>                               Introspectable.class);<br><br>        String data = intro.Introspect();<br>
<br>        <br><br>        <br>        //System.out.println(db.myfun());<br><br><br>        System.out.println(&quot;&lt;--------------------------- Introspection Data Start -----------------------------------&gt;&quot;);<br>
        System.out.println(data);<br>        System.out.println(&quot;&lt;--------------------------- Introspection Data End   -----------------------------------&gt;&quot;);<br>        <br><br>        //Getting the remote object and calling a method of that object.<br>
<br>        DBusInterface db=bus1.getPeerRemoteObject(&quot;My.FirstBus&quot;,&quot;/Test&quot;);<br>        DBusAsyncReply&lt;Boolean&gt; stuffreply =bus1.callMethodAsync(db,&quot;myfun&quot;);<br>        <br><br>         while(true){}<br>
                 <br>        }<br>}<br><br>&lt;--------------------------------------------------<b>End Of Code</b> --------------------------------------------------------------------------------------&gt;<br><br><br><br>
<br>&lt;--------------------------------------------<b>Console Output on running TestDBus.java </b>---------------------------------------&gt;<br><br>Connecting Bus........<br>Bus Connection Established.<br>Unique Name of this Bus Connection =&gt; :1.37<br>
Names owned by this Bus Connection are =&gt;<br>:1.37<br>My.FirstBus<br>^Cshivnath@cmk-kbcs-shivnath:~/jdk1.6.0_07/bin/dbusex2$ java TestDBus<br>Connecting Bus........<br>Bus Connection Established.<br>Unique Name of this Bus Connection =&gt; :1.39<br>
Names owned by this Bus Connection are =&gt;<br>:1.39<br>My.FirstBus<br><br><br><br>&lt;------------------------------------- <b>Console Output
on running TestDBus1.java</b> ---------------------------------------&gt;<br><br>Establishing Bus Connection.......<br>Bus Connection Established.<br>Unique Name of this Bus Connection =&gt; :1.40<br>&lt;--------------------------- Introspection Data Start -----------------------------------&gt;<br>
&lt;!DOCTYPE node PUBLIC &quot;-//freedesktop//DTD D-BUS Object Introspection 1.0//EN&quot; &quot;<a href="http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd</a>&quot;&gt;<br>
&lt;node name=&quot;/Test&quot;&gt;<br> &lt;interface name=&quot;pack.TestDBusInt&quot;&gt;<br>  &lt;method name=&quot;myfun&quot; &gt;<br>  &lt;/method&gt;<br> &lt;/interface&gt;<br> &lt;interface name=&quot;org.freedesktop.DBus.Introspectable&quot;&gt;<br>
  &lt;method name=&quot;Introspect&quot;&gt;<br>   &lt;arg type=&quot;s&quot; direction=&quot;out&quot;/&gt;<br>  &lt;/method&gt;<br> &lt;/interface&gt;<br> &lt;interface name=&quot;org.freedesktop.DBus.Peer&quot;&gt;<br>
  &lt;method name=&quot;Ping&quot;&gt;<br>  &lt;/method&gt;<br> &lt;/interface&gt;<br>&lt;/node&gt;<br>&lt;--------------------------- Introspection Data End   -----------------------------------&gt;<br>Exception in thread &quot;main&quot; org.freedesktop.dbus.exceptions.DBusExecutionException: $Proxy2.myfun()<br>
        at org.freedesktop.dbus.AbstractConnection.callMethodAsync(AbstractConnection.java:683)<br>        at TestDBus1.main(TestDBus1.java:48)<br>&lt;------------------------------------------------------<b>End of Console Output</b>--------------------------------------------------------------&gt;<br>
<br>I am not sure, if I am missing something obvious here and would  appreciate any advice on this. Plz, help me if I am going wrong in some way. Plz suggest me what to do to fix such exception and call the method as I want. <br>
Waiting for your reply.<br><br>Thanks in Advance !!<br><br>-- <br>Regards,<br>Shiv Nath Kumar<br>