commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Majid Azimi <>
Subject prunsrv crashes when exiting
Date Tue, 16 Oct 2012 06:02:02 GMT
Hi guys,

I have written a simple windows service. It only creates a thread and that thread logs a random
UUID to a file every 1 second.

public class WindowsService {
    private static MyRunnable r;
    private static Thread t;
    public static void main(String[] args) {
        r = new MyRunnable();
        t = new Thread(r);
    public static void start(String[] args) {
    public static void stop(String[] args) {
        try {
        } catch (InterruptedException ex) { /* do nothing */ }

public class MyRunnable implements Runnable {
    private boolean isStopped;
    private FileHandler handler;
    public MyRunnable() {        
        try {
            handler = new FileHandler("C:\\access.log", 100000, 5, true);
        } catch (IOException | SecurityException ex) { /* do nothing */}
        isStopped = false;
    public void run() {
        handler.publish(new LogRecord(Level.INFO, "starting service"));
        while (!isStopped) {
            handler.publish(new LogRecord(Level.INFO, UUID.randomUUID().toString()));
            try {
            } catch (InterruptedException ex) {
                isStopped = true;
        handler.publish(new LogRecord(Level.INFO, "exiting service"));
    public synchronized void setStopped(boolean isStopped) {
        this.isStopped = isStopped;

I add this service with this command:

prunsrv.exe //IS//MyService --DisplayName "Log Service" --Jvm auto --StartM
ode jvm --StopMode jvm --Classpath "My jar file path" --StartClass win
dowsservice.WindowsService --StopClass windowsservice.WindowsService --StartMeth
od start --StopMethod stop

I can start and stop the service and I can see "starting service" and "exiting service" at
the log file. But when I stop the service I got this error:

Commons Daemon Service Runner has encountered a problem and needs to close. We are sorry for
the inconvenience.

in the Event Viewer i see this message:

Faulting application prunsrv.exe, version, faulting module jvm.dll, version,
fault address 0x0012baba.

Why is this happening? What is wrong with this program?
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message