I am using a manager/service pair to submit fatal errors in our server by using the logging-system. This is quite a hack but it works very well. Except in the case where a SEVERE-level log message occurs in the system context (here is an example):
SEVERE: acceptor error on port: 6,655
java.io.IOException: accept failed
at com.sun.sgs.impl.nio.AsyncServerSocketChannelImpl$1.call(AsyncServerSocketChannelImpl.java:245)
at com.sun.sgs.impl.nio.AsyncServerSocketChannelImpl$1.call(AsyncServerSocketChannelImpl.java:240)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at com.sun.sgs.impl.nio.Reactor$PendingOperation.selected(Reactor.java:534)
at com.sun.sgs.impl.nio.Reactor$ReactiveAsyncKey.selected(Reactor.java:764)
at com.sun.sgs.impl.nio.Reactor.performWork(Reactor.java:308)
at com.sun.sgs.impl.nio.ReactiveChannelGroup$Worker.run(ReactiveChannelGroup.java:267)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Then the logging-system will try to get hold of a manager from the system context, this is not allowed (that makes sense). But trying to get hold of a manager from the system context results in yet an other SEVERE logging message.... and guess what happens then

Now, I am aware that what I am doing with the logging-system might not be very wise - but it works very well for our test-setup. So here is the real question: Is it possible to test if some code is running in a context suitable for accessing managers, or is the only way trying and catching?