Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

RMI Project Debugging: ArrayIndexOutOfBoundsException from Remote Ref

843793Feb 28 2003 — edited Mar 2 2003
Hello. My name is Ray Botardo from the Philippines. I am a postgraduate student at the Ateneo de Manila University Information Technology Institute. I am new to the forum and am desperately seeking help in debugging my RMI project for a remote CmdServer that will do simple arithmetic calculations. The remote interface is CmdServer and its implementation is CmdServerImpl. CmdServerImpl accepts calls from Client and passes it to Dispatcher.java from processing. Dispatcher extends Thread class. Arguments passed on to CmdServer are primitive types, IClient object (interface for Client) and ISession objects (interface for Session). Upon launching main() of Client, a blank GUI (w/c is the constructor) is shown on the screen with 5 buttons: connect, new session, execute, get result and sign off . After I fill up the text fields, I make another instantiation to getText and set up the attributes of the Client object which is passed to the Remote Server. I create an ISession object inside the ActionPerformed method for btn_new (new session). Midway in my ActionPerformed method for btn_execute (after I have successfully posted a session in a RequestBuffer in a Vector created inside Dispatcher), I got an ArrayIndexOutOfBoundsException. The details of the debug trace are listed below. I'd appreciate a reply to this because it is a term requirement.

Both Client.java and CmdServer.java are launched from the same machine but separate JVMs. The machine name is home-5utooks60s. I was able to connect the client to the cmdserver when I clicked on the connect button and was able to successfully post a session inside the CmdServer.

I would appreciate if an interested party could suggest how I can send my source code package so that it will be easier to understand. Nevertheless, I have attached in this text message a debugging trace which follows the questions I am posting here:

1. Where is the IndexArrayOutOfBoundsException happening? I can?t figure out why it points to line 398 at Client.java? (Note: Line 398 is a line within ActionPerformed for btn_execute. It calls the remote object CmdServer mySrvrObj that was looked up in line 225 when btn_connect was clicked.)

2. When I made a check on the side, I noticed that the ISession session object that was created and casted as ISession in line 333 (in ActionPerformed of btn_new) and subsequently passed on as argument in a remote method call in line 371 via mySrvrObj.postSession (session) (in ActionPerformed of btn_execute) , is different from the object reference of Session session in line 398 that was being passed to the remote obj via a remote method call to the same remote obj via mySrvrObj(session). Before the code now, I got an ArrayIndexOutOfBoundsException (just like now). So, I changed the code to what it is now, but I still got the same error. Where is the error ocurring? How can I fix it?

3. I noticed that the CmdServerImpl remote obj stub objID changed from the instantation at main() of CmdServerImpl when I checked it a Client.java after Naming.lookup().But they still communicate on the same port (1748). And it remained the same thru out Client. Please explain.
From: (CmdServer.java)
[RemoteStub [ref: [endpoint:[home-5utooks60s:1748](local),objID:[0]]]
To: (Client.java)
[RemoteStub [ref: [endpoint:[home-5utooks60s:1748](remote),objID:[6930e2:f3a24f27ef:-8000, 0]

4. Why is the Dispatcher object reference changing ? Please explain. Is this related to the error? How can I fix it?
From CmdServerImpl: cmdserverimpl.Dispatcher@a992f
To Client (@btn_connect: cmdserverimpl.Dispatcher@8f8e0
To Client (@btn_new): ???
To Client(@btn_execute): cmdserverimpl.Dispatcher@5d855f

HERE IS THE DEBUGGING TRACE:
CmdServer Side:
D:\OSProj>java -Djava.rmi.server.codebase=file:/d:\OSProj\classes/ -Djava.rmi.server.hostna
me=home-5utooks60s -Djava.security.policy=java.policy cmdserverimpl.CmdServerImpl home-5utooks60s

System.out.println Output at CmdServer side after launch:

IDispatcher cmdSrvrDisp (inside CmdServerImpl constructor)= cmdserverimpl.Dispatcher@a992f
CmdServerImpl(main) running.
CmdServerImpl Object (main), CmdServer cmdsrvr: cmdserverimpl.CmdServerImpl[RemoteStub [ref: [endpoint:[home-5utooks60s:1748](local),objID:[0]]]]
cmdSrvrDisp (inside main)= cmdserverimpl.Dispatcher@a992f
CmdServerImpl bound.


Client side:
D:\OSProj>java -Djava.rmi.server.codebase=file:/d:\OSProj\classes/ -Djava.security.policy=j
ava.policy client.Client

System.out.println Output at Client side after launch:
Client: client.Client[,150,60,500x500,invalid,layout=java.awt.BorderLayout,resizable,title=
ClientWindow,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,4,23,492x473,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=3586,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]


Output of JtextArea ta_result per ActionPerformed at Client Side:

a) btn_connect: (Connect)

Client: client.Client[RAY BOTARDO,150,60,500x500,invalid,hidden,layout=java.awt.BorderLayout,resizable,title=ClientWindow,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=1538,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
Client name: RAY BOTARDO
Client password: migs
Client ip: home-5utooks60s
Session: null
Client: RAY BOTARDO is REGISTERED.
CmdServerImpl Client: client.Client[RAY BOTARDO,150,60,500x500,invalid,hidden,layout=java.awt.BorderLayout,resizable,title=Client Window,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=1538,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
CmdServerImpl Object, mySrvrObj: cmdserverimpl.CmdServerImpl_Stub[RemoteStub [ref: [endpoint:[home-5utooks60s:1748](remote),objID:[6930e2:f3a24f27ef:-8000, 0]]]]
Dispatcher Object(@cmdServerImpl global variable): cmdserverimpl.Dispatcher@8f8e0
Request Buffer Object: []


b) btn_new: (New Session)
New Session created.
Session: client.Session@7e315d
Client(parameter): client.Client[RAY BOTARDO,150,60,500x500,invalid,hidden,layout=java.awt.BorderLayout,resizable,title=ClientWindow,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=1538,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
Client(session.getClient()): client.Client[RAY BOTARDO,150,60,500x500,invalid,hidden,layout=java.awt.BorderLayout,resizable,title=Clientwindow,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=1538,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
Please choose operation.
Enter values for operand A and B.

c) btn_execute: (Execute)
mySrvrObj(@client.Client): cmdserverimpl.CmdServerImpl_Stub[RemoteStub [ref: [endpoint:[home-5utooks60s:1748](remote),objID:[6930e2:f3a24f27ef:-8000, 0]]]]
Session(parameter @client.Client): client.Session@7e315d
Dispatcher Object(@CmdServerImpl(cmdServerImpl global variable)): cmdserverimpl.Dispatcher@5d855f
Dispatcher Message:
SESSION(parameter): client.Session@1e8c34
of CLIENT(session.getClient()): client.Client[RAY BOTARDO,150,60,500x500,invalid,hidden,layout=java.awt.BorderLayout,resizable,title=ClientWindow,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=1538,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
has been POSTED in Request Buffer and ready for Command execution.
sessionHash VALUE= client.Session@1e8c34
clientHash VALUE= client.Client[RAY BOTARDO,150,60,500x500,invalid,hidden,layout=java.awt.BorderLayout,resizable,title=ClientWindow,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=1538,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
reqPosn(index of session in Request Buffer)= 0
Session in requestBuffer[0]= client.Session@1e8c34
Client RAY BOTARDOhas session in sessionHashMap.
Remaining Request Buffer Slots(after Posting)= 9
Remaining Output Buffer Slots(after Posting)= 10

CmdServer Console Output (after btn_exec):
CmdServerImpl: postSession(ISession session)= client.Session@1e8c34

Client Console output (after btn_execute):
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at cmdserverimpl.CmdServerImpl_Stub.execSession(Unknown Source)
at client.Client.actionPerformed(Client.java:398)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 30 2003
Added on Feb 28 2003
4 comments
219 views