Link to home
Start Free TrialLog in
Avatar of tzvika179
tzvika179

asked on

Problem: A program invoking remote objects through RMI refuses to exit

I've got a program calling remote beans on a server (running on JBOSS 246) , and the program works fine. the only problem is that my process (the client) never exits. i've tried, as you can see below, to close the context and the objects on my end - but that doesn't help. also tried to unexport the registry, and that didn't work.

Any ideas?



Here's the code (even though it references other code parts on our end,which are compiled code to me)

String provider = "anfield:1099";
            TopazConfiguration conf = TopazConfiguration.getInstance();
            String url            = conf.get ("global.configuration.topaz.jndi.provider.url",            "localhost:1099");
            String urlPkgs      = conf.get ("global.configuration.topaz.jndi.factory.url.pkgs",      "org.jboss.naming");
            String facInit      = conf.get ("global.configuration.topaz.jndi.factory.initial",      "org.jnp.interfaces.NamingContextFactory");
            Hashtable hash = new Hashtable();
            hash.put ("java.naming.provider.url",            (provider != null) ? provider : url);
            hash.put ("java.naming.factory.initial",      facInit);
            hash.put ("java.naming.factory.url.pkgs",      urlPkgs);

            InitialContext context = new InitialContext (hash);
            AlertHome objHome = (AlertHome) context.lookup ("com.mercury.topaz.tmc.bizprocess.Alert");
            AlertTBP moshe = objHome.create();

            //AlertTBP moshe = AlertFactory.create();
            try {
                moshe.insertRecipientObject(rcp);
            } catch (Exception e) {
                e.printStackTrace();  //To change body of catch statement use Options | File Templates.
            }

            moshe = null;
            objHome = null;
            context.close();
            //context.unbind("com.mercury.topaz.tmc.bizprocess.Alert");



        } catch (NamingException e) {
            e.printStackTrace();  //To change body of catch statement use Options | File Templates.
        } catch (CreateException e) {
            e.printStackTrace();  //To change body of catch statement use Options | File Templates.
        } catch (RemoteException e) {
            e.printStackTrace();  //To change body of catch statement use Options | File Templates.
        }


         System.out.println("i got here");
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Where does it get to?

does it do the:

System.out.println("i got here");

line?

Have you tried putting more debug in...to see where it freezes?

Are you sure it's not getting caught in some other bit of code other than here?
I think you might need to post some more code...
Avatar of jimmack
jimmack

Does the following line return?

>> moshe.insertRecipientObject(rcp);

(ie. if you add an "i got here" after this line, is it displayed?)
;-)  Hi Tim.
:-)  Morning :-)
Avatar of tzvika179

ASKER

yea, as i said, the code i didnt post is compiled code to me, i just have the jars, so i can't see the content

and yes it does get to the i get here :-)   in fact the program doesnt freeze at all ! it just doesn't exit when main() is done - which to me is weird .

can anyone say anything about maybe unbind? i'm not sure what name needs to be given to it.
 Why don't you just do a System.exit() if it is the client?
System.exit will work, but i dont want to
That can't be all your code?

That won't compile...

Can you post all your code?

Tim
> System.exit will work, but i dont want to

  Why not?

  You probably have some dangling objects doing some background processing that's why it doesn't exit.
Maybe one of the threads is blocked. Do a thread dump to try and detect this (Ctrl-Break)
Or post your code
Ooooh...  CEHJ is here early :-)
How do i do the thread dump thingi , i am using intellij or just tell me in command
Don't know that IDE. You may be able to inspect the threads through its gui.
>>Ooooh...  CEHJ is here early :-)

I'm late aren't I? ;-)
do you start any threads?  Create any object that block? etc...

without seeing the code, I'm only guessing what it could be...
 I still can't understand why System.exit() is not a good solution since we are talking about the client.
>>I still can't understand why System.exit() is not a good solution since we are talking about the client.

Papering over cracks?
 Make it work first and optimize later :)
> Papering over cracks?

Not really...more like slamming the door on your way out ;-)
i dont start any threads.

here's the thread dump:

Full thread dump Java HotSpot(TM) Client VM (1.4.1_03-b02 mixed mode):

"DestroyJavaVM" prio=5 tid=0x00236008 nid=0x1f10 waiting on condition [0..6fadc]


"Thread-17" prio=5 tid=0x0AEFEFB8 nid=0x1f34 waiting on condition [bb9f000..bb9f
d8c]
        at java.lang.Thread.sleep(Native Method)
        at com.mercury.topaz.util.ObjectPool$ShrinkerThread._sleepUntilNextTime(
ObjectPool.java:202)
        at com.mercury.topaz.util.ObjectPool$ShrinkerThread.run(ObjectPool.java:
115)

"Thread-15" prio=5 tid=0x0AF19BE8 nid=0x1f30 waiting on condition [bb5f000..bb5f
d8c]
        at java.lang.Thread.sleep(Native Method)
        at com.mercury.topaz.util.ObjectPool$ShrinkerThread._sleepUntilNextTime(
ObjectPool.java:202)
        at com.mercury.topaz.util.ObjectPool$ShrinkerThread.run(ObjectPool.java:
115)

"Thread-13" prio=5 tid=0x0AEFB9D8 nid=0x1f2c in Object.wait() [bb1f000..bb1fd8c]

        at java.lang.Object.wait(Native Method)
        - waiting on <02FC94D8> (a com.mercury.util.threads.ThreadPool$MonitorRu
nnable)
        at com.mercury.util.threads.ThreadPool$MonitorRunnable.run(ThreadPool.ja
va:384)
        - locked <02FC94D8> (a com.mercury.util.threads.ThreadPool$MonitorRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-12" prio=5 tid=0x0AF072E8 nid=0x1f28 in Object.wait() [badf000..badfd8c]

        at java.lang.Object.wait(Native Method)
        - waiting on <02FC9538> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC9538> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-11" prio=5 tid=0x0AF06858 nid=0x1f24 in Object.wait() [ba9f000..ba9fd8c]

        at java.lang.Object.wait(Native Method)
        - waiting on <02FC95A0> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC95A0> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-10" prio=5 tid=0x0AF05DE0 nid=0x1f20 in Object.wait() [ba5f000..ba5fd8c]

        at java.lang.Object.wait(Native Method)
        - waiting on <02FC9608> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC9608> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-9" prio=5 tid=0x0AF053F0 nid=0x1f18 in Object.wait() [ba1f000..ba1fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02FC9670> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC9670> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-8" prio=5 tid=0x0AF04A88 nid=0x1ed0 in Object.wait() [b9df000..b9dfd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02FC96D8> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC96D8> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-7" prio=5 tid=0x0AF04120 nid=0x1f0c in Object.wait() [b99f000..b99fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02FC9740> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC9740> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-6" prio=5 tid=0x0AF0B9D0 nid=0x1970 in Object.wait() [b95f000..b95fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02FC97A8> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC97A8> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-5" prio=5 tid=0x0AEF8DE8 nid=0x1f08 in Object.wait() [b91f000..b91fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02FC9810> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC9810> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-4" prio=5 tid=0x0AF02F90 nid=0x170 in Object.wait() [b8df000..b8dfd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02FC9878> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC9878> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"Thread-3" prio=5 tid=0x0AF07B30 nid=0xa44 in Object.wait() [b89f000..b89fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02FC98E0> (a com.mercury.util.threads.ThreadPool$ControlRu
nnable)
        at java.lang.Object.wait(Unknown Source)
        at com.mercury.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.ja
va:430)
        - locked <02FC98E0> (a com.mercury.util.threads.ThreadPool$ControlRunnab
le)
        at java.lang.Thread.run(Unknown Source)

"RMI RenewClean-[192.168.88.101:4444]" daemon prio=5 tid=0x0AEF22C8 nid=0x19d0 i
n Object.wait() [b81f000..b81fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02FAB2A0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        - locked <02FAB2A0> (a java.lang.ref.ReferenceQueue$Lock)
        at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(Unknow
n Source)
        at java.lang.Thread.run(Unknown Source)

"GC Daemon" daemon prio=2 tid=0x0AD1B520 nid=0x1f1c in Object.wait() [b79f000..b
79fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02F91100> (a sun.misc.GC$LatencyLock)
        at sun.misc.GC$Daemon.run(Unknown Source)
        - locked <02F91100> (a sun.misc.GC$LatencyLock)

"RMI RenewClean-[192.168.88.101:4767]" daemon prio=5 tid=0x0AD1B260 nid=0x1290 i
n Object.wait() [b75f000..b75fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02F90DD8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        - locked <02F90DD8> (a java.lang.ref.ReferenceQueue$Lock)
        at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(Unknow
n Source)
        at java.lang.Thread.run(Unknown Source)

"Thread-1" daemon prio=5 tid=0x0AD5A960 nid=0x1d9c waiting on condition [b29f000
..b29fd8c]
        at java.lang.Thread.sleep(Native Method)
        at org.apache.log4j.helpers.FileWatchdog.run(FileWatchdog.java:95)

"Signal Dispatcher" daemon prio=10 tid=0x008C7C78 nid=0x1b04 waiting on conditio
n [0..0]

"Finalizer" daemon prio=9 tid=0x0090B9B8 nid=0x1cf0 in Object.wait() [ab5f000..a
b5fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02F02FE0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        - locked <02F02FE0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

"Reference Handler" daemon prio=10 tid=0x0090AD48 nid=0x14a8 in Object.wait() [a
b1f000..ab1fd8c]
        at java.lang.Object.wait(Native Method)
        - waiting on <02F03048> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Unknown Source)
        at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
        - locked <02F03048> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=5 tid=0x00909B10 nid=0xb3c runnable

"VM Periodic Task Thread" prio=10 tid=0x008C66D0 nid=0x1efc waiting on condition

"Suspend Checker Thread" prio=10 tid=0x008C7290 nid=0x5ec runnable
Can you post your code?  Or the smallest subset of your code that compiles, and locks up?
You're not running the server in the same JVM are you by any chance?
>  it just doesn't exit when main() is done - which to me is weird .

Just cause main() has finished doesn't mean your app will exit.
There are other threads running and unless you have means to stop these threads (which u may not) then System.exit() is your only alternative.
You're up late objects :-)
yes, a bit busy down here at the moment.
Are you using something like Mercury as well?
> Are you using something like Mercury as well?

Thats pretty obvious isn't it ;)
And yes it is one of the threads I mentioned above.
>>Thats pretty obvious isn't it ;)

Not necessarily. If it's so obvious, can you explain the correlation between this matter and your previous link posting talking about a supposed bug in RMI?

If you're using a diagnostic tool and it's operating through non-code hooks, then you probably will have to System.exit. Otherwise close the diagnostics down explicitly.
I counted about 13 threads that are running that you'll need to terminate before your app will exit, or use System.exit(). All from a thread pool by the looks of it.

I'm not sure i got your conclusion - should i be looking into some threads that i have opened without being aware of it, or should i be looking at unbind and unexport?
tzvika179> should i be looking into some threads that i have opened without being aware of it

I'd start with those threads first.
Can you post exactly how you start your program, including all command line parameters?
And maybe the source code?
and another thing: in my case it's not latency of several minutes - i waited hours
Check mercury's doco, it may tell you how to shut things down.
> in my case it's not latency of several minutes - i waited hours

It may never shut down. Until all those threads have ended it will not exit, and if there is no timeout on the wait()'s it will be foirever.
Especially check the documentation on its thread pool.
i am mercury :-)  
i am now going to decompile the jars (the guy who wrote them is on vacation, of course...) to try to see what is going on on the server side. maybe get some more additional info


command line is:
java.exe -classpath C:\javaprojects\AlertsTester\classes;.\lib\topazdbutilities.jar;.\lib\topazmetadatautilities.jar;.\lib\topazqautils.jar;.\lib\topazutil.jar;.\lib\activation.jar;.\lib\aesrequests.jar;.\lib\commons-collections.jar;.\lib\commons-pool.jar;.\lib\concurrent-utils.jar;.\lib\connection-pool.jar;.\lib\crimson.jar;.\lib\dataselector.jar;.\lib\datatypesifs.jar;.\lib\idgen.jar;.\lib\javacore.jar;.\lib\jboss.jar;.\lib\jce1_2_1.jar;.\lib\jmdrv.jar;.\lib\jrequestor.jar;.\lib\legacyutils.jar;.\lib\local_policy.jar;.\lib\mail.jar;.\lib\object-pool.jar;.\lib\security.jar;.\lib\seropto.jar;.\lib\soap.jar;.\lib\sprinta2000.jar;.\lib\sunjce_provider.jar;.\lib\topazjmdrv.jar;.\lib\us_export_policy.jar;.\lib\xalan.jar;.\lib\xdr.jar;.\lib\xdr_utils.jar;.\lib\xerces.jar;.\lib\xmlwrapper.jar;.\lib\alert_updates.jar;.\lib\connection-pool-mng-jmx.jar;.\lib\ejb.jar;.\lib\ejb2.0.jar;.\lib\genericdataviewcreator.jar;.\lib\jboss-client.jar;.\lib\jboss-jaas.jar;.\lib\jbosssx-client.jar;.\lib\jms.jar;.\lib\jnp-client.jar;.\lib\jta-spec1_0_1.jar;.\lib\junit.jar;.\lib\log4j.jar;.\lib\logger.jar;.\lib\mtime-client.jar;.\lib\mtime.jar;.\lib\MTJUnit-1.jar;.\lib\open_api.jar;.\lib\sboxdata.jar;.\lib\servlet.jar;.\lib\tmc_ex_data.jar;.\lib\transheaders.jar;.\lib\tmc-client.jar;.\lib\tmc-shared.jar;.\lib\tmcalert-client.jar;.\lib\tmcalert-jboss-server.jar;.\lib\tmcalert-shared.jar com.mercury.infra.qa.alertstester.AlertsTester
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yup once jad decompiles com.mercury.topaz.util.ObjectPool and com.mercury.util.threads.ThreadPool hopefully we'll know more
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
(but of course that may appear at a higher level)
found the culprit. thx to everyone