Re: How to Get the ObjectID?
Niclas Hedhman <[email protected]> Tue, 26 May 2009 21:48:46 +0800
| Newsgroups | gmane.comp.java.sun.rmi |
|---|---|
| Message-ID | <[email protected]> |
I am just guessing a lot (never looked at RMI at socket level); #1, #2 Establishment of RMI socket which is shared within a client JVM to same server, same port and socket factories. #3, #4 Establishment of the lease of such client, i.e. the heart beat for the above connection, and probably used in DGC algorithm as well. #5, #6 No clue. Maybe acknowledgment of the above. Also, don't forget that RMI uses MarshalledObject as a serialization container for anything involving Java objects and data types, e.g. #3/4 is probably MarshalledObject for lease/dgc management and hard to decode without going through the source code. But, I would heed Esmond's advice; Don't bother, more trouble than it is worth. You could also check and see if Apache Harmony has implemented RMI yet, in which case you could copy code from there, without worrying about SCSL, GPL and all of those "Freedom" restrictions. Cheers Niclas On Tue, May 26, 2009 at 4:57 PM, Alex Co <[email protected]> wrote: > I sent too much text on my replay and just the end of my reply was sent t= o > the forum/mailling list. > Please, consider read the attached txt that has all the reply text. > > Thank you once again > > Alex > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D > To unsubscribe, send email to [email protected] and include in the bo= dy > of the message "signoff RMI-USERS". =A0For general help, send email to > [email protected] and include in the body of the message "help". > > For a list of frequently asked RMI questions please refer to: > http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html > > To view past RMI-USERS postings, please see: > http://archives.java.sun.com/archives/rmi-users.html > > Hi, > > I cant use the stub to invoke the rmi server method because the device i = am using has no capabilities to run a standard java virtual machine. I deve= loped a tiny JVM and now i need to give it =A0means to, at least, invoke rm= i methods on other resource rich devices like PCs. > Please, consider help me if you know the rmi protocol details that are no= t specificed on the RMI official spec. > > Meanwhile I discovered that the objID i was looking for is in the rmi ser= ver implementation and not on the skeletton. > > > > > Conside this source code of my RMIServer: > > =85 > Naming.rebind("HelloWorld", obj); > =85 > System.out.println(obj.toString()); > =85 > > > > > When i run the RMI server shows this on the console: > > > HelloWorldServer[UnicastServerRef [liveRef: [endpoint:[192.168.1.2:27000]= (local) > ,objID:[-621ddd5b:12177edca46:-7fff, -6483729047876005357]]]] > > > > > Using the standard rmi client (not the custom socket client) and sniffing= the messages that arrive/leave RMI Server, > I see this: > > > > 1# (Receive) > 00000000 =A04A 52 4D 49 00 02 4B =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 JRMI..K > > > 2# (Send) > 00000000 =A04E 00 0B 31 39 32 2E 31 36 38 2E 31 2E 32 00 00 =A0 =A0N..192= .168.1.2.. > 00000010 =A008 EA =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.. > > > 3# (Receive) > 00000000 =A000 0B 31 39 32 2E 31 36 38 2E 31 2E 32 00 00 00 =A0 =A0..192.= 168.1.2... > 00000010 =A000 50 AC ED 00 05 77 22 00 00 00 00 00 00 00 02 =A0 =A0.P....= w"........ > 00000020 =A000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =A0 =A0......= .......... > 00000030 =A000 01 F6 B6 89 8D 8B F2 86 43 75 72 00 18 5B 4C =A0 =A0......= ...Cur..[L > 00000040 =A06A 61 76 61 2E 72 6D 69 2E 73 65 72 76 65 72 2E =A0 =A0java.r= mi.server. > 00000050 =A04F 62 6A 49 44 3B 87 13 00 B8 D0 2C 64 7E 02 00 =A0 =A0ObjID;= .....,d~.. > 00000060 =A000 70 78 70 00 00 00 01 73 72 00 15 6A 61 76 61 =A0 =A0.pxp..= ..sr..java > 00000070 =A02E 72 6D 69 2E 73 65 72 76 65 72 2E 4F 62 6A 49 =A0 =A0.rmi.s= erver.ObjI > 00000080 =A044 A7 5E FA 12 8D DC E5 5C 02 00 02 4A 00 06 6F =A0 =A0D.^...= ..\...J..o > 00000090 =A062 6A 4E 75 6D 4C 00 05 73 70 61 63 65 74 00 15 =A0 =A0bjNumL= ..spacet.. > 000000A0 =A04C 6A 61 76 61 2F 72 6D 69 2F 73 65 72 76 65 72 =A0 =A0Ljava/= rmi/server > 000000B0 =A02F 55 49 44 3B 70 78 70 A6 05 2A C8 81 78 12 13 =A0 =A0/UID;p= xp..*..x.. > 000000C0 =A073 72 00 13 6A 61 76 61 2E 72 6D 69 2E 73 65 72 =A0 =A0sr..ja= va.rmi.ser > 000000D0 =A076 65 72 2E 55 49 44 0F 12 70 0D BF 36 4F 12 02 =A0 =A0ver.UI= D..p..6O.. > 000000E0 =A000 03 53 00 05 63 6F 75 6E 74 4A 00 04 74 69 6D =A0 =A0..S..c= ountJ..tim > 000000F0 =A065 49 00 06 75 6E 69 71 75 65 70 78 70 80 01 00 =A0 =A0eI..un= iquepxp... > 00000100 =A000 01 21 77 ED CA 46 9D E2 22 A5 77 08 80 00 00 =A0 =A0..!w..= F..".w.... > 00000110 =A000 00 00 00 00 73 72 00 12 6A 61 76 61 2E 72 6D =A0 =A0.....s= r..java.rm > 00000120 =A069 2E 64 67 63 2E 4C 65 61 73 65 B0 B5 E2 66 0C =A0 =A0i.dgc.= Lease...f. > 00000130 =A04A DC 34 02 00 02 4A 00 05 76 61 6C 75 65 4C 00 =A0 =A0J.4...= J..valueL. > 00000140 =A004 76 6D 69 64 74 00 13 4C 6A 61 76 61 2F 72 6D =A0 =A0.vmidt= ..Ljava/rm > 00000150 =A069 2F 64 67 63 2F 56 4D 49 44 3B 70 78 70 00 00 =A0 =A0i/dgc/= VMID;pxp.. > 00000160 =A000 00 00 09 27 C0 73 72 00 11 6A 61 76 61 2E 72 =A0 =A0....'.= sr..java.r > 00000170 =A06D 69 2E 64 67 63 2E 56 4D 49 44 F8 86 5B AF A4 =A0 =A0mi.dgc= .VMID..[.. > 00000180 =A0A5 6D B6 02 00 02 5B 00 04 61 64 64 72 74 00 02 =A0 =A0.m....= [..addrt.. > 00000190 =A05B 42 4C 00 03 75 69 64 71 00 7E 00 03 70 78 70 =A0 =A0[BL..u= idq.~..pxp > 000001A0 =A075 72 00 02 5B 42 AC F3 17 F8 06 08 54 E0 02 00 =A0 =A0ur..[B= ......T... > 000001B0 =A000 70 78 70 00 00 00 08 F0 ED 2A 6D 7F B0 76 88 =A0 =A0.pxp..= ....*m .v. > 000001C0 =A073 71 00 7E 00 05 80 01 00 00 01 21 78 5C E2 37 =A0 =A0sq.~..= .....!x\.7 > 000001D0 =A0A0 04 A7 9E =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.... > > > 4# (Send) > 00000000 =A051 AC ED 00 05 77 0F 01 9D E2 22 A5 00 00 01 21 =A0 =A0Q....w= ...."....! > 00000010 =A077 ED CA 46 80 28 73 72 00 12 6A 61 76 61 2E 72 =A0 =A0w..F.(= sr..java.r > 00000020 =A06D 69 2E 64 67 63 2E 4C 65 61 73 65 B0 B5 E2 66 =A0 =A0mi.dgc= .Lease...f > 00000030 =A00C 4A DC 34 02 00 02 4A 00 05 76 61 6C 75 65 4C =A0 =A0.J.4..= .J..valueL > 00000040 =A000 04 76 6D 69 64 74 00 13 4C 6A 61 76 61 2F 72 =A0 =A0..vmid= t..Ljava/r > 00000050 =A06D 69 2F 64 67 63 2F 56 4D 49 44 3B 70 78 70 00 =A0 =A0mi/dgc= /VMID;pxp. > 00000060 =A000 00 00 00 09 27 C0 73 72 00 11 6A 61 76 61 2E =A0 =A0.....'= .sr..java. > 00000070 =A072 6D 69 2E 64 67 63 2E 56 4D 49 44 F8 86 5B AF =A0 =A0rmi.dg= c.VMID..[. > 00000080 =A0A4 A5 6D B6 02 00 02 5B 00 04 61 64 64 72 74 00 =A0 =A0..m...= .[..addrt. > 00000090 =A002 5B 42 4C 00 03 75 69 64 74 00 15 4C 6A 61 76 =A0 =A0.[BL..= uidt..Ljav > 000000A0 =A061 2F 72 6D 69 2F 73 65 72 76 65 72 2F 55 49 44 =A0 =A0a/rmi/= server/UID > 000000B0 =A03B 70 78 70 75 72 00 02 5B 42 AC F3 17 F8 06 08 =A0 =A0;pxpur= ..[B...... > 000000C0 =A054 E0 02 00 00 70 78 70 00 00 00 08 F0 ED 2A 6D =A0 =A0T....p= xp......*m > 000000D0 =A07F B0 76 88 73 72 00 13 6A 61 76 61 2E 72 6D 69 =A0 =A0 .v.sr= ..java.rmi > 000000E0 =A02E 73 65 72 76 65 72 2E 55 49 44 0F 12 70 0D BF =A0 =A0.serve= r.UID..p.. > 000000F0 =A036 4F 12 02 00 03 53 00 05 63 6F 75 6E 74 4A 00 =A0 =A06O....= S..countJ. > 00000100 =A004 74 69 6D 65 49 00 06 75 6E 69 71 75 65 70 78 =A0 =A0.timeI= ..uniquepx > 00000110 =A070 80 01 00 00 01 21 78 5C E2 37 A0 04 A7 9E =A0 =A0 =A0 p...= ..!x\.7.... > > > 5#(Receive) > R > > 6# (Send) > S > > 7# (Receive) > 00000000 =A050 AC ED 00 05 77 22 A6 05 2A C8 81 78 12 13 9D =A0 =A0P....w= "..*..x... > 00000010 =A0E2 22 A5 00 00 01 21 77 ED CA 46 80 01 FF FF FF =A0 =A0."....= !w..F..... > 00000020 =A0FF EF C1 74 D7 7F AC B4 6D =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 ...t. ..m > > > 8# (Send) > 00000000 =A051 AC ED 00 05 77 0F 01 9D E2 22 A5 00 00 01 21 =A0 =A0Q....w= ...."....! > 00000010 =A077 ED CA 46 80 29 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0w..F.) > > On message 1# (received at RMI server) we can see that client is starting= up the handshake for the stream protocol. > > On message 2# the RMI server responds telling RMI client that it supports= the stream protocol but it also sends to the client, the client=92s endpoi= nt. > > On message 3#, the RMI client responds to the RMI server with its fake li= stening endpoint (just to respect the protocol). But in this message client= sends more information that I can=92t understand why nor for what aim eith= er. > > Message 4# seems to be a response from the RMI server to the client=92s s= trange message (strange at least for me). > > Messages 5 and 6: I don=92t understand them. > > Message 7# is a call method request from the RMI client for a specific me= thod > > Message 8# is the response to the call message. 0x51 means ok. > > > > So, if RMI server shows this: > > HelloWorldServer[UnicastServerRef [liveRef: [endpoint:[192.168.1.2:27000]= (local) > ,objID:[-621ddd5b:12177edca46:-7fff, -6483729047876005357]]]] > > > > > Why message 7# sends an object id that is different from the one showed b= y the rmi server? > According to the JDK source code (JDK), an ObjID is sent by the wire in t= his format: > > =A0 =A0 =A0 =A0 out.writeLong(l); //ObjNum (last field of the RMI server = output) > =A0 =A0 =A0 =A0 out.writeInt(); =A0 //First field of the RMI server outpu= t (UID:1) > =A0 =A0 =A0 =A0 out.writeLong(); =A0//Second field of the RMI server outp= ut (UID:2) > =A0 =A0 =A0 =A0 out.writeShort(); //Third field of the RMI server output = (UID:3) > =A0 =A0 =A0 =A0 out.writeInt(); =A0 //Method number > =A0 =A0 =A0 =A0 out.writeLong(l); //method hash > > Please, could you help me understand these messages and ObjectID sent by = the client (which is different from the server output) > > Many thanks > > Alex > > > > > --=20 Niclas Hedhman, Software Developer http://www.qi4j.org - New Energy for Java I live here; http://tinyurl.com/2qq9er I work here; http://tinyurl.com/2ymelc I relax here; http://tinyurl.com/2cgsug =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D To unsubscribe, send email to [email protected] and include in the body of the message "signoff RMI-USERS". For general help, send email to [email protected] and include in the body of the message "help". For a list of frequently asked RMI questions please refer to: http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html To view past RMI-USERS postings, please see: http://archives.java.sun.com/archives/rmi-users.html