[erlang-questions] jinterface (was: otp.net)

Serge Aleynikov <>
Sat Oct 4 07:32:55 CEST 2008


I tried a similar test using jinterface to see if it's possible to 
monitor processes running on a Java node and ran into the same failure.

Can anyone explain what's wrong?

()10> {test, } ! {self(), hello}.
{<0.45.0>,hello}
()11> f(), {Pid, _} = receive M -> M end.
{<5979.1.0>,hello}
()12> erlang:monitor(process, Pid).
** exception error: bad argument
      in function  erlang:monitor/2
         called as erlang:monitor(process,<5979.1.0>)



The corresponding java node was implemented using code below:


import com.ericsson.otp.erlang.*;

public class test {
	public static void main (String args[]) {
		System.out.println ("Hello World!");

         try {
             OtpSelf self = new OtpSelf("client", "abc123");
             OtpPeer other = new OtpPeer("server");
             OtpConnection connection = self.connect(other);

             connection.sendRPC("erlang","date",new OtpErlangList());
             OtpErlangObject received = connection.receiveRPC();
             System.out.println("erlang:date() -> " + received + "\n");

             OtpErlangObject o;
             OtpErlangTuple msg;
             OtpErlangPid from;

             while (true) {
                 try {
                     o = connection.receive();
                     if (o instanceof OtpErlangTuple) {
                         msg = (OtpErlangTuple)o;
                         from = (OtpErlangPid)(msg.elementAt(0));
                         connection.send(from, new OtpErlangTuple(
                             new OtpErlangObject[] {
                                 self.pid(),
                                 msg.elementAt(1)
                             }
                         ) );
                     }
                 }
                 catch (Exception e) {
                     System.out.println("" + e);
                 }
             }
         } catch (Exception e) {
             System.out.println("" + e);
         }
     }
}


Serge Aleynikov wrote:
> While playing with the otp.net project for the past several days I ran 
> into one problem that I can't quite explain.  I am starting a .NET node
> () and connecting to a regular Erlang node 
> (), then send a Pid from .NET to Erlang and try to set up a 
> monitor.  The monitor call fails with badarg:
> 
> ()2> register(test, self()).
> true
> ()3> nodes(hidden).
> []
> ()4> f(M), M = receive M -> M end.
> <5852.1.0>
> ()5> M ! {hello, self()}.
> {hello,<0.50.0>}
> ()6> erlang:monitor(process, M).
> ** exception error: bad argument
>       in function  erlang:monitor/2
>          called as erlang:monitor(process,<5852.1.0>)
> ()7>
> 
> I am able to send messages back and forth between two nodes and verify 
> their delivery, but don't understand why the monitor call would fail. 
> Does anyone have a clue?
> 
> Serge
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list