Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java applications prevent server restart after JRE update

Tags:

java

windows

I have a problem after JRE update.

If I have a launched Java application and initiate system restart - Windows fails to automatically stop this Java application and I get following message: "This program is preventing Windows from restarting". If I press cancel, then I could see that Java application that prevents restart hangs. This issue affects both my Java applications and such applications as jconsole.

Before JRE update everything works fine on JRE 1.6.0_26. I first faced this problem on JRE 1.6.0_36. But it also happens on 1.6.0_39.

P.S: I have Windows Server 2008 R2 Interprise

Have anyone had same problem or can suggest what to do in this situation? Thanks.

Update: I have implemented following addhook:

Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
logger.log("SHUTDOWN - BEGIN");
((Window) view).setVisible(false);
logger.log("SHUTDOWN - Visible");
((Window) view).dispose();
logger.log("SHUTDOWN - Dispose");
System.exit(0);
}
});

After that applications with such addhook closes normally on system restart, but I figured out that if we just close application (by pressing exit or "x") Java VM not terminated (we can see javaw process in taskmgr).

From log file I could see that program never leaves dispose() function. In case if I comment dispose() and leave only System.exit(0) Java VM still not able to terminate.

Update 2: Ticket has been created for this issue. And we received following reply from Oracle: "Problem reproduced and confirmed."

like image 552
Dmitry Stukalov Avatar asked Feb 05 '13 11:02

Dmitry Stukalov


2 Answers

matts, This happens for all Java applications, it has been tested with a Server with just 2008 OS and JRE 6U37 on. If we start the Java Control Panel and then try and restart the Server we get the Windows message.

If the App is minimised, we don't get the message.

Message "This program is preventing Windows from restarting"

We get the option to "Force restart" or "Cancel" if you take the Cancel option, the Java Control Panel hangs and the javaw.exe process is running at 25% cpu, this is on a quad processor server, so I assume on a single processor this would be running at 100% cpu.

Oliver

like image 198
Oliver Thompson Avatar answered Nov 18 '22 09:11

Oliver Thompson


I can think of few things:

1) Do you have a shutdownhook() implemented, possibly trying to do something when it gets a QUIT signal from OS?

2) Do a thread dump (ctrl + break for windows- pls google?) when your application hangs and check what is happening inside. You should get some clue.

3) Non-daemon threads, if any, still active in the java application may prevent JVM to exit too.

like image 33
Bimalesh Jha Avatar answered Nov 18 '22 08:11

Bimalesh Jha