I'm using integration method 1 for a Windows 2000
Service implementation. When the server is busy, I get
the following symptoms:
- The service shuts down on its own as if someone
explicitly shut it down.
- The following messages in the wrapper.log:
DEBUG | wrapperp | 2004/07/07 11:36:39 | send a
packet PING : ping
INFO | jvm 1 | 2004/07/07 11:36:39 | Received a
packet PING : ping
INFO | jvm 1 | 2004/07/07 11:36:39 | Send a
packet PING : ok
INFO | jvm 1 | 2004/07/07 11:36:39 | All non-
daemon threads have stopped. Exiting.
INFO | jvm 1 | 2004/07/07 11:36:39 |
WrapperManager.stop(0) called by thread: Wrapper-
Connection
INFO | jvm 1 | 2004/07/07 11:36:39 | Send a
packet STOP : 0
DEBUG | wrapperp | 2004/07/07 11:36:39 | read a
packet PING : ok
DEBUG | wrapper | 2004/07/07 11:36:39 | Got ping
response from JVM
DEBUG | wrapperp | 2004/07/07 11:36:39 | read a
packet STOP : 0
DEBUG | wrapper | 2004/07/07 11:36:39 | JVM
requested a shutdown. (0)
DEBUG | wrapper | 2004/07/07 11:36:39 |
wrapperStopProcess(0) called.
DEBUG | wrapper | 2004/07/07 11:36:39 | Sending
stop signal to JVM
DEBUG | wrapperp | 2004/07/07 11:36:39 | send a
packet STOP : NULL
INFO | jvm 1 | 2004/07/07 11:36:40 | Thread,
Wrapper-Connection, handling the shutdown process.
INFO | jvm 1 | 2004/07/07 11:36:40 | calling
listener.stop()
INFO | jvm 1 | 2004/07/07 11:36:40 |
WrapperSimpleApp: stop(0)
INFO | jvm 1 | 2004/07/07 11:36:40 | returned from
listener.stop()
INFO | jvm 1 | 2004/07/07 11:36:40 | Send a
packet STOPPED : 0
DEBUG | wrapperp | 2004/07/07 11:36:40 | read a
packet STOPPED : 0
DEBUG | wrapper | 2004/07/07 11:36:40 | JVM
signalled that it was stopped.
INFO | jvm 1 | 2004/07/07 11:36:40 | Closing
socket.
DEBUG | wrapperp | 2004/07/07 11:36:40 | socket
read no code (closed?).
INFO | jvm 1 | 2004/07/07 11:36:41 | calling
System.exit(0)
INFO | jvm 1 | 2004/07/07 11:36:41 | [Thread-0]
INFO com.citibank.csapropagator - Shutting down
CSAPropagator...
DEBUG | wrapper | 2004/07/07 11:36:42 | JVM
process exited with a code of 0, leaving the wrapper
exit code set to 0.
DEBUG | wrapper | 2004/07/07 11:36:42 | JVM exited
normally.
STATUS | wrapper | 2004/07/07 11:36:42 | <--
Wrapper Stopped
The java-side code is basically a loop that gets exited
when the shutdown hook is called. What could be
shutting down the JVM?
Logged In: YES
user_id=228081
This is the key line in the debug output:
INFO | jvm 1 | 2004/07/07 11:36:39 | All non-daemon threads
have stopped. Exiting.
The Wrapper is designed to shutdown the JVM when there are
no longer any non-daemon threads running. This is how Java
works when running on its own as well.
If you have a program that stays up and running without the
Wrapper, but exits when running under the Wrapper then I
would like to look into it more, but I am not aware of any
such problems.
Try making sure that there is always at least one non-daemon
thread running.
Please repy to this issue so I know when it can be closed off.
Cheers,
Leif
Logged In: YES
user_id=283056
It seems to run fine in JBuilder, but under the wrapper it
sporadically shuts down under a heavy load.
The entry point of the java side calls a main while loop that
only exits when a boolean condition is met -- this should
qualify as a non-daemon thread correct?
Logged In: YES
user_id=283056
Note also that it seems to quit after a thread (that is
executed in the main loop) has finished.
Logged In: YES
user_id=228081
Richard,
A daemon thread is a thread which has had its daemon flag
set to true using the thread.setDaemon(true) method. The
Daemon flag tells the JVM not to monitor the thread when
deciding when to shutdown. Java will normally wait until
all non-daemon threads have stopped before shutting down on
its own. If you call System.exit then the JVM will of
course start the shutdown process earlier.
The message in the log is definitely being caused by the
fact that no non-daemon threads are running. JBuilder may
handle this automatic shutdown process a little differently.
If you are not confident in the Wrapper yet, then a better
test would be to see how your application functions as a
standalone Java program.
Usually I make the main loop of a program be a non-daemon
thread. Its while loop monitors a shutdown flag that is
set from with in a shutdown hook or other shutdown
mechanism. As this thread is not meant to be left running
as the JVM shuts down. Its daemon flag is set to false.
Cheers,
Leif
Logged In: YES
user_id=283056
I think I found the problem. I had an unhandled exception
that was breaking the code out of the loop. I didn't catch it
in the log. Its been running now for over 18 hours with some
pretty heavy loads.
I found that the main loop is a daemon thread.
Thanks for the help!
Logged In: YES
user_id=228081
Great, glad you got things working. Remember
try {
something
} catch (Exception e) {
// silently do nothing.
}
will end up biting you every time.
Cheers,
Leif