Skip to main content

UndeclaredThrowableExceptions caused by NoSuchObjectException

  4 posts   Feedicon  
Replies: 3 - Last Post: June 09, 2011 07:38
by: John Catherino
showing 1 - 4 of 4
Posted: June 09, 2011 02:34 by duindain
Each pc i have is a server and can be multiple clients to each other server

I currently am getting alot of these errors when connecting between machines

When i click connect at similiar times it seems to work a bit more often but sometimes this can go on forever and the machines will never connect

Usually in this scenario 1 machine will connect to a server but that connected machine cannot connect back to the first machine and will stream these errors for a long time if not forever

Some quick research on this issue I found out it can be caused by the java garbage collector collecting the references to service objects

I initilise the server like so
Remote.config(null, 1198, null, 0); // use cajo port 1198
         myLocalEntities = new networkFactoryEntityManagerImpl();

         //assign to a varible to prevent it being garbage collected
         item = ItemServer.bind(myLocalEntities, getSharedRMIObjectName());

I added in the varible item to stop this issue with no effect so far

protected Remote item;

Does anyone know what could be the cause of this error and a way to stop it happening?

Its getting a little insane lately i used to be able to ignore it because within a few minutes the machines would eventually connect regardless now however they can be trying to connect thousands of times and still fail with this issue.

Thanks for any help

Posted: June 09, 2011 06:13 by John Catherino
A NoSuchObjectException most commonly occurs when a client has a reference to a remote object in a JVM that has either been shut down, or restarted. The client will typically be unaware of this, and when it tries to invoke a method on its reference, the exception is thrown.

The second, but less less often case, is when the object being served by a JVM goes out of scope, and gets garbage collected.

Is either, or both, scenarios possible in the code?

Posted: June 09, 2011 07:13 by duindain
There is a couple of different scenarios in recieving this error

Im receiving this error when i activate pc1 and pc2's networking one of them generally will connect instantly the other will continually spam this error no such object for anywhere up to 10 minutes is the most ive tested
at some point usually they will both accept the connection and all is well

When i have 3 pcs usually 2 of them instantly connect to the 3rd but the cross connections never happen
so 1 doesnt see 2, 2 doesnt see 1, 3 doesnt see 1 or 2, but both 1 and 2 see 3
It isnt always this exact combination but it does seem to be the most frequent pattern.

Most importantly it doesnt seem to resolve itself given enough time which the 2 pc test usually does

all pcs have a server running the identical string "EntityFactory" all servers run on whatever ip the machine is on and use port 1198
They all share the same interfaces objects the implementation gets the local entity list when called on the clients

A client is created everytime a multicast packet is detected that isnt already connected. The client attempts to connect to the multicast packets source address at port 1198 and retrieve the interface object which uses a TransparentItemProxy.getItem to share the object

The servers all have 1 remote item a class varible, it is saved for the entire time the server is active so it should never get garbage collected
protected Remote item;
item = ItemServer.bind(myLocalEntities, "EntityFactory");

The server has one class which handles detected multicasts this class stores all clients in a hashmap of ip address and then the client class

So that should never be going out of scope or getting gc'ed either

Im at a loss for how to fix this everything seemed to be working for the most part barring the occasional long wait for both machines to sucsessfully connect till i started testing with a 3rd pc heh

Hope you can see an issue with my implementation or something to test
Thanks John
Posted: June 09, 2011 07:38 by John Catherino
The approach I find really helps, is to build a skeleton of your application architecture. It simply contains mock objects that are stubs, or return reasonable, but trivially derived values. This helps you find and debug infrastructure issues, without the added complexity of the application code. This really helps to simplify things.

Next, subclass these skeleton objects, progressively adding in functionality. This allows you to debug the application without regard to infrastructure.

I have been in your position many times Wink and I have found this to be the best approach by far. Even, as in your case, where you have developed the combined application; it is remarkably easy to break them apart.

A final and extremely important benefit: When deploying into a complex distributed environment... if the application does not work, try the skeleton. If the skeleton does not work, then it is a environment configuration issue, not an issue with your application.

Just a few helpful tips, learnt from a lot of hard experience.

Replies: 3 - Last Post: June 09, 2011 07:38
by: John Catherino
Please Confirm