|
From: Marc W. <ma...@da...> - 2002-09-30 02:26:31
|
I have had a similar problem using 2.2.7.
My application starts up and registers a remote object with an RMI
registry running in the same JVM. When it is run from the console it
remains after starting up and recieves requests, but when started by the
wrapper, it closes down imediately notifying me that "All non-daemon
threads have stopped".
I used Eclipse to debug the state of the threads after it starts up and
there is one non-daemon thread running. This is running in the System
Thread group, one group above the Thread Group the wrapper is running
in, so when the wrapper checks there are no non-daemon threads, it
returns true and exits, as it is only looking in it's own thread group.
I haven't had much of a look at a fix yet, but changes to the
getNonDaemonThreadCount() method in the WrapperManager class below may
be sufficient.
Cheers
-Marc
private static int getNonDaemonThreadCount()
{
// BEGIN CHANGE
ThreadGroup topGroup = Thread.currentThread().getThreadGroup();
while(topGroup.getParent() != null)
{
topGroup = topGroup.getParent();
}
Thread[] threads = new Thread[topGroup.activeCount() * 2];
topGroup.enumerate(threads, true);
// END CHANGE
// Only count any non daemon threads which are
// still alive other than this thread.
int liveCount = 0;
for (int i = 0; i < threads.length; i++) {
/*
if (threads[i] != null) {
System.out.println("Check " + threads[i].getName() + "
daemon=" +
threads[i].isDaemon() + " alive=" + threads[i].isAlive());
}
*/
if ((threads[i] != null) && (threads[i].isAlive() &&
(!threads[i].isDaemon()))) {
// Do not count this thread or the wrapper connection
thread
if ((Thread.currentThread() != threads[i]) &&
(threads[i] != _commRunner)) {
// Non-Daemon living thread
liveCount++;
//System.out.println(" -> Non-Daemon");
}
}
}
//System.out.println(" => liveCount = " + liveCount);
return liveCount;
}
-----Original Message-----
From: wra...@li...
[mailto:wra...@li...] On Behalf Of Leif
Mortenson
Sent: Friday, 27 September 2002 23:16
To: Wrapper User List
Subject: [Wrapper-user] Re: my wrapper stoped and i don't know why
Ralf,
The wrapper is designed to exit cleanly when all non-daemon threads have
quit. Most likely, your application is launching one or more threads
with their daemon flag set and then all other threads are exiting.
Daemon threads are designed to be running in the background until the
JVM is ready to shut down. They are designed so that your application
does not need to worry about shutting them all down before the JVM will
exit. The Swing event handler thread is an example of a daemon thread.
Running java without the wrapper should behave in the same way. That is
what the following line is telling you.
jvm 1 | All non-daemon threads have stopped. Exiting.
Is this an application you wrote yourself? How does it behave when not
using the Wrapper?
Leif
Ralf weber wrote:
>i use the WrapperSimpleApp for my application but after the
>main method completed the wrapper stopped, can you maybe tell
>me what bullshit i done. i have no idea, here is a screenshot.
>
>ciao, ralf
>
>jvm 1 | WrapperSimpleApp: main method completed
>wrapperp | sent 6 bytes
>jvm 1 | Received a packet 103 : ping
>jvm 1 | Send a packet 103 : ok
>jvm 1 | All non-daemon threads have stopped. Exiting.
>jvm 1 | Send a packet 101 : 0
>wrapperp | read a packet 103 : ok
>wrapper | Got ping response from JVM
>wrapperp | read a packet 101 : 0
>wrapper | JVM requested a shutdown. (0)
>wrapper | wrapperStopProcess(0) called.
>wrapper | Sending stop signal to JVM
>wrapperp | sent 2 bytes
>jvm 1 | Thread, Wrapper-Connection, handling the shutdown
>process.
>jvm 1 | calling listener.stop()
>jvm 1 | WrapperSimpleApp: stop(0)
>jvm 1 | returned from listener.stop()
>jvm 1 | Send a packet 107 : 0
>jvm 1 | Closing socket.
>wrapperp | read a packet 107 : 0
>wrapper | JVM signalled that it was stopped.
>wrapperp | socket read no code (closed?).
>jvm 1 | calling System.exit(0)
>wrapper | JVM exited normally.
>wrapper | <-- Wrapper Stopped
>
>
>
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf _______________________________________________
Wrapper-user mailing list
Wra...@li...
https://lists.sourceforge.net/lists/listinfo/wrapper-user
|