Folks:

I'm trying to use the JDK 1.4 object locking capabilities so I can prevent an application from running more than one time.

The code I'm using is pretty simple ...

FileLock lock = null;
File lockFile = null;
                
// make sure another instance of the server isn't running
try {
        lockFile = new File(LOCK_FILE);
        if (!lockFile.exists()) {
                lockFile.createNewFile();
        }
        lock = new FileOutputStream(lockFile).getChannel().tryLock();
} catch (IOException e) {
        String msg = MessageFormat.format(MC.getMessage("LOCK_ERR"),
                new String[] { e.getMessage() });
        System.err.println(msg);
        e.printStackTrace(System.err);
        System.exit(ALREADY_RUNNING_EXIT);
}

This code works fine on the PC (where I'm developing it) ... but when I run it on the iSeries ... I get the following exception:

java.io.IOException: Object is too large to process. Lock failed
at java/lang/Throwable.<init>(Throwable.java:195)


at java/lang/Exception.<init>(Exception.java:41)

at java/io/IOException.<init>(IOException.java:40)

at sun/nio/ch/FileChannelImpl.tryLock(FileChannelImpl.java:788)

at java/nio/channels/FileChannel.tryLock(FileChannel.java:967)

at com/mks/implementer/server/util/LaunchServer.main(LaunchServer.java:92)

Another VERY odd thing is ... line that is trying to obtain the lock is 105 ... but the java exception is indicating line 92. Running on the PC, the line number is reported correctly (when I force a different IOException).

Any suggestions on what could be going wrong?

Thanks!

david


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.