TryLock

Hi, I am trying to run one of the example codes from the book "Horton's_Java 2", this example is trying to show us when a lock has been etablished how other attepmts will fail.
I compiled it, but when I want to run it, it throws exception and says:
Exception in thread "main" java.nio.channels.NonWritableChannelException
at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:769)
at LocingPrimesRead.main(LockingPrimesRead.java:43)
and the code is:
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
public class LockingPrimesRead {
  public static void main (String[] args){
        File aFile = new File ("primes.bin");
        FileInputStream inFile = null;
        try{
            inFile = new FileInputStream(aFile);
        }catch(FileNotFoundException e){
            e.printStackTrace(System.err);
            System.exit(1);
        FileChannel inChannel = inFile.getChannel();
        final int PrimesCount = 6;
        ByteBuffer buf = ByteBuffer.allocate(8*PrimesCount);
        long[] primes = new long[PrimesCount];
        try{
            int primesRead = 0;
            FileLock inLock = null;
            while(true){
                int tryLockCount = 0;
                while(true){
                    inLock = inChannel.tryLock(inChannel.position(), buf.remaining(), false);
                    if(inLock == null){
                        if(++tryLockCount<100){
                            try{
                                Thread.sleep(200);
                            }catch(InterruptedException e){
                                e.printStackTrace(System.err);
                            continue;
                        }else{
                            System.out.println("Failed to acquire lock after " + tryLockCount+ " tries." + " Terminating...");
                            System.exit(1);
                    }else{
                            System.out.println("\nAcquired file lock.");
                            break;
                if (inChannel.read(buf) == -1) break;
                inLock.release();
                System.out.println("\nRelease file lock.");
                LongBuffer longBuf = ((ByteBuffer)(buf.flip())).asLongBuffer();
                primesRead = longBuf.remaining();
                longBuf.get(primes, 0, longBuf.remaining());
                StringBuffer str = null;
                for(int i=0; i< primesRead; i++){
                    if(i%6 ==0) System.out.println();
                    str = new StringBuffer("           ").append(primes);
System.out.print(str.substring (str.length()-12));
buf.clear();
System.out.println("\nEOF reached. ");
inFile.close();
}catch(IOException e){
e.printStackTrace(System.err);
System.exit(1);
System.exit(0);
by the way the "primes.bin" is a file which keeps some primes, if you need it I will send the code to create it later, just please let me know.
Thanks.

according to the api documentation this runtime exception will uccor when an attempt is made to write to a channel that was not originally opened for writing....
http://java.sun.com/j2se/1.4.1/docs/api/java/nio/channels/NonWritableChannelException.html
so, make sure that the is not read only, or maybe you have it open in someother application like notepad or something.... some applications will actually ristrict the file from being opened by other applications....
hope this helps
oaq

Similar Messages

  • Java.nio.FileChannel  tryLock() method does not lock!!!

    Hello,
    I have the following:
               RandomAccessFile raf = new RandomAccessFile(file, "rw");
               try {
                     lock = raf.getChannel().tryLock();
              } catch (OverlappingFileLockException e) {
                      System.out.println("File is locked"); // this never gets printed
               if (lock != null) {
                      // successfully acquired a lock
                      System.out.println("acquired lock!!!"); // this gets printed alright
                      // check if lock is valid
                      System.out.println("is this lock valid?  "+lock.isValid()); // it always is when I run my app
                      // do stuff with the file
              ....Note that I do NOT close the channel, which would make the lock invalid.
    Well, as far as I know, the code above tries to acquire an EXCLUSIVE lock (no read or write) on a file. It means that no other java application should be able to access that file, right?
    My problem is that I can still open that file with a second instance of my app, regardless of the lock.
    What am I missing?
    PS: don't know if it's relevant, but I do this right AFTER acquiring the lock:
         InputStream stream = Channels.newInputStream(raf.getChannel());
         XMLDecoder d = new XMLDecoder(new BufferedInputStream(stream));                       

    Thanks for the answer, mlk.
    Well, I went through MSDN to find no answer. Anyway, now I noticed tryLock() blocks, and it shouldn't. I ran two instances of my app and the second one keeps waiting till I release the lock created on the first one!!! Here's some code:
                try
                    lock = channel.tryLock();
                    System.out.println("File not locked");
                catch (OverlappingFileLockException e)
                    // File is already locked in this thread or virtual machine
                    System.out.println("File locked");
                 try
                    BufferedReader in = new BufferedReader(new InputStreamReader(
                            System.in));
                    String str = "";
                    while (str != null)
                        System.out.print("> prompt ");
                        str = in.readLine();
                        if (str.equalsIgnoreCase("status")) {
                            System.out.println("lock = "+lock);
                        } else if (str.equalsIgnoreCase("exit")) break;
    ...As stated in the API docs, tryLock() should return immediately. Therefore, the 'lock = channel.tryLock();' should either return cleanly or throw an exception. Then, no matter what, 'prompt >' should appear in the console. Except it doesn't for the second instance. Exiting the first instance makes the second one print out 'prompt'. I believe this shows tryLock() was blocking the execution. Am I missing something?
    Not being able to use file lock functionality has been annoying me for quite some time now. Urgh!!!!
    Has someone used it on Windows with success? Is there another way of doing it (I know one could use native code, but I could not find example) ?
    Thanks

  • FileChannel.tryLock() prevent backup sotware to read the lock file

    Hello,
    In the startup code of my application I lock a file for the whole session to prevent the application to be restarted. This mechanism works fine, however when I try to zip the folder that contains the locked file and the application is still running, winzip fails saying "can read file".
    Is there a way to create a lock such that the content of the file can be read?
    I'm running with Java 1.4.2_03-b2 on win2000, FAT32
    Thank you in advance.

    Hello,
    In the startup code of my application I lock a file
    for the whole session to prevent the application to be
    restarted..."Bad design alert"
    I'm inclined to say designing the app this way is wonky, and to find a 'solution' to directly answer your question without redesigning it to not do this lock file, is to just put a band-aid on a festering wound.

  • Issue with Ftp Client / Server using Sockets

    I have developed a Ftp Client and a Ftp Server. The client Connects to the Ftp Server and sends files to the ftp server. It is a multi threaded server and can have multiple clients connecting to it.
    If a client goes down...the server waits till the client comes up
    Similarly the client waits if a server goes down and reconnects when the server is again up and running
    i am having a strange issue here. When two clients go down and reconnect to the server...They take a long time to connect and transferring of files takes a long time...
    Other wise in all other scenarios the duo work properly.
    Any feedback and suggestion about this strange issue from all you java gurus out there will be deeply appreciated.
    Here is the client code
    import java.net.*;
    import java.net.Socket;
    import java.net.InetAddress;
    import java.io.*;
    import java.io.File;
    import java.util.*;
    import java.lang.*;
    import java.lang.Object;
    import javax.crypto.*;
    import java.util.regex.*;
    import javax.crypto.spec.PBEKeySpec;
    import javax.crypto.spec.PBEParameterSpec;
    import java.security.spec.AlgorithmParameterSpec;
    import java.security.spec.KeySpec;
    import java.io.InputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.File.*;
    import java.nio.channels.FileLock;
    public class  FTPClient {
         public static void main(String[] args) throws Exception
              Timer timer = new Timer("Test Timer");
              timer.scheduleAtFixedRate(new TimerTask()
                   private int counter = 0;
                                            public void run() {
                                                                     try     {                                                                                
                                                                              System.out.println(counter++);
                                                                               Socket soc=new Socket("xxx.x.x.xx",5217);
                                                                               System.out.println("Socket Initialised.");          
                                                                               transferfileClient t=new transferfileClient(soc);
                                                                               t.SendFile();
                                                                               System.out.println("run complete.");                                                                           
                                                                          catch(Exception ex)
                                                           }, 10000, 40000);
         static class transferfileClient
         Socket ClientSoc;
         DataInputStream din;
         DataOutputStream dout;
         BufferedReader br;
         transferfileClient(Socket soc)
              try
                   ClientSoc=soc;
                   din=new DataInputStream(ClientSoc.getInputStream());
                   dout=new DataOutputStream(ClientSoc.getOutputStream());
                   br=new BufferedReader(new InputStreamReader(System.in));
              catch(Exception ex)
         //encrypto routine starts
    class DesEncrypter {
           Cipher ecipher;
            Cipher dcipher;   
            // 8-byte Salt
            byte[] salt = {
                (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
                (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
            // Iteration count
            int iterationCount = 19;   
            DesEncrypter(String passPhrase) {
                try {
                             // Create the key
                             KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
                             SecretKey key = SecretKeyFactory.getInstance(
                             "PBEWithMD5AndDES").generateSecret(keySpec);
                             ecipher = Cipher.getInstance(key.getAlgorithm());
                             dcipher = Cipher.getInstance(key.getAlgorithm());   
                             // Prepare the parameter to the ciphers
                             AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);   
                             // Create the ciphers
                             ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
                             dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
                } catch (java.security.InvalidAlgorithmParameterException e) {
                } catch (java.security.spec.InvalidKeySpecException e) {
                } catch (javax.crypto.NoSuchPaddingException e) {
                } catch (java.security.NoSuchAlgorithmException e) {
                } catch (java.security.InvalidKeyException e) {
            // Buffer used to transport the bytes from one stream to another
            byte[] buf = new byte[1024];   
            public void encrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes written to out will be encrypted
                    out = new CipherOutputStream(out, ecipher);   
                    // Read in the cleartext bytes and write to out to encrypt
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                    out.close();
                } catch (java.io.IOException e) {
            public void decrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes read from in will be decrypted
                    in = new CipherInputStream(in, dcipher);   
                    // Read in the decrypted bytes and write the cleartext to out
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                    out.close();
                } catch (java.io.IOException e) {
    }     //encryptor routine ends     
         void SendFile() throws Exception
                   try
                   String directoryName; 
                   // File object referring to the directory.
                   String[] files;        // Array of file names in the directory.        
                   //directory = new File ( "C:\\FTP\\" ) ; 
                   File directory1 = new File("C:\\FTP");
                        boolean successmk = directory1.mkdir();
                        if (!successmk) {
                             // Directory creation failed /Already Exists
                        File directory = new File("C:\\FTP\\ftpc");
                        boolean successmk1 = directory.mkdir();
                        if (!successmk1) {
                             // Directory creation failed /Already Exists
                   //directory = new File ( "E:\\FTP-encrypted" ) ;           
                if (directory.isDirectory() == false) {
                    if (directory.exists() == false)
                       System.out.println("There is no such directory!");
                    else
                      System.out.println("That file is not a directory.");
                else {
                    files = directory.list();
                    System.out.println("Files in directory \"" + directory + "\":");
                    for (int i = 0; i < files.length; i++)
                             String patternStr = "xml";
                             Pattern pattern = Pattern.compile(patternStr);
                             Matcher matcher = pattern.matcher(files);
                             boolean matchFound = matcher.find();
                                       if (matchFound) {                                   
                                       System.out.println(" " + files[i]);                                        
                                       String filename;
                                       filename=files[i];                                   
                                       File f=new File(directory,filename);
                                       FileLock lock = null;                                   
                                       FileOutputStream fos = new FileOutputStream(f, true);
                                       lock = fos.getChannel().tryLock();
                                                 if (lock == null) {
                                                 System.out.println(" Failed to get the file lock: means that the file is locked by other instance.");
                                                 fos.close();
                                                 else
                                                                     InetAddress addr = InetAddress.getLocalHost();                                                                      
                                                                               // Get IP Address
                                                                               //byte[] ipAddr = addr.getAddress();
                                                                               String ip= addr.toString();                                                                      
                                                                               // Get hostname
                                                                               //String hostname = addr.getHostName();
                                       System.out.println(" Lock Acquired.");
                                       lock.release();
                                       fos.close();
                                       dout.writeUTF("SEND");
                                            dout.writeUTF(ip);
                                       dout.writeUTF(filename);
              //String msgFromServer=din.readUTF();          
    DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
    // Encrypt
              FileInputStream fino=new FileInputStream(f);
              encrypter.encrypt(fino,
    new FileOutputStream("ciphertext.txt"));               
              fino.close();
              FileInputStream fin=new FileInputStream("ciphertext.txt");          
              int ch;
              do
                   ch=fin.read();
                   dout.writeUTF(String.valueOf(ch));
              while(ch!=-1);
              fin.close();          
              String option;
                        option=din.readUTF();
                             if((option.compareTo("Delete")==0))     
                                  boolean success = (new File("ciphertext.txt")).delete();
                                  boolean success1 = f.delete();
                                  if (success) {
                                  System.out.println("File Sent ...");
                                  if (success1) {
                                  System.out.println("--File deleted from Client ...");
         for (int j = 0; j < 999999999; j++){}
                                       }//pattermatch loop ends here
    else
                             { //System.out.println("   " + "Not an XML file-------->" +files[i]);
    for (int jb = 0; jb < 111999999; jb++){}
              }// for loop ends here for files in directory
                   }//else loop ends for directory files listing               
         System.out.println("sendfile finished...");
         return;
         }               catch(Exception ex)          {ex.printStackTrace();}                    
         }//sendfile ends here     
         public void displayMenu() throws Exception
                   System.out.println(" Send File");                    
                        SendFile();
                        return;          
    And here is the server code...
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.text.SimpleDateFormat;
    import java.text.DateFormat;
    import java.text.Format;
    import java.lang.Object;
    import java.lang.*;
    import javax.crypto.*;
    import javax.crypto.spec.PBEKeySpec;
    import javax.crypto.spec.PBEParameterSpec;
    import java.security.spec.AlgorithmParameterSpec;
    import java.security.spec.KeySpec;
    public class FTPServer
    {     public static void main(String args[]) throws Exception
         {     ServerSocket soc=new ServerSocket(5217);
              System.out.println("FTP Server Started on Port Number 5217");
              while(true)
                   System.out.println("Waiting for Connection ...");
                   transferfile t=new transferfile(soc.accept());               
    class transferfile extends Thread
         Socket ClientSoc;
         DataInputStream din;
         DataOutputStream dout;     
         transferfile(Socket soc)
         {     try
              {     ClientSoc=soc;                              
                   din=new DataInputStream(ClientSoc.getInputStream());
                   dout=new DataOutputStream(ClientSoc.getOutputStream());
                   System.out.println("FTP Client Connected ...");
                   System.out.println("External IP of Client ..." + ClientSoc.getInetAddress());
                   //System.out.println("FTP Client Connected ..." + ClientSoc.getRemoteSocketAddress());
                   start();               
              catch(Exception ex)
    //encrypto routine starts
    class DesEncrypter {
            Cipher ecipher;
            Cipher dcipher;   
            // 8-byte Salt
            byte[] salt = {
                (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
                (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03 };   
            // Iteration count
            int iterationCount = 19;   
           DesEncrypter(String passPhrase) {
                try {
                    // Create the key
                    KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
                    SecretKey key = SecretKeyFactory.getInstance(
                        "PBEWithMD5AndDES").generateSecret(keySpec);
                    ecipher = Cipher.getInstance(key.getAlgorithm());
                    dcipher = Cipher.getInstance(key.getAlgorithm());   
                    // Prepare the parameter to the ciphers
                    AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);   
                    // Create the ciphers
                    ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
                    dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
                } catch (java.security.InvalidAlgorithmParameterException e) {
                } catch (java.security.spec.InvalidKeySpecException e) {
                } catch (javax.crypto.NoSuchPaddingException e) {
                } catch (java.security.NoSuchAlgorithmException e) {
                } catch (java.security.InvalidKeyException e) {
            // Buffer used to transport the bytes from one stream to another
            byte[] buf = new byte[1024];   
            public void encrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes written to out will be encrypted
                    out = new CipherOutputStream(out, ecipher);   
                    // Read in the cleartext bytes and write to out to encrypt
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                    out.close();
                } catch (java.io.IOException e) {
            public void decrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes read from in will be decrypted
                    in = new CipherInputStream(in, dcipher);   
                    // Read in the decrypted bytes and write the cleartext to out
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                        //added later on
                        in.close();                    
                    out.close();
                } catch (java.io.IOException e) {
    }     //encryptor routine ends
    //not implemented right now as we arent using the ftp server to download stuff...can be activated later on if we want
         void SendFile() throws Exception
              String filename=din.readUTF();
              File f=new File(filename);
              if(!f.exists())
                   dout.writeUTF("File Not Found");
                   return;
              else
              {     dout.writeUTF("READY");
                   FileInputStream fin=new FileInputStream(f);
                   int ch;
                   do
                        ch=fin.read();
                        dout.writeUTF(String.valueOf(ch));
                   while(ch!=-1);     
                   fin.close();     
                   dout.writeUTF("File Received Successfully");                                   
         String Compare(String filename) throws Exception
                        ///dout.writeUTF("entering compare");
                        String dateTempString=new String();
                        Date dateValue=new Date();
                        SimpleDateFormat formatter = new SimpleDateFormat ("hhmmss");
                        dateTempString = formatter.format(dateValue);
                        File dir1 = new File("C:\\FTPnew");
                        boolean success2 = dir1.mkdir();
                        if (!success2) {
                             // Directory creation failed /Already Exists
                        File dir = new File("C:\\FTPnew\\server");
                        boolean success = dir.mkdir();
                        if (!success) {
                             // Directory creation failed /Already Exists
                        File ftemp=new File(dir,dateTempString + filename);
                        File fnewtemp=new File(dir,"new-enc-"+filename);
                        // Create encrypter/decrypter class
                        DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
                        FileOutputStream fout=new FileOutputStream(fnewtemp);     
                        int ch;
                        String temp;
                        do
                        {     temp=din.readUTF();
                             ch=Integer.parseInt(temp);
                             if(ch!=-1)
                                  fout.write(ch);                         
                        }while(ch!=-1);
                        fout.close();
                        //dout.writeUTF("written temp en file");
                        // Decrypt
                    encrypter.decrypt(new FileInputStream(fnewtemp),
                    new FileOutputStream(ftemp));
                        //String Option;
                        dout.writeUTF("Delete");                    
                        System.out.println("File Upload Successfull--Duplicate file with timestamp Created");          
                        boolean success1 = fnewtemp.delete();                    
                        return "hello" ;
         void ReceiveFile() throws Exception
              String ip=din.readUTF();
              System.out.println("\tRequest Coming from Internal IP Address : "+ ip);
              String filename=din.readUTF();
              if(filename.compareTo("File not found")==0)
                   return;
              // Destination directory
       File dir11 = new File("C:\\FTPnew");
                        boolean success22 = dir11.mkdir();
                        if (!success22) {
                             // Directory creation failed /Already Exists
                        File dir = new File("C:\\FTPnew\\server");
                        boolean success21 = dir.mkdir();
                        if (!success21) {
                             // Directory creation failed /Already Exists
              File f=new File(dir ,"enc-"+filename);
              File fe=new File(dir,filename);
              String option;
              if(fe.exists())
                   //dout.writeUTF("File Already Exists");
                   String compvalue = Compare(filename);
                   //dout.writeUTF(compvalue);
                   if(compvalue.compareTo("hello")==0)
                        //dout.writeUTF("Transfer Completed");
                        return;
                   option=din.readUTF();
              else
                   //dout.writeUTF("SendFile");
                    option="Y";
                   if(option.compareTo("Y")==0)
                        // Generate a temporary key.       
            // Create encrypter/decrypter class
             DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
                 FileOutputStream fout=new FileOutputStream(f);                    
                        int ch;
                        String temp;
                        do
                        {     temp=din.readUTF();
                             ch=Integer.parseInt(temp);
                             if(ch!=-1)
                                  fout.write(ch);                         
                        }while(ch!=-1);
                        fout.close();                    
                        // Decrypt
                    encrypter.decrypt(new FileInputStream(f),
                    new FileOutputStream(fe));          
                        boolean success2 = f.delete();
                        dout.writeUTF("Delete");
                        System.out.println("File Upload Successfull");                    
                   else
                        return;
         public void run()
              while(true)
                   try
                   String Command=din.readUTF();
                   if(Command.compareTo("SEND")==0)
                        System.out.println("\tSEND Command Received ...");     
                        ReceiveFile();
                        continue;
                   catch(Exception ex)
                        //System.out.println("\tClient Terminated Abnormally ...........");
                        continue;

    Please note that this is not an FTP client and server. FTP is defined by a standard IETF protocol and this isn't it.
    Then, move the following lines:
    din=new DataInputStream(ClientSoc.getInputStream());
    dout=new DataOutputStream(ClientSoc.getOutputStream());
    System.out.println("FTP Client Connected ...");
    System.out.println("External IP of Client ..." + ClientSoc.getInetAddress());
    //System.out.println("FTP Client Connected ..."+ClientSoc.getRemoteSocketAddress());from the constructor into the run() method. i.e. don't do anything with the socket in the thread which handles the accept().

  • File lock() method problem

    I know this may be a common question, but can someone explain why this code:
    import java.io.*;
    import java.nio.channels.*;
    import java.util.*;
    public class TestFileLock
         private static File file;
         private static RandomAccessFile fileRandom;
         private static FileChannel fileChannel;
         private static FileLock fileLock;
         private static String process;
         public static void main(String[] args)
              process = args[0];
              try
                   file = new File("/home/fauxn/work/blast/java/java_blast/test.log");
                   //fileWriter = new FileWriter(file, true);
                   fileRandom = new RandomAccessFile(file, "rw");
                   fileChannel = fileRandom.getChannel();
                   for(int i =0; i < 1000; i++)
                        writeLogFile(process + ": happy days\n");
              catch(Exception exception)
                   System.out.println(exception.getMessage());
                   exception.printStackTrace();
         * Method lockes the logFile and then append the string to the file and unlocks the file.
         * @author Noel Faux.
         * @param s The string to be written to be appended to the file.
         private static void writeLogFile(String s) throws IOException
         System.out.println(process + ": trying to lock the log file");
         fileLock = fileChannel.tryLock();
         while(fileLock == null)
                   System.out.println(s + ": waiting!!!!");
                   fileLock = fileChannel.tryLock();
         System.out.println(s + ": logfile locked");
              fileRandom.seek(fileRandom.length());
         fileRandom.write(s.getBytes());
              fileLock.release();
              System.out.println(s + ": logfile unlocked");
    produces this error:
    Invalid argument
    java.io.IOException: Invalid argument
    at sun.nio.ch.FileChannelImpl.lock0(Native Method)
    at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:528)
    at java.nio.channels.FileChannel.tryLock(FileChannel.java:967)
    at TestFileLock.writeLogFile(TestFileLock.java:43)
    at TestFileLock.main(TestFileLock.java:23)
    on a intel linux box, java 1.4 and this code works fine:
    import java.io.*;
    import java.nio.channels.*;
    import java.util.*;
    public class TestFileLock
         private static File file;
         private static RandomAccessFile fileRandom;
         private static FileChannel fileChannel;
         private static FileLock fileLock;
         private static String process;
         public static void main(String[] args)
              process = args[0];
              try
                   file = new File("/home/fauxn/work/blast/java/java_blast/test.log");
                   //fileWriter = new FileWriter(file, true);
                   fileRandom = new RandomAccessFile(file, "rw");
                   fileChannel = fileRandom.getChannel();
                   for(int i =0; i < 1000; i++)
                        writeLogFile(process + ": happy days\n");
              catch(Exception exception)
                   System.out.println(exception.getMessage());
                   exception.printStackTrace();
         * Method lockes the logFile and then append the string to
    * the file and unlocks the file.
         private static void writeLogFile(String s) throws IOException
         System.out.println(process + ": trying to lock the log file");
         fileLock = fileChannel.tryLock(0, fileRandom.length(), false);
         while(fileLock == null)
                   System.out.println(s + ": waiting!!!!");
                   fileLock = fileChannel.tryLock(0, fileRandom.length(), false);
         System.out.println(s + ": logfile locked");
         fileRandom.seek(fileRandom.length());
         fileRandom.write(s.getBytes());
         fileLock.release();
         System.out.println(s + ": logfile unlocked");
    Any suggestions welcome, or is this a bug????
    Thanks in advance :)

    Its a known bug. The default tryLock() method calls the parametered
    tryLock method as follows
    tryLock(0,Long.MAX_VALUE,false);unfortunately under linux the parameter Long.MAX_VALUE is too big for
    the underlying OS file locking. This causes the IOException to be thrown
    It has been fixed in version 1.4.1 i believe.
    For more info
    http://developer.java.sun.com/developer/bugParade/bugs/4532474.html
    matfud

  • Large Memory Usage and Frozen [thread dump attached]

    Hi,
    SQL Developer (Version 2.1.1.64, WinXP Pro, Java 1.6, Oracle 10g R2) always uses at least 550MB of memory, if left open, for more than a day, it invariably goes up to 700-800MB.
    If I close all windows and connections, virtually no memory is reclaimed.
    I clicked + beside a view to see the columns, sqldeveloper froze for a few minutes, below is the thread dump.
    2010-05-21 11:31:58
    Full thread dump Java HotSpot(TM) Client VM (14.2-b01 mixed mode):
    "CONNECTION_ALIVE" prio=6 tid=0x3891c000 nid=0x1d58 waiting for monitor entry [0x3a55f000]
    java.lang.Thread.State: BLOCKED (on object monitor)
    at oracle.jdbc.driver.T4CConnection.doPingDatabase(T4CConnection.java:3398)
    - waiting to lock <0x09ad05f8> (a oracle.jdbc.driver.T4CConnection)
    at oracle.jdbc.driver.PhysicalConnection.pingDatabase(PhysicalConnection.java:7074)
    at oracle.javatools.db.ora.BaseOracleDatabase.isConnectionAlive(BaseOracleDatabase.java:165)
    at oracle.javatools.db.AbstractDatabase$1.run(AbstractDatabase.java:316)
    at java.lang.Thread.run(Thread.java:619)
    "Loading Children" prio=6 tid=0x3891bc00 nid=0x12c4 waiting on condition [0x39d5f000]
    java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for <0x03eab570> (a java.util.concurrent.FutureTask$Sync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:218)
    at java.util.concurrent.FutureTask.get(FutureTask.java:83)
    at oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$IdeTaskTracker.run(RaptorTaskManager.java:532)
    at java.lang.Thread.run(Thread.java:619)
    "pool-2-thread-57" prio=6 tid=0x3891b400 nid=0x2094 waiting on condition [0x35b5f000]
    java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for <0x09b819f0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireNanos(AbstractQueuedSynchronizer.java:841)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireNanos(AbstractQueuedSynchronizer.java:1160)
    at java.util.concurrent.locks.ReentrantLock.tryLock(ReentrantLock.java:416)
    at oracle.dbtools.raptor.utils.Connections.lock(Connections.java:1334)
    at oracle.dbtools.raptor.utils.Connections.lock(Connections.java:1319)
    at oracle.dbtools.raptor.utils.Connections.lock(Connections.java:1306)
    at oracle.dbtools.raptor.navigator.xml.AbstractItemInstance.lockConnection(AbstractItemInstance.java:52)
    at oracle.dbtools.raptor.navigator.xml.XmlNodeInstance.listChildren(XmlNodeInstance.java:55)
    at oracle.dbtools.raptor.navigator.ObjectNodeFilter$ObjectNodeFilterLoadTask.doWorkImpl(ObjectNodeFilter.java:78)
    at oracle.dbtools.raptor.navigator.DeferredLoadingFilter$FilterLoadTask.doWork(DeferredLoadingFilter.java:124)
    at oracle.dbtools.raptor.navigator.DeferredLoadingFilter$FilterLoadTask.doWork(DeferredLoadingFilter.java:113)
    at oracle.dbtools.raptor.backgroundTask.RaptorTask.call(RaptorTask.java:193)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$RaptorFutureTask.run(RaptorTaskManager.java:492)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
    "pool-2-thread-55" prio=6 tid=0x38d68400 nid=0xd74 runnable [0x3a15f000]
    java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at oracle.net.ns.Packet.receive(Packet.java:239)
    at oracle.net.ns.DataPacket.receive(DataPacket.java:92)
    at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:172)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:117)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:92)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:77)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1023)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:999)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:584)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:785)
    at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:860)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3425)
    - locked <0x09ad05f8> (a oracle.jdbc.driver.T4CConnection)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1490)
    at oracle.dbtools.raptor.controls.grid.ResultSetTableModel.openResultSet(ResultSetTableModel.java:412)
    at oracle.dbtools.raptor.controls.grid.ResultSetTableModel.fetchNext(ResultSetTableModel.java:169)
    at oracle.dbtools.raptor.controls.grid.ResultSetTableModel$4.doWork(ResultSetTableModel.java:556)
    at oracle.dbtools.raptor.controls.grid.ResultSetTableModel$4.doWork(ResultSetTableModel.java:540)
    at oracle.dbtools.raptor.backgroundTask.RaptorTask.call(RaptorTask.java:193)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$RaptorFutureTask.run(RaptorTaskManager.java:492)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
    "AWT-EventQueue-0" prio=6 tid=0x354fac00 nid=0x18d4 waiting for monitor entry [0x3a45f000]
    java.lang.Thread.State: BLOCKED (on object monitor)
    at oracle.jdbc.driver.PhysicalConnection.getMetaData(PhysicalConnection.java:3891)
    - waiting to lock <0x09ad05f8> (a oracle.jdbc.driver.T4CConnection)
    at oracle.dbtools.raptor.plscope.Query.getToolTipText(Query.java:58)
    at oracle.dbtools.raptor.phighlight.TooltipPlugin$1.getToolTipText(TooltipPlugin.java:29)
    at oracle.ide.ceditor.CodeEditor.getToolTipText(CodeEditor.java:1734)
    - locked <0x17245f98> (a java.util.ArrayList)
    at oracle.javatools.editor.BasicEditorPane.getToolTipText(BasicEditorPane.java:1530)
    at javax.swing.ToolTipManager$insideTimerAction.actionPerformed(ToolTipManager.java:658)
    at javax.swing.Timer.fireActionPerformed(Timer.java:271)
    at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    "Background Parser" prio=6 tid=0x38a43400 nid=0x23c4 waiting on condition [0x39c5f000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at oracle.dbtools.raptor.plsql.BackgroundParser$1.construct(BackgroundParser.java:112)
    at oracle.dbtools.raptor.utils.NamedSwingWorker$2.run(NamedSwingWorker.java:115)
    at java.lang.Thread.run(Thread.java:619)
    "SwingWorker-pool-5-thread-1142" prio=6 tid=0x38868800 nid=0x1a7c waiting on condition [0x3820f000]
    java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for <0x0e77bc10> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:358)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    "Background Parser" prio=6 tid=0x38a76c00 nid=0x1d18 waiting on condition [0x3a35f000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at oracle.dbtools.raptor.plsql.BackgroundParser$1.construct(BackgroundParser.java:112)
    at oracle.dbtools.raptor.utils.NamedSwingWorker$2.run(NamedSwingWorker.java:115)
    at java.lang.Thread.run(Thread.java:619)
    "Background Parser" prio=6 tid=0x387e2800 nid=0xd00 waiting on condition [0x3a25f000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at oracle.dbtools.raptor.plsql.BackgroundParser$1.construct(BackgroundParser.java:112)
    at oracle.dbtools.raptor.utils.NamedSwingWorker$2.run(NamedSwingWorker.java:115)
    at java.lang.Thread.run(Thread.java:619)
    "Background Parser" prio=6 tid=0x38752000 nid=0x2794 waiting on condition [0x39e5f000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at oracle.dbtools.raptor.plsql.BackgroundParser$1.construct(BackgroundParser.java:112)
    at oracle.dbtools.raptor.utils.NamedSwingWorker$2.run(NamedSwingWorker.java:115)
    at java.lang.Thread.run(Thread.java:619)
    "Swing-Shell" daemon prio=6 tid=0x367f0000 nid=0xd7c waiting on condition [0x3a85f000]
    java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for <0x1069d0d8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:358)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at sun.awt.shell.Win32ShellFolderManager2$ComInvoker$3.run(Win32ShellFolderManager2.java:458)
    at java.lang.Thread.run(Thread.java:619)
    "Persistence Auto Flusher" daemon prio=6 tid=0x388a5c00 nid=0x1950 in Object.wait() [0x37e0f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x0e892d48> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "Thread-76" prio=6 tid=0x387aec00 nid=0x259c runnable [0x00000000]
    java.lang.Thread.State: RUNNABLE
    "WeakDataReference polling" prio=2 tid=0x38752800 nid=0xe94 in Object.wait() [0x3a05f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
    - locked <0x0b6ba260> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
    at oracle.ide.util.WeakDataReference$Cleaner.run(WeakDataReference.java:88)
    at java.lang.Thread.run(Thread.java:619)
    "Image Animator 3" daemon prio=4 tid=0x3861b400 nid=0x2330 waiting on condition [0x3978f000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at sun.awt.image.GifFrame.dispose(GifImageDecoder.java:653)
    at sun.awt.image.GifImageDecoder.produceImage(GifImageDecoder.java:230)
    at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246)
    at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
    at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
    "Background Parser" prio=6 tid=0x38348800 nid=0x978 waiting on condition [0x3988f000]
    java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at oracle.dbtools.raptor.plsql.BackgroundParser$1.construct(BackgroundParser.java:112)
    at oracle.dbtools.raptor.utils.NamedSwingWorker$2.run(NamedSwingWorker.java:115)
    at java.lang.Thread.run(Thread.java:619)
    "TextBufferScavenger" prio=6 tid=0x38324800 nid=0x1af0 in Object.wait() [0x3968f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
    - locked <0x09bb9158> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
    at oracle.ide.model.TextNode$FacadeBufferReference$PollingThread.run(TextNode.java:1949)
    "pool-4-thread-1" prio=6 tid=0x36960400 nid=0x1a84 waiting on condition [0x35a5f000]
    java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for <0x08150a78> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1963)
    at java.util.concurrent.DelayQueue.take(DelayQueue.java:164)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:583)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:576)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    "IconOverlayTracker Timer" prio=6 tid=0x38520c00 nid=0x1b48 in Object.wait() [0x3950f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x0795f290> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "Timer queue for AWT thread" daemon prio=6 tid=0x369b4000 nid=0x1f20 in Object.wait() [0x3940f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x077e1358> (a java.lang.Object)
    at java.lang.Object.wait(Object.java:485)
    at ice.util.awt.TimedAWTExecutor.nextElem(TimedAWTExecutor.java:108)
    - locked <0x077e1358> (a java.lang.Object)
    at ice.util.awt.TimedAWTExecutor.runScheduler(TimedAWTExecutor.java:130)
    at ice.util.awt.TimedAWTExecutor$1.run(TimedAWTExecutor.java:19)
    "WaitCursor-Timer" prio=6 tid=0x367c3c00 nid=0x1010 in Object.wait() [0x37b0f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x077e1400> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "Native Directory Watcher" prio=2 tid=0x368d4000 nid=0x2334 runnable [0x3830f000]
    java.lang.Thread.State: RUNNABLE
    at oracle.ide.natives.NativeHandler.enterWatcherThread(Native Method)
    at oracle.ide.natives.NativeHandler$2.run(NativeHandler.java:252)
    at java.lang.Thread.run(Thread.java:619)
    "BaseTreeExplorer.NodeOpeningExecutor" prio=6 tid=0x3684b000 nid=0x8b0 waiting on condition [0x3810f000]
    java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for <0x06950af0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:358)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    "Scheduler" daemon prio=6 tid=0x36846400 nid=0x14bc in Object.wait() [0x37f0f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at oracle.dbtools.raptor.backgroundTask.TaskLinkedList.takeNextTask(TaskLinkedList.java:47)
    - locked <0x06950c70> (a oracle.dbtools.raptor.backgroundTask.TaskLinkedList)
    at oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$SchedulerThread.run(RaptorTaskManager.java:422)
    "TimerQueue" daemon prio=6 tid=0x36832800 nid=0x88c in Object.wait() [0x37d0f000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at javax.swing.TimerQueue.postExpiredTimers(TimerQueue.java:218)
    - locked <0x06950da8> (a javax.swing.TimerQueue)
    at javax.swing.TimerQueue.run(TimerQueue.java:234)
    - locked <0x06950da8> (a javax.swing.TimerQueue)
    at java.lang.Thread.run(Thread.java:619)
    "ChangeSetService" prio=2 tid=0x367fd400 nid=0x2754 in Object.wait() [0x37c0f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x06892cc0> (a oracle.jdevimpl.vcs.changeset.ChangeSetService)
    at java.lang.Object.wait(Object.java:485)
    at oracle.jdevimpl.vcs.changeset.ChangeSetService.awaitEvents(ChangeSetService.java:178)
    - locked <0x06892cc0> (a oracle.jdevimpl.vcs.changeset.ChangeSetService)
    at oracle.jdevimpl.vcs.changeset.ChangeSetService.eventLoop(ChangeSetService.java:199)
    at oracle.jdevimpl.vcs.changeset.ChangeSetService.access$200(ChangeSetService.java:56)
    at oracle.jdevimpl.vcs.changeset.ChangeSetService$2.run(ChangeSetService.java:138)
    at java.lang.Thread.run(Thread.java:619)
    "TimedCache-Timer" daemon prio=6 tid=0x35d52c00 nid=0x2448 in Object.wait() [0x3624f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x062ab118> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "JarIndex Timer" daemon prio=6 tid=0x35556400 nid=0x2488 in Object.wait() [0x35d4f000]
    java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.util.TimerThread.mainLoop(Timer.java:509)
    - locked <0x062206e0> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "AWT-Windows" daemon prio=6 tid=0x354dd000 nid=0x1d0c runnable [0x3595f000]
    java.lang.Thread.State: RUNNABLE
    at sun.awt.windows.WToolkit.eventLoop(Native Method)
    at sun.awt.windows.WToolkit.run(WToolkit.java:291)
    at java.lang.Thread.run(Thread.java:619)
    "AWT-Shutdown" prio=6 tid=0x354a1800 nid=0x268c in Object.wait() [0x3585f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:259)
    - locked <0x062208d8> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:619)
    "Java2D Disposer" daemon prio=10 tid=0x354b7400 nid=0x5f4 in Object.wait() [0x3575f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
    - locked <0x06220968> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
    at sun.java2d.Disposer.run(Disposer.java:125)
    at java.lang.Thread.run(Thread.java:619)
    "Low Memory Detector" daemon prio=6 tid=0x00ee1000 nid=0x2664 runnable [0x00000000]
    java.lang.Thread.State: RUNNABLE
    "CompilerThread0" daemon prio=10 tid=0x00edc000 nid=0x1f6c waiting on condition [0x00000000]
    java.lang.Thread.State: RUNNABLE
    "Attach Listener" daemon prio=10 tid=0x00eda800 nid=0x206c runnable [0x00000000]
    java.lang.Thread.State: RUNNABLE
    "Signal Dispatcher" daemon prio=10 tid=0x00ed9400 nid=0xf64 waiting on condition [0x00000000]
    java.lang.Thread.State: RUNNABLE
    "Finalizer" daemon prio=8 tid=0x00ec6c00 nid=0x2348 in Object.wait() [0x34e7f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
    - locked <0x061b0298> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    "Reference Handler" daemon prio=10 tid=0x00ec5800 nid=0x2484 in Object.wait() [0x34d7f000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
    - locked <0x061b0320> (a java.lang.ref.Reference$Lock)
    "main" prio=6 tid=0x009f8000 nid=0x19e0 waiting on condition [0x00000000]
    java.lang.Thread.State: RUNNABLE
    "VM Thread" prio=10 tid=0x00ec1800 nid=0x22e0 runnable
    "VM Periodic Task Thread" prio=10 tid=0x00eec000 nid=0x2604 waiting on condition
    JNI global references: 5312
    Heap
    def new generation total 45376K, used 28499K [0x03080000, 0x061b0000, 0x061b0000)
    eden space 40384K, 67% used [0x03080000, 0x04af44c0, 0x057f0000)
    from space 4992K, 28% used [0x05cd0000, 0x05e30850, 0x061b0000)
    to space 4992K, 0% used [0x057f0000, 0x057f0000, 0x05cd0000)
    tenured generation total 604992K, used 364537K [0x061b0000, 0x2b080000, 0x2b080000)
    the space 604992K, 60% used [0x061b0000, 0x1c5ae548, 0x1c5ae600, 0x2b080000)
    compacting perm gen total 57344K, used 57260K [0x2b080000, 0x2e880000, 0x33080000)
    the space 57344K, 99% used [0x2b080000, 0x2e86b348, 0x2e86b400, 0x2e880000)
    No shared spaces configured.
    Edited by: mdaly on May 21, 2010 11:42 AM

    The cause of hang could be figured out from the thread dump.
    I have fixed that in development code. It was happening from PL/SQL editor trying to create tooltip which locked up the connection.
    I am not sure what would lead to memory bloat even if the tool is not in use. There could be memory leak from some component. I am investigating that.
    Suggest you to keep ObjectViewers, reports & PL/SQL editor closed when not in use.
    Have Sql Array Fetch Size preference to 50 if it's higher.
    Do not have auto-refresh for Report editor.
    Keep Sql History, Find Db Object, Snippets collapsed.
    See if that helps.
    -Raghu

  • How to access the serial port on sdk 3.1.3 ?

    Hi all,
    I know that accessing serial port is not possible on firmware 2.x for non jailbroken iPhones.
    But what about firmware 3.0?
    Apple has focused firmware 3.0 on accessories, through bluetooth or through serial port. So, accessing serial port should be possible.
    But I can't find any documentation / sample code for that.
    Would you please help me?
    Regards,
    Alx
    PS: I tried to read the port /dev/cu.iap and get this message:
    Error opening serial port /dev/cu.iap - Permission denied(13).
    Looks bad.

    Yes I am enregistred in the Mad For iPod program?
    And I try to communique with my accessorie
    So the Code
    +*// SerialPortsModuleAppDelegate.m*+
    +*// SerialPortsModule*+
    +*// Created by BPO iMac on 08/02/10.*+
    +*// Copyright _MyCompanyName_ 2010. All rights reserved.*+
    +*#import "SerialPortsModuleAppDelegate.h"*+
    +*#import <fcntl.h>*+
    +*@implementation SerialPortsModuleAppDelegate*+
    +*@synthesize window;*+
    +*- (void)applicationDidFinishLaunching:(UIApplication *)application {*+
    +*// Override point for customization after application launch*+
    +*[window makeKeyAndVisible];*+
    +* portSerie = [SerialManager alloc];*+
    +* [portSerie init];*+
    +* int nb_port;*+
    +* nb_port = [portSerie findRS232Ports];*+
    +* NSString path_port;+
    +* path_port = [NSString alloc];*+
    +* int num_port;*+
    +* if(nb_port!=0)*+
    +* {*+
    +* num_port=0;*+
    +* path_port=[portSerie pathAtIndex:num_port];*+
    +* int resultat= [portSerie openInput:path_port baudrate:9600 bits:8 parity:0 stopbits:1 flags:O_RDONLY];*+
    +* if(resultat==-1)*+
    +* {*+
    +* NSLog(@"Communication Error");*+
    +* }*+
    +* resultat= [portSerie openOutput:path_port baudrate:9600 bits:8 parity:0 stopbits:1];*+
    +* if(resultat==-1)*+
    +* {*+
    +* NSLog(@"Communication Error");*+
    +* }*+
    +* }*+
    +* [path_port release];*+
    +* *+
    +*- (void)dealloc {*+
    +*[window release];*+
    +*[super dealloc];*+
    @end
    +*// SerialPortsModuleAppDelegate.h*+
    +*// SerialPortsModule*+
    +*// Created by BPO iMac on 08/02/10.*+
    +*// Copyright _MyCompanyName_ 2010. All rights reserved.*+
    +*#import <UIKit/UIKit.h>*+
    +*#import "SerialManager.h"*+
    +*@interface SerialPortsModuleAppDelegate : NSObject <UIApplicationDelegate> {*+
    +*UIWindow window;+
    +* SerialManager portSerie;+
    +*@property (nonatomic, retain) IBOutlet UIWindow window;+
    @end
    +*// SerialManager.m*+
    +*// K3 Tools*+
    +*// Created by Kok Chen on 4/28/09.*+
    +*// Copyright 2009 Kok Chen, W7AY. All rights reserved.*+
    +*#import "SerialManager.h"*+
    +*#include <unistd.h>*+
    +*#include <termios.h>*+
    +*#include <sys/ioctl.h>*+
    +*#include <IOKit/IOKitLib.h>*+
    +*#include <IOKit/serial/IOSerialKeys.h>*+
    +*#import <fcntl.h>*+
    +*#import <UIKit/UIKit.h>*+
    +*@implementation SerialManager*+
    +*- (id)init*+
    +* self = [ super init ] ;*+
    +* if ( self ) {*+
    +* termiosBits = -1 ;*+
    +* inputfd = outputfd = -1 ;*+
    +* useTermiosThread = NO ;*+
    +* needsNotification = NO ;*+
    +* termioLock = [ [ NSLock alloc ] init ] ;*+
    +* }*+
    +* return self ;*+
    +*static int findPorts( CFStringRef *stream, CFStringRef *path, int maxDevice, CFStringRef type )*+
    +*kernreturnt kernResult ;*+
    +*machportt masterPort ;*+
    +* ioiteratort serialPortIterator ;*+
    +* ioobjectt modemService ;*+
    +*CFMutableDictionaryRef classesToMatch ;*+
    +* CFStringRef cfString ;*+
    +* int count ;*+
    +*kernResult = IOMasterPort( MACHPORTNULL, &masterPort ) ;*+
    +*if ( kernResult != KERN_SUCCESS ) return 0 ;*+
    +* *+
    +*classesToMatch = IOServiceMatching( kIOSerialBSDServiceValue ) ;*+
    +*if ( classesToMatch == NULL ) return 0 ;*+
    +* *+
    +* // get iterator for serial ports (including modems)*+
    +* CFDictionarySetValue( classesToMatch, CFSTR(kIOSerialBSDTypeKey), type ) ;*+
    +*kernResult = IOServiceGetMatchingServices( masterPort, classesToMatch, &serialPortIterator ) ;*+
    +* // walk through the iterator*+
    +* count = 0 ;*+
    +* while ( ( modemService = IOIteratorNext( serialPortIterator ) ) ) {*+
    +* if ( count >= maxDevice ) break ;*+
    +*cfString = IORegistryEntryCreateCFProperty( modemService, CFSTR(kIOTTYDeviceKey), kCFAllocatorDefault, 0 ) ;*+
    +*if ( cfString ) {*+
    +* stream[count] = cfString ;*+
    +* cfString = IORegistryEntryCreateCFProperty( modemService, CFSTR(kIOCalloutDeviceKey), kCFAllocatorDefault, 0 ) ;*+
    +* if ( cfString ) {*+
    +* path[count] = cfString ;*+
    +* count++ ;*+
    +* }*+
    +* }*+
    +*IOObjectRelease( modemService ) ;*+
    +* IOObjectRelease( serialPortIterator ) ;*+
    +* return count ;*+
    +*// return number of ports*+
    +*- (int)findPorts:(CFStringRef)type*+
    +* CFStringRef cstream[64], cpath[64] ;*+
    +* int i ;*+
    +* *+
    +* numberOfPorts = findPorts( cstream, cpath, 64, type ) ;*+
    +* for ( i = 0; i < numberOfPorts; i++ ) {*+
    +* stream = [ [ NSString stringWithString:(NSString*)cstream ] retain ] ;*+
    +* CFRelease( cstream ) ;*+
    +* path = [ [ NSString stringWithString:(NSString*)cpath ] retain ] ;*+
    +* CFRelease( cpath ) ;*+
    +* }*+
    +* return numberOfPorts ;*+
    +*- (int)findPorts*+
    +* return [ self findPorts:CFSTR( kIOSerialBSDAllTypes ) ] ;*+
    +*- (int)findModems*+
    +* return [ self findPorts:CFSTR( kIOSerialBSDModemType ) ] ;*+
    +*- (int)findRS232Ports*+
    +* return [ self findPorts:CFSTR( kIOSerialBSDRS232Type ) ] ;*+
    +*- (NSString)streamAtIndex:(int)n+
    +* if ( n < 0 || n >= numberOfPorts ) return nil ;*+
    +* return stream[n] ;*+
    +*- (NSString)pathAtIndex:(int)n+
    +* if ( n < 0 || n >= numberOfPorts ) return nil ;*+
    +* return path[n] ;*+
    +*// common function to open port and set up serial port parameters*+
    +*static int openPort( NSString *path, int speed, int bits, int parity, int stops, int openFlags, Boolean input )*+
    +* int fd, cflag ;*+
    +* struct termios termattr ;*+
    +* *+
    +* fd = open( [ path cStringUsingEncoding:NSASCIIStringEncoding], openFlags ) ;*+
    +* if ( fd < 0 ) return -1 ;*+
    +* *+
    +* // build other flags*+
    +* cflag = 0 ;*+
    +* cflag |= ( bits == 7 ) ? CS7 : CS8 ; // bits*+
    +* if ( parity != 0 ) {*+
    +* cflag |= PARENB ; // parity*+
    +* if ( parity == 1 ) cflag |= PARODD ;*+
    +* }*+
    +* if ( stops > 1 ) cflag |= CSTOPB ;*+
    +* *+
    +* // merge flags into termios attributes*+
    +* tcgetattr( fd, &termattr ) ;*+
    +* termattr.c_cflag &= ~( CSIZE | PARENB | PARODD | CSTOPB ) ; // clear all bits and merge in our selection*+
    +* termattr.c_cflag |= cflag ;*+
    +* *+
    +* // set speed, split speed not support on Mac OS X?*+
    +* cfsetispeed( &termattr, speed ) ;*+
    +* cfsetospeed( &termattr, speed ) ;*+
    +* // set termios*+
    +* tcsetattr( fd, TCSANOW, &termattr ) ;*+
    +* return fd ;*+
    +*- (int)openInput:(NSString*)pathname baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops flags:(int)openFlags*+
    +* return ( inputfd = openPort( pathname, speed, bits, parity, stops, openFlags, YES ) ) ;*+
    +*- (int)openInput:(NSString*)pathname baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops*+
    +* return ( inputfd = openPort( pathname, speed, bits, parity, stops, ( O_RDONLY | O_NOCTTY | O_NDELAY ), YES ) ) ;*+
    +*- (int)openOutput:(NSString*)pathname baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops flags:(int)openFlags*+
    +* return ( outputfd = openPort( pathname, speed, bits, parity, stops, openFlags, NO ) ) ;*+
    +*- (int)openOutput:(NSString*)pathname baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops*+
    +* return ( outputfd = openPort( pathname, speed, bits, parity, stops, ( O_WRONLY | O_NOCTTY | O_NDELAY ), NO ) ) ;*+
    +*- (void)closeInput*+
    +* if ( inputfd > 0 ) close( inputfd ) ;*+
    +*- (void)closeOutput*+
    +* if ( outputfd > 0 ) close( outputfd ) ;*+
    +*- (int)inputFileDescriptor*+
    +* return inputfd ;*+
    +*- (int)outputFileDescriptor*+
    +* return outputfd ;*+
    +*- (int)getTermios*+
    +* int bits ;*+
    +* *+
    +* if ( inputfd > 0 ) {*+
    +* [ termioLock lock ] ;*+
    +* ioctl( inputfd, TIOCMGET, &bits ) ;*+
    +* [ termioLock unlock ] ;*+
    +* return bits ;*+
    +* }*+
    +* return 0 ;*+
    +*- (void)setRTS:(Boolean)state*+
    +* int bits ;*+
    +* if ( inputfd > 0 ) {*+
    +* [ termioLock lock ] ;*+
    +* ioctl( inputfd, TIOCMGET, &bits ) ;*+
    +* if ( state ) bits |= TIOCM_RTS ; else bits &= ~( TIOCM_RTS ) ;*+
    +* ioctl( inputfd, TIOCMSET, &bits ) ;*+
    +* [ termioLock unlock ] ;*+
    +* }*+
    +*- (void)setDTR:(Boolean)state*+
    +* int bits ;*+
    +* if ( inputfd > 0 ) {*+
    +* [ termioLock lock ] ;*+
    +* ioctl( inputfd, TIOCMGET, &bits ) ;*+
    +* if ( state ) bits |= TIOCM_DTR ; else bits &= ~( TIOCM_DTR ) ;*+
    +* ioctl( inputfd, TIOCMSET, &bits ) ;*+
    +* [ termioLock unlock ] ;*+
    +* }*+
    +*// IO Notifications*+
    +*// prototype for delegate*+
    +*- (void)port:(NSString*)name added:(Boolean)added*+
    +* if ( delegate && [ delegate respondsToSelector:@selector(port:added:) ] ) [ delegate port:name added:added ] ;*+
    +*// this is called from deviceAdded() and deviceRemoved() callbacks*+
    +*- (void)portsChanged:(Boolean)added iterator:(ioiteratort)iterator*+
    +* ioobjectt modemService ;*+
    +* CFStringRef cfString ;*+
    +* while ( ( modemService = IOIteratorNext( iterator ) ) > 0 ) {*+
    +* cfString = IORegistryEntryCreateCFProperty( modemService, CFSTR( kIOTTYDeviceKey ), kCFAllocatorDefault, 0 ) ;*+
    +* if ( cfString ) {*+
    +* [ self port:(NSString*)cfString added:added ] ;*+
    +* CFRelease( cfString ) ;*+
    +* }*+
    +* IOObjectRelease( modemService ) ;*+
    +* }*+
    +*// callback notification when device added*+
    +*static void deviceAdded(void *refcon, ioiteratort iterator )*+
    +* ioobjectt modemService ;*+
    +* *+
    +* if ( refcon ) [ (SerialManager*)refcon portsChanged:YES iterator:iterator ] ;*+
    +* else {*+
    +* while ( modemService = IOIteratorNext( iterator ) ) IOObjectRelease( modemService ) ;*+
    +* }*+
    +*static void deviceRemoved(void *refcon, ioiteratort iterator )*+
    +* ioobjectt modemService ;*+
    +* *+
    +* if ( refcon ) [ (SerialManager*)refcon portsChanged:NO iterator:iterator ] ;*+
    +* else {*+
    +* while ( modemService = IOIteratorNext( iterator ) ) IOObjectRelease( modemService ) ;*+
    +* }*+
    +*- (void)startNotification*+
    +* CFMutableDictionaryRef matchingDict ;*+
    +* *+
    +* notifyPort = IONotificationPortCreate( kIOMasterPortDefault ) ;*+
    +* CFRunLoopAddSource( CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource( notifyPort ), kCFRunLoopDefaultMode ) ;*+
    +* matchingDict = IOServiceMatching( kIOSerialBSDServiceValue ) ;*+
    +* CFRetain( matchingDict ) ;*+
    +* CFDictionarySetValue( matchingDict, CFSTR(kIOSerialBSDTypeKey), CFSTR( kIOSerialBSDAllTypes ) ) ;*+
    +* *+
    +* IOServiceAddMatchingNotification( notifyPort, kIOFirstMatchNotification, matchingDict, deviceAdded, self, &addIterator ) ;*+
    +* deviceAdded( nil, addIterator ) ; // set up addIterator*+
    +* IOServiceAddMatchingNotification( notifyPort, kIOTerminatedNotification, matchingDict, deviceRemoved, self, &removeIterator ) ;*+
    +* deviceRemoved( nil, removeIterator ) ; // set up removeIterator*+
    +*- (void)stopNotification*+
    +* if ( addIterator ) {*+
    +* IOObjectRelease( addIterator ) ;*+
    +* addIterator = 0 ;*+
    +* }*+
    +* if ( removeIterator ) {*+
    +* IOObjectRelease( removeIterator ) ;*+
    +* removeIterator = 0 ;*+
    +* }*+
    +* if ( notifyPort ) {*+
    +* CFRunLoopRemoveSource( CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource( notifyPort ), kCFRunLoopDefaultMode ) ;*+
    +* IONotificationPortDestroy( notifyPort ) ;*+
    +* notifyPort = nil ;*+
    +* }*+
    +*// prototype for delegate or subclass*+
    +*- (void)controlFlagsChanged:(int)termbits*+
    +* if ( delegate && [ delegate respondsToSelector:@selector(controlFlagsChanged:) ] ) [ delegate controlFlagsChanged:termbits ] ;*+
    +*- (void)termiosThread*+
    +* NSAutoreleasePool *pool = [ [ NSAutoreleasePool alloc ] init ] ;*+
    +* int termbits ;*+
    +* while ( 1 ) {*+
    +* if ( useTermiosThread == NO ) break ;*+
    +* if ( inputfd > 0 ) {*+
    +* if ( [ termioLock tryLock ] ) {*+
    +* ioctl( inputfd, TIOCMGET, &termbits ) ;*+
    +* if ( termiosBits != termbits ) [ self controlFlagsChanged:termbits ] ;*+
    +* termiosBits = termbits ;*+
    +* [ termioLock unlock ] ;*+
    +* }*+
    +* [ NSThread sleepUntilDate:[ NSDate dateWithTimeIntervalSinceNow:0.25 ] ] ;*+
    +* }*+
    +* else {*+
    +* [ NSThread sleepUntilDate:[ NSDate dateWithTimeIntervalSinceNow:1.0 ] ] ;*+
    +* }*+
    +* }*+
    +* [ pool release ] ;*+
    +*// If delegate is set, setDelegate also starts a termiosThread if delegate responds to -controlFlagsChanged:*+
    +*- (void)setDelegate:(id)object*+
    +* delegate = object ;*+
    +* if ( delegate == nil ) {*+
    +* useTermiosThread = NO ;*+
    +* if ( needsNotification ) {*+
    +* needsNotification = NO ;*+
    +* [ self stopNotification ] ;*+
    +* }*+
    +* }*+
    +* else {*+
    +* if ( [ delegate respondsToSelector:@selector(controlFlagsChanged:) ] ) {*+
    +* useTermiosThread = YES ;*+
    +* [ NSThread detachNewThreadSelector:@selector(termiosThread) toTarget:self withObject:nil ] ;*+
    +* } *+
    +* if ( [ delegate respondsToSelector:@selector(port:added:) ] ) {*+
    +* needsNotification = YES ;*+
    +* [ self startNotification ] ;*+
    +* }*+
    +* }*+
    +*- (id)delegate*+
    +* return delegate ;*+
    @end
    +*// SerialManager.h*+
    +*// K3 Tools*+
    +*// Created by Kok Chen on 4/28/09.*+
    +*// Copyright 2009 Kok Chen, W7AY. All rights reserved.*+
    +*//#import <Cocoa/Cocoa.h>*+
    +*#import <Foundation/Foundation.h>*+
    +*#import <UIKit/UIKit.h>*+
    +*#import <CoreData/CoreData.h>*+
    +*//#import <IOKit/IOKitLib.h>*+
    +*//#import <IOKitLib.h>*+
    +*#include <IOKit/IOKitLib.h>*+
    +*typedef int FileDescriptor ;*+
    +*@interface SerialManager : NSObject {*+
    +* NSLock *termioLock ;*+
    +* FileDescriptor outputfd ;*+
    +* FileDescriptor inputfd ;*+
    +* id delegate ;*+
    +* // serial ports in system*+
    +* NSString *stream[64] ;*+
    +* NSString *path[64] ;*+
    +* int numberOfPorts ;*+
    +* *+
    +* // termios*+
    +* int termiosBits ;*+
    +* Boolean useTermiosThread ;*+
    +* *+
    +* // IO notifications*+
    +* IONotificationPortRef notifyPort ;*+
    +* ioiteratort addIterator, removeIterator ;*+
    +* Boolean needsNotification ;*+
    +*- (void)setDelegate:(id)sender ;*+
    +*- (int)findPorts ;*+
    +*- (int)findModems ;*+
    +*- (int)findRS232Ports ;*+
    +*- (NSString*)streamAtIndex:(int)n ;*+
    +*- (NSString*)pathAtIndex:(int)n ;*+
    +*- (FileDescriptor)openInput:(NSString*)path baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops ;*+
    +*- (FileDescriptor)openInput:(NSString*)path baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops flags:(int)openFlags ;*+
    +*- (FileDescriptor)openOutput:(NSString*)path baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops ;*+
    +*- (FileDescriptor)openOutput:(NSString*)path baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops flags:(int)openFlags ;*+
    +*- (void)closeInput ;*+
    +*- (void)closeOutput ;*+
    +*- (FileDescriptor)inputFileDescriptor ;*+
    +*- (FileDescriptor)outputFileDescriptor ;*+
    +*- (int)getTermios ;*+
    +*- (void)setRTS:(Boolean)state ;*+
    +*- (void)setDTR:(Boolean)state ;*+
    +*- (void)setDelegate:(id)object ;*+
    +*- (id)delegate ;*+
    +*// delegates*+
    +*- (void)port:(NSString*)name added:(Boolean)added ;*+
    +*- (void)controlFlagsChanged:(int)termbits ;*+
    @end
    Could you help me ?

  • How do i determine what processes have a lock on a file?

    hi-
    i want to replicate the functionality of a program like:
    http://www.codeguru.com/Cpp/W-P/dll/article.php/c3641/
    in java, without having to use native code/JNI.
    the closest method i could find was:
    http://java.sun.com/j2se/1.5.0/docs/api/java/nio/channels/FileChannel.html#tryLock(long,%20long,%20boolean)
    however, FileChannel#tryLock doesn't identify what processes have a lock on the file.
    thanks,
    augusto.

    I don't think you can get hold of the locking process id using only Java.
    Kaj

  • File Locking!!! Is this a BUG or there is something wrong in my code.

    In new JDK v 1.4. new means of file locking are introuced, and it seems it is a little bit buggy yet (or maybe this one isn't a one). though it's better than nothing :)
    here is 2 classes. first locks a file, the second attemts to change it.
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.*;
    class FileLocker {
      static File targetFile = new File ("D:\\Java",
                                         "manual.chm");
      public static void main(String[] args)
          throws Exception
        RandomAccessFile fin = new RandomAccessFile (targetFile, "rw");
        FileChannel fChan = fin.getChannel();
        FileLock lock = fChan.lock();
        // to let other process to attempt to change the same file.
        Thread.currentThread().sleep(100000);
        lock.release();
        fChan.close();
        fin.close();
    }and the other class
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.*;
    class FileWriter {
      static File targetFile = new File ("D:\\Java",
                                         "manual.chm");
      public static void main(String[] args)
          throws Exception
        // this is better/more secure way to access files.
        RandomAccessFile f = new RandomAccessFile (targetFile, "rw");
        // next line deletes the file content even if file locked.
    //    FileOutputStream f = new FileOutputStream (targetFile);
    //--this parts is not needed as the problem is in first 2 lines
        FileChannel fChan = f.getChannel();
        if (fChan.isOpen()) {
          System.out.println("File is Opened, can't write");
        } else
          f.write(-1);
    }so when i use FileInputStream for open stream to write,
    constructor deletes the targetFile (makes it size equal to 0)
    at once i create new FileInputStream object. Since, when i
    use RandomAccessFile to open stream for writting nothing happens.
    after that, f.write (-1); throws exception regardless the way the
    uoutput stream was created.
    So i think there is some problem in FileInputStream class' constructor.

    OK, I know you mean FileOutputStream instead of FileInputStream in the above message. Looks to me like you've discovered a bug in the way Java is locking the file - locking the whole contents of a file (using the no-args lock or tryLock methods) doesn't prevent other programs, including Java, from overwriting some, if not all, of the file. Note that this occurs even on Windows 2000, where exclusive locks appear to be well supported.
    I've found a similar problem where saving from Outlook appears to zero the whole of the locked file. Saving from other programs that are a little more careful, such as XEmacs, appears to only (!) truncate the file to 0, as the FileOutputStream does.
    From what I can tell, in JDK 1.4.2 RandomAccessFiles respect each others' locks, but nothing else does.

  • Java.nio, FileChannel, FileLock conundrum...

    Hey all--
    I want to have multiple java machines on multiple clients to access a singe file. I want the first java machine to access it to lock the file so only it can write to the file. Other machines may come in later and read it.
    Here's the trouble. If I simply access the file as, say, a RandomAccessFile in "rw" mode. All the clients may read and write to their hearts desire without throwing and exception.
    So I found that if I obtain a FileChannel from the RandomAccessFile, I can tryLock(0,Long.MAX_VALUE,true) to obtain a Shared Lock.
    Here's the trouble. A client can obtain the lock and prevent others from writing to it successfully while allowing them to read from it...great!. HOWEVER, even though that particular client has the lock, the client can't write to the file either!
    myRandomAccessFile.write() methods NOR myRandomAccessFile.getChannel().write(myByteBuffer);NOR
    FileLock myFileLock =myRandomAccessFile.getChannel().tryLock(0,Long.MAX_VALUE,true);
    FileChannel lockedChannel = myFileLock.channel();
    lockedChannel.write(myByteBuffer);all of these throw a java.io.IOException "The process cannot access the file because another process has locked a portion of the file"
    I'm only running one process and one virtual machine. I also checked to make sure myFileLock != null and that myFileLock.isValid()==true So does obtaining a filelock also prevent my OWN program from writing to the file?! If so what's the use of a filelock? Because in order to write to the channel upon whose lock I have, I'd have to release the lock which would allow any other clients the ability to write to it concurrently.
    Thanks for the help! The documentation seems a bit sparse on this...

    I know they say it's platform dependent. But what's weird is that I know native Windows and native Mac apps (the two systems this program will run on) both allow the type of lock I describe. Yet, at least on Java on Windows, this locking system doesn't work.
    "FileLock protects against other locks."
    So this would be great too! It would at least let me sense when another jvm from a different machine was accessing my file and I, as the programmer, could say if someone else has a lock, my app won't do any writing.
    The problem is that the only locks I appear to be able to get are 1) exclusive lock that boots everyone from coming within a Gigabyte of the file... or
    2) a shared lock that let's no one write including the locker of the file.
    Even if it doesn't let me have a "everybody read, only I write" lock, I wish it let me have a lock that just said, "someone's currently accessing the file besides you"...then I could fill in, "so don't do any writing."
    Which brings me to what you said that's kind of exciting "Also be aware that you can lock bytes beyond the end of the file:"
    So if I lock a RandomAccessFile only at the byte Long.MAX_VALUE-1, other's would be able to see that lock, even though that aspect of the file on others file systems didn't even exist? Because if so, you've answered my question. That would let me write and read the rest of the file but still have other apps detect whether there was a lock on the file or not.
    I suppose I could also just lock the first byte of the file and ask the same question. I'm going to play around with that and see if it works.

  • Java.nio package Runtime error java.lang.UnsupportedClassVersionError.

    Hi
    I am using nio package and create a java program for file locking (FileLocking.java).
    Here is the sample
    try {
    file = new File("C:/acc.txt");
    channel = new RandomAccessFile(file, "rw").getChannel();
         lock = channel.lock(0, Long.MAX_VALUE, true);
    try {
              lock = channel.tryLock(0, Long.MAX_VALUE, true);
    catch (OverlappingFileLockException e) {
    return true;
    using wsad 5.1 and jdk1.4 i compiled this program.
    While executing i got the following runtime error..
    java.lang.UnsupportedClassVersionError: FileLocking (Unsupported major.minor version 48.0)
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:703)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:133)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:319)
         at java.net.URLClassLoader.access$400(URLClassLoader.java:92)
         at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:677)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:238)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:516)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:441)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:448)
    Exception in thread "main"
    Even if i try to recompile it in command prompt and run, i got the same error.
    please suggest me how can i overcome this problem.

    UnsupportedClassVersionError means that you are trying to execute a class for a newer version of the JVM on an older version of the JVM.
    Version 48.0 is for Java 1.4, so you have compiled your class with JDK 1.4.
    The computer you are trying to run the class on, has an older version of Java than 1.4 - check it!
    Try recompiling your source files with the "-target" switch, for example if you're running on Java 1.3, try compiling with:
    javac -target 1.3 ... FileLocking.java

  • Problem with apache2 + mod_jk2

    OS: SuSe 9.1
    apache: apache2-2.0.49-27.18.3
    OAS: Oracle9iAS Containers for J2EE Version 9.0.3.0.0
    i compiled myself mod_jk2
    i tried all version
    When i enter JSP page in browser
    if page size is very small - everything is OK
    if page size a little bigger, i got in browser:
    (at the end LALALALA means my HTML code from that JSP, but not from begining: there are only last part)
    ERROR BAD MESSAGE: msg_ajp.getLong(): BufferOverflowException %d %d
    msg_ajp.geInt(): BufferOverflowException %d %d
    msg_ajp.peekInt(): BufferOverflowException %d %d
    msg_ajp.getByte(): BufferOverflowException %d %d
    msg_ajp.getString(): BufferOverflowException %d %d
    msg_ajp.getBytes(): BufferOverflowException %d %d
    msgAjp.receive(): Bad signature %x%x
    msgAjp.receive(): Incoming message is too big %d
    msgAjp.copy(): destination buffer too small %d/%d
    msg.appendFromServer(): appendInt failed
    msgAjp.appendFromServer() error reading from server
    mutex.%d()
    ../../common/jk_mutex.c mutex.unlock()
    mutex.trylock()
    mutex.lock()
    mechanism logger.file logger.win32 uriMap uriEnv endpoint uri config ajp13 status run channel.un channel.socket shm procMutex channel.jni worker.jni vm signal user jk2_registry_init: Assertion failed, env==NULL -----END CERTIFICATE-----
    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ -----BEGIN CERTIFICATE-----
    0123456789abcdef &#1105;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;˜&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;h&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1080; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1105;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;˜&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;h&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1080; &#1102;&#1103;Content-Type Content-Language Content-Length Date Last-Modified Location Set-Cookie Set-Cookie2 Servlet-Engine Status WWW-Authenticate ../../common/jk_requtil.c web-inf meta-inf cookie ;jsessionid JSESSIONID user-agent referer pragma accept connection authorization content-type charset content-length encoding cookie2 language POST HEAD DELETE OPTIONS TRACE PROPFIND PROPPATCH MKCOL COPY MOVE UNLOCK REPORT VERSION-CONTROL CHECKIN UNCHECKOUT SEARCH MKWORKSPACE UPDATE LABEL MERGE BASELINE-CONTROL MKACTIVITY handler.marshalPostHead() - error len=%d
    handle.request() Error serializing the message head
    serialize.request() Add headerName %s
    serialize.request() Error serializing header id
    handle.request() Error serializing SSL key size
    handle.request() Error serializing SSL session
    handle.request() Error serializing secret
    handle.request() Error serializing SSL cipher
    handle.request() Error serializing SSL cert
    handle.request() Error serializing worker id
    handle.request() Error serializing query string
    handle.request() Error serializing auth type
    serialize.request() Error serializing user name
    Error ajp_marshal_into_msgb - method %s
    serialize.request() Error serializing header name
    serialize.request() serialized %s
    handle.request() Error encoding method %s
    handle.request() Error serializing attribute %s=%s
    serialize.request() Error serializing header value
    handle.request() Error serializing end marker
    size slots useMemory resetEndpointStats ../../common/jk_shm.c shm.init() Reset %s %#lx
    shm.init(): file=%s size=%d
    anon shm.%d()
    shm.writeSlot() %s %d
    epStat shm.getSlot() found existing slot %d %s
    shm.create(): shm created %#lx %#lx %d
    shm.create(): error creating shm %s
    shm.create(): error creating shm %d %s
    shm.create() Created head %#lx size %d
    shm.create(): Anonymous shared memory not implemented %d
    shm.init(): shm file not specified
    shm.writeSlot() No head - shm was not initalized
    shm.writeSlot() Packet too large %d %d
    shm.createSlot() Created slot %d
    shm.createSlot() found existing slot %s
    shm.createSlot() no shared memory head
    shm.createSlot() create %d returned NULL
    context servlet timing alias match_type aliases exact prefix gensuffix contextpath regexp uriEnv.init() map %s %s %s
    ../../common/jk_uriEnv.c lb:lb * worker vhost uriEnv.init() exact mapping %s=%s
    uriEnv.init() regexp mapping %s=%s
    uriEnv.init() map to invalid worker %s %s
    uriEnv.init() suffix mapping %s=%s
    uriEnv.init() %s host=%s uri=%s type=%d ctx=%s prefix=%s suffix=%s
    uriEnv.init() host mapping %s=%s
    uriEnv.init() prefix mapping %s=%s
    uriEnv.init() context must start with '/' in %s
    uriEnv.init() context mapping %s=%s
    uriEnv.parseName() parsing regexp %s not supported
    uriEnv.factory() error parsing %s
    uriEnv.setAttribute() the %s directive is deprecated. Use 'group' instead.
    uriMap.addUriEnv() %s %s %s
    ../../common/jk_uriMap.c uriMap.destroy()
    *: *:%d / uriMap.init() Fixing Host %s
    null uriMap: no context %s
    uriMap.init() global for %s
    uriMap.init() NPE
    uriMap: creating context %s
    uriMap.mapUri() found ctx %s
    %s:%d uriMap: creating duplicate of uri %s
    uriMap: can't create uri object %s
    uriMap.factory() OutOfMemoryError
    uriMap.init() Create default context %s
    uriMap.factory() Fail to create default host
    uriMap.init() Create missing host %s
    uriMap.init() loaded context %s %s %#lx %#lx %#lx
    uriMap: fix uri %s context %s host %s
    uriMap.init() adding context %s:%s for %s
    uriMap: can't create context object %s
    uriMap: creating duplicate of context %s
    uriMap.init() creating global webapp %s for %s
    uriMap.init() no context for %s
    uriMap.init() creating global mappings
    uriMap.init() processing mappings
    uriMap.mapUri() rewrote uri %s
    uriMap.mapUri() exact match %s %s
    uriMap.mapUri() hostname %s port %d uri %s
    uriMap.mapUri() found host %s
    uriMap.mapUri() uri must start with /
    uriMap.mapUri() context match %s %s
    uriMap.mapUri() prefix match %s %s
    uriMap.mapUri() caching host %s
    uriMap.mapUri() no context %s
    uriMap.mapUri() extension match %s %s
    uriMap.mapUri() cannot find host %s/
    uriMap.mapUri() no match found
    ../../common/jk_workerEnv.c destroy worker %s
    workerEnv.close() done %d
    workerEnv.init() Reset shm
    config.file Message: workerEnv.callbacks() %s
    Received Apache->tomcat fs so i386 arch HTTPS SSL_CLIENT_CERT SSL_CIPHER SSL_SESSION_ID SSL_CIPHER_USEKEYSIZE config: shm: Error creating config
    handler. workerEnv.init() ok %s
    logger sslEnable httpsIndicator certsIndicator cipherIndicator sessionIndicator keySizeIndicator forwardKeySize forwardURICompat forwardURICompatUnparsed forwardURIEscaped noRecoveryIfRequestSent noRecoveryIfHeaderSent workerEnv.initWorkers() init failed for %s
    workerEnv.initChannel() init failed for %s
    ${serverRoot}/conf/workers2.properties workerEnv.dispatch() Calling %d %s
    workerEnv.dispatch() Invalid code: %d
    workerEnv.processCallbacks() error sending response data
    workerEnv.processCallbacks() by configuration, avoid recovery when tomcat has started to send headers to client
    workerEnv.processCallbacks() Error reading reply
    workerEnv.processCallbacks() by configuration, avoid recovery when tomcat has received request
    workerEnv.processCallbacks() unknown status %d
    workerEnv.processCallbacks() no reply after %d ms waiting
    workerEnv.addChannel(): Can't find ajp13 worker
    Error getting uriMap implementation
    workerEnv.addWorker() duplicated %s worker
    workerEnv.init() create default worker %s
    U&#1100;&#1102;&#1103;&#1064;&#1101;&#1102;&#1103;&#1048;&#1101;&#1102;&#1103;¬&#1101;&#1102;&#1103;˜&#1101;&#1102;&#1103;channel secretkey max_connections lb_factor route routeRedirect connectTimeout replyTimeout prepostTimeout groups epCount lb_value errorState errorTime endpoint.close() %s
    ajp13.done() No pool
    ajp13.destroy()
    lb: ajp13.init(): No channel %s
    channelName 0 tomcatId ajp13.getEndpoint() No pool
    ajp13.service() %s
    ajp13.forwardST() After %d
    ajp13.service() done %s
    ajp13.connect() %s %s
    ajp13.connect() failed %s
    ajp13.connect() logging in
    Post head ../../common/jk_worker_ajp13.c ajp13.checkalive() can't get cpong reply from %s in %d ms
    ajp13.checkalive() can't send cping request to %s
    ajp13.checkalive() can't read cpong reply from %s
    ajp13.done() return to pool %s
    ajp13.done() Error recycling ep
    ajp13.done() close endpoint %s error_state %d
    ajp13.destroy() closed %d cached endpoints
    ajp13.factory() NullPointerException
    ajp13.init(): Adding %s to %s
    ajp13.init(): Automatically creating the group %s
    ajp13.init(): Failed to create %s
    ajp13.init(): Adding %s to default lb
    ajp13.init(): error creating endpoint ERROR BAD MESSAGE: msg_ajp.getLong(): BufferOverflowException %d %d
    msg_ajp.geInt(): BufferOverflowException %d %d
    msg_ajp.peekInt(): BufferOverflowException %d %d
    msg_ajp.getByte(): BufferOverflowException %d %d
    msg_ajp.getString(): BufferOverflowException %d %d
    msg_ajp.getBytes(): BufferOverflowException %d %d
    msgAjp.receive(): Bad signature %x%x
    msgAjp.receive(): Incoming message is too big %d
    msgAjp.copy(): destination buffer too small %d/%d
    msg.appendFromServer(): appendInt failed
    msgAjp.appendFromServer() error reading from server
    mutex.%d()
    ../../common/jk_mutex.c mutex.unlock()
    mutex.trylock()
    mutex.lock()
    mechanism logger.file logger.win32 uriMap uriEnv endpoint uri config ajp13 status run channel.un channel.socket shm procMutex channel.jni worker.jni vm signal user jk2_registry_init: Assertion failed, env==NULL -----END CERTIFICATE-----
    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ -----BEGIN CERTIFICATE-----
    0123456789abcdef &#1105;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;˜&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;h&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1080; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1105;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;˜&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;h&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1080; &#1102;&#1103;Content-Type Content-Language Content-Length Date Last-Modified Location Set-Cookie Set-Cookie2 Servlet-Engine Status WWW-Authenticate ../../common/jk_requtil.c web-inf meta-inf cookie ;jsessionid JSESSIONID user-agent referer pragma accept connection authorization content-type charset content-length encoding cookie2 language POST HEAD DELETE OPTIONS TRACE PROPFIND PROPPATCH MKCOL COPY MOVE UNLOCK REPORT VERSION-CONTROL CHECKIN UNCHECKOUT SEARCH MKWORKSPACE UPDATE LABEL MERGE BASELINE-CONTROL MKACTIVITY handler.marshalPostHead() - error len=%d
    handle.request() Error serializing the message head
    serialize.request() Add headerName %s
    serialize.request() Error serializing header id
    handle.request() Error serializing SSL key size
    handle.request() Error serializing SSL session
    handle.request() Error serializing secret
    handle.request() Error serializing SSL cipher
    handle.request() Error serializing SSL cert
    handle.request() Error serializing worker id
    handle.request() Error serializing query string
    handle.request() Error serializing auth type
    serialize.request() Error serializing user name
    Error ajp_marshal_into_msgb - method %s
    serialize.request() Error serializing header name
    serialize.request() serialized %s
    handle.request() Error encoding method %s
    handle.request() Error serializing attribute %s=%s
    serialize.request() Error serializing header value
    handle.request() Error serializing end marker
    size slots useMemory resetEndpointStats ../../common/jk_shm.c shm.init() Reset %s %#lx
    shm.init(): file=%s size=%d
    anon shm.%d()
    shm.writeSlot() %s %d
    epStat shm.getSlot() found existing slot %d %s
    shm.create(): shm created %#lx %#lx %d
    shm.create(): error creating shm %s
    shm.create(): error creating shm %d %s
    shm.create() Created head %#lx size %d
    shm.create(): Anonymous shared memory not implemented %d
    shm.init(): shm file not specified
    shm.writeSlot() No head - shm was not initalized
    shm.writeSlot() Packet too large %d %d
    shm.createSlot() Created slot %d
    shm.createSlot() found existing slot %s
    shm.createSlot() no shared memory head
    shm.createSlot() create %d returned NULL
    context servlet timing alias match_type aliases exact prefix gensuffix contextpath regexp uriEnv.init() map %s %s %s
    ../../common/jk_uriEnv.c lb:lb * worker vhost uriEnv.init() exact mapping %s=%s
    uriEnv.init() regexp mapping %s=%s
    uriEnv.init() map to invalid worker %s %s
    uriEnv.init() suffix mapping %s=%s
    uriEnv.init() %s host=%s uri=%s type=%d ctx=%s prefix=%s suffix=%s
    uriEnv.init() host mapping %s=%s
    uriEnv.init() prefix mapping %s=%s
    uriEnv.init() context must start with '/' in %s
    uriEnv.init() context mapping %s=%s
    uriEnv.parseName() parsing regexp %s not supported
    uriEnv.factory() error parsing %s
    uriEnv.setAttribute() the %s directive is deprecated. Use 'group' instead.
    uriMap.addUriEnv() %s %s %s
    ../../common/jk_uriMap.c uriMap.destroy()
    *: *:%d / uriMap.init() Fixing Host %s
    null uriMap: no context %s
    uriMap.init() global for %s
    uriMap.init() NPE
    uriMap: creating context %s
    uriMap.mapUri() found ctx %s
    %s:%d uriMap: creating duplicate of uri %s
    uriMap: can't create uri object %s
    uriMap.factory() OutOfMemoryError
    uriMap.init() Create default context %s
    uriMap.factory() Fail to create default host
    uriMap.init() Create missing host %s
    uriMap.init() loaded context %s %s %#lx %#lx %#lx
    uriMap: fix uri %s context %s host %s
    uriMap.init() adding context %s:%s for %s
    uriMap: can't create context object %s
    uriMap: creating duplicate of context %s
    uriMap.init() creating global webapp %s for %s
    uriMap.init() no context for %s
    uriMap.init() creating global mappings
    uriMap.init() processing mappings
    uriMap.mapUri() rewrote uri %s
    uriMap.mapUri() exact match %s %s
    uriMap.mapUri() hostname %s port %d uri %s
    uriMap.mapUri() found host %s
    uriMap.mapUri() uri must start with /
    uriMap.mapUri() context match %s %s
    uriMap.mapUri() prefix match %s %s
    uriMap.mapUri() caching host %s
    uriMap.mapUri() no context %s
    uriMap.mapUri() extension match %s %s
    uriMap.mapUri() cannot find host %s/
    uriMap.mapUri() no match found
    ../../common/jk_workerEnv.c destroy worker %s
    workerEnv.close() done %d
    workerEnv.init() Reset shm
    config.file Message: workerEnv.callbacks() %s
    Received Apache->tomcat fs so i386 arch HTTPS SSL_CLIENT_CERT SSL_CIPHER SSL_SESSION_ID SSL_CIPHER_USEKEYSIZE config: shm: Error creating config
    handler. workerEnv.init() ok %s
    logger sslEnable httpsIndicator certsIndicator cipherIndicator sessionIndicator keySizeIndicator forwardKeySize forwardURICompat forwardURICompatUnparsed forwardURIEscaped noRecoveryIfRequestSent noRecoveryIfHeaderSent workerEnv.initWorkers() init failed for %s
    workerEnv.initChannel() init failed for %s
    ${serverRoot}/conf/workers2.properties workerEnv.dispatch() Calling %d %s
    workerEnv.dispatch() Invalid code: %d
    workerEnv.processCallbacks() error sending response data
    workerEnv.processCallbacks() by configuration, avoid recovery when tomcat has started to send headers to client
    workerEnv.processCallbacks() Error reading reply
    workerEnv.processCallbacks() by configuration, avoid recovery when tomcat has received request
    workerEnv.processCallbacks() unknown status %d
    workerEnv.processCallbacks() no reply after %d ms waiting
    workerEnv.addChannel(): Can't find ajp13 worker
    Error getting uriMap implementation
    workerEnv.addWorker() duplicated %s worker
    workerEnv.init() create default worker %s
    U&#1100;&#1102;&#1103;&#1064;&#1101;&#1102;&#1103;&#1048;&#1101;&#1102;&#1103;¬&#1101;&#1102;&#1103;˜&#1101;&#1102;&#1103;channel secretkey max_connections lb_factor route routeRedirect connectTimeout replyTimeout prepostTimeout groups epCount lb_value errorState errorTime endpoint.close() %s
    ajp13.done() No pool
    ajp13.destroy()
    lb: ajp13.init(): No channel %s
    channelName 0 tomcatId ajp13.getEndpoint() No pool
    ajp13.service() %s
    ajp13.forwardST() After %d
    ajp13.service() done %s
    ajp13.connect() %s %s
    ajp13.connect() failed %s
    ajp13.connect() logging in
    Post head ../../common/jk_worker_ajp13.c ajp13.checkalive() can't get cpong reply from %s in %d ms
    ajp13.checkalive() can't send cping request to %s
    ajp13.checkalive() can't read cpong reply from %s
    ajp13.done() return to pool %s
    ajp13.done() Error recycling ep
    ajp13.done() close endpoint %s error_state %d
    ajp13.destroy() closed %d cached endpoints
    ajp13.factory() NullPointerException
    ajp13.init(): Adding %s to %s
    ajp13.init(): Automatically creating the group %s
    ajp13.init(): Failed to create %s
    ajp13.init(): Adding %s to default lb
    ajp13.init(): error creating endpoint ERROR BAD MESSAGE: msg_ajp.getLong(): BufferOverflowException %d %d
    msg_ajp.geInt(): BufferOverflowException %d %d
    msg_ajp.peekInt(): BufferOverflowException %d %d
    msg_ajp.getByte(): BufferOverflowException %d %d
    msg_ajp.getString(): BufferOverflowException %d %d
    msg_ajp.getBytes(): BufferOverflowException %d %d
    msgAjp.receive(): Bad signature %x%x
    msgAjp.receive(): Incoming message is too big %d
    msgAjp.copy(): destination buffer too small %d/%d
    msg.appendFromServer(): appendInt failed
    msgAjp.appendFromServer() error reading from server
    mutex.%d()
    ../../common/jk_mutex.c mutex.unlock()
    mutex.trylock()
    mutex.lock()
    mechanism logger.file logger.win32 uriMap uriEnv endpoint uri config ajp13 status run channel.un channel.socket shm procMutex channel.jni worker.jni vm signal user jk2_registry_init: Assertion failed, env==NULL -----END CERTIFICATE-----
    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ -----BEGIN CERTIFICATE-----
    0123456789abcdef &#1105;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;˜&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;h&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1080; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1105;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;˜&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;h&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1038;&#1102;&#1103;&#1054; &#1102;&#1103;&#1054; &#1102;&#1103;&#1080; &#1102;&#1103;Content-Type Content-Language Content-Length Date Last-Modified Location Set-Cookie Set-Cookie2 Servlet-Engine Status WWW-Authenticate ../../common/jk_requtil.c web-inf meta-inf cookie ;jsessionid JSESSIONID user-agent referer pragma accept connection authorization content-type charset content-length encoding cookie2 language POST HEAD DELETE OPTIONS TRACE PROPFIND PROPPATCH MKCOL COPY MOVE UNLOCK REPORT VERSION-CONTROL CHECKIN UNCHECKOUT SEARCH MKWORKSPACE UPDATE LABEL MERGE BASELINE-CONTROL MKACTIVITY handler.marshalPostHead() - error len=%d
    handle.request() Error serializing the message head
    serialize.request() Add headerName %s
    serialize.request() Error serializing header id
    handle.request() Error serializing SSL key size
    handle.request() Error serializing SSL session
    handle.request() Error serializing secret
    handle.request() Error serializing SSL cipher
    handle.request() Error serializing SSL cert
    handle.request() Error serializing worker id
    handle.request() Error serializing query string
    handle.request() Error serializing auth type
    serialize.request() Error serializing user name
    Error ajp_marshal_into_msgb - method %s
    serialize.request() Error serializing header name
    serialize.request() serialized %s
    handle.request() Error encoding method %s
    handle.request() Error serializing attribute %s=%s
    serialize.request() Error serializing header value
    handle.request() Error serializing end marker
    size slots useMemory resetEndpointStats ../../common/jk_shm.c shm.init() Reset %s %#lx
    shm.init(): file=%s size=%d
    anon shm.%d()
    shm.writeSlot() %s %d
    epStat shm.getSlot() found existing slot %d %s
    shm.create(): shm created %#lx %#lx %d
    shm.create(): error creating shm %s
    shm.create(): error creating shm %d %s
    shm.create() Created head %#lx size %d
    shm.create(): Anonymous shared memory not implemented %d
    shm.init(): shm file not specified
    shm.writeSlot() No head - shm was not initalized
    shm.writeSlot() Packet too large %d %d
    shm.createSlot() Created slot %d
    shm.createSlot() found existing slot %s
    shm.createSlot() no shared memory head
    shm.createSlot() create %d returned NULL
    context servlet timing alias match_type aliases exact prefix gensuffix contextpath regexp uriEnv.init() map %s %s %s
    ../../common/jk_uriEnv.c lb:lb * worker vhost uriEnv.init() exact mapping %s=%s
    uriEnv.init() regexp mapping %s=%s
    uriEnv.init() map to invalid worker %s %s
    uriEnv.init() suffix mapping %s=%s
    uriEnv.init() %s host=%s uri=%s type=%d ctx=%s prefix=%s suffix=%s
    uriEnv.init() host mapping %s=%s
    uriEnv.init() prefix mapping %s=%s
    uriEnv.init() context must start with '/' in %s
    uriEnv.init() context mapping %s=%s
    uriEnv.parseName() parsing regexp %s not supported
    uriEnv.factory() error parsing %s
    uriEnv.setAttribute() the %s directive is deprecated. Use 'group' instead.
    uriMap.addUriEnv() %s %s %s
    ../../common/jk_uriMap.c uriMap.destroy()
    *: *:%d / uriMap.init() Fixing Host %s
    null uriMap: no context %s
    uriMap.init() global for %s
    uriMap.init() NPE
    uriMap: creating context %s
    uriMap.mapUri() found ctx %s
    %s:%d uriMap: creating duplicate of uri %s
    uriMap: can't create uri object %s
    uriMap.factory() OutOfMemoryError
    uriMap.init() Create default context %s
    uriMap.factory() Fail to create default host
    uriMap.init() Create missing host %s
    uriMap.init() loaded context %s %s %#lx %#lx %#lx
    uriMap: fix uri %s context %s host %s
    uriMap.init() adding context %s:%s for %s
    uriMap: can't create context object %s
    uriMap: creating duplicate of context %s
    uriMap.init() creating global webapp %s for %s
    uriMap.init() no context for %s
    uriMap.init() creating global mappings
    uriMap.init() processing mappings
    uriMap.mapUri() rewrote uri %s
    uriMap.mapUri() exact match %s %s
    uriMap.mapUri() hostname %s port %d uri %s
    uriMap.mapUri() found host %s
    uriMap.mapUri() uri must start with /
    uriMap.mapUri() context match %s %s
    uriMap.mapUri() prefix match %s %s
    uriMap.mapUri() caching host %s
    uriMap.mapUri() no context %s
    uriMap.mapUri() extension match %s %s
    uriMap.mapUri() cannot find host %s/
    uriMap.mapUri() no match found
    ../../common/jk_workerEnv.c destroy worker %s
    workerEnv.close() done %d
    workerEnv.init() Reset shm
    config.file Message: workerEnv.callbacks() %s
    Received Apache->tomcat fs so i386 arch HTTPS SSL_CLIENT_CERT SSL_CIPHER SSL_SESSION_ID SSL_CIPHER_USEKEYSIZE config: shm: Error creating config
    handler. workerEnv.init() ok %s
    logger sslEnable httpsIndicator certsIndicator cipherIndicator sessionIndicator keySizeIndicator forwardKeySize forwardURICompat forwardURICompatUnparsed forwardURIEscaped noRecoveryIfRequestSent noRecoveryIfHeaderSent workerEnv.initWorkers() init failed for %s
    workerEnv.initChannel() init failed for %s
    ${serverRoot}/conf/workers2.properties workerEnv.dispatch() Calling %d %s
    workerEnv.dispatch() Invalid code: %d
    workerEnv.processCallbacks() error sending response data
    workerEnv.processCallbacks() by configuration, avoid recovery when tomcat has started to send headers to client
    workerEnv.processCallbacks() Error reading reply
    workerEnv.processCallbacks() by configuration, avoid recovery when tomcat has received request
    workerEnv.processCallbacks() unknown status %d
    workerEnv.processCallbacks() no reply after %d ms waiting
    workerEnv.addChannel(): Can't find ajp13 worker
    Error getting uriMap implementation
    workerEnv.addWorker() duplicated %s worker
    workerEnv.init() create default worker %s
    U&#1100;&#1102;&#1103;&#1064;&#1101;&#1102;&#1103;&#1048;&#1101;&#1102;&#1103;¬&#1101;&#1102;&#1103;˜&#1101;&#1102;&#1103;channel secretkey max_connections lb_factor route routeRedirect connectTimeout replyTimeout prepostTimeout groups epCount lb_value errorState errorTime endpoint.close() %s
    ajp13.done() No pool
    ajp13.destroy()
    lb: ajp13.init(): No channel %s
    channelName 0 tomcatId ajp13.getEndpoint() No pool
    ajp13.service() %s
    ajp13.forwardST() After %d
    ajp13.service() done %s
    ajp13.connect() %s %s
    ajp13.connect() failed %s
    ajp13.connect() logging in
    Post head ../../common/jk_worker_ajp13.c ajp13.checkalive() can't get cpong reply from %s in %d ms
    ajp13.checkalive() can't send cping request to %s
    ajp13.checkalive() can't read cpong reply from %s
    ajp13.done() return to pool %s
    ajp13.done() Error recycling ep
    ajp13.done() close endpoint %s error_state %d
    ajp13.destroy() closed %d cached endpoints
    ajp13.factory() NullPointerException
    ajp13.init(): Adding %s to %s
    ajp13.init(): Automatically creating the group %s
    ajp13.init(): Failed to create %s
    ajp13.init(): Adding %s to default lb
    ajp13.init(): error creating endpointLALALALALALALA

    Start by using console and checking your apache logs in /var/log/httpd or whereveer you have set apache2 to log to.
    Aside from using your 'configuration' - is there some features you need in apache2 that are not available in apache ?

  • FileLock not working properly in Solaris

    I tried to obtain the lock of a file using
    fileLock = fileChannel.tryLock();
    In Window,
    First called fileChannel.tryLock() on a file and obtained the lock successfully
    Again i tried to obtain the lock of the same file using fileChannel.tryLock() & it returns null (means that lock is already obtained). No problem in windows.
    But In Solaris,
    First called fileChannel.tryLock() on a file and obtained the lock successfully
    Again i tried to obtain the lock of the same file using fileChannel.tryLock() & it again returns the lock successfully which is not the expected behavior. Why is it so?
    Thanks,
    Deepak

    If you are callinf FileLock from within the same JVM, yes it will succeed. The API docs themselves say that it is use for use between processes, not within the JVM, as it is the OS that determines it's behaviour, and on many OSes it is perfectly legal and valid for the same process to request a lock on a file that it already holds.

  • A question about Condition#await(long, timeunit)

    Hello, all:
    I am testing Condition#await(long, Timeunit).
    In my testing code there are two threads. Thread#1 acquires the lock first, releases it by calling condtion.await(50, TimeUnit.MILLISECONDS), and print sth.
    Thread#2 acquires the lock as soon as Thread#1 release it, but in its run(), it sleeps for 2000 millsec, during which time Thread#1's waiting should have expired and the code should have proceeded. Nevertheless, Thread#1 still suspend till Thread#2 run to its completion.
    My explaination is that the fact that Thread#1's waiting expired only means now it's mode switch to runnable, still it can't run until it re-acuquire the lock.
    Am I right?
    Thanks for your input
    The code is as below
    public class SyncTest {
         private Lock lock = new ReentrantLock();
         private Condition cond = lock.newCondition();
          class Task1 implements Runnable{
              public void run(){
                   if(lock.tryLock()){
                        try{
                             Thread.sleep(500);
                             cond.await(50,TimeUnit.MILLISECONDS);
                             System.out.println("Task1.");
                        } catch (InterruptedException e) {
                             e.printStackTrace();
                        finally{
                             lock.unlock();
          class Task2 implements Runnable{
              public void run(){
                   boolean locked = false;
                   try {
                        locked = lock.tryLock(510, TimeUnit.MILLISECONDS);
                   } catch (InterruptedException e) {
                        e.printStackTrace();
                   if(locked){
                        try{
                             Thread.sleep(2000);
                             System.out.println("Task2.");
                             cond.signalAll();
                        } catch (InterruptedException e) {
                             e.printStackTrace();
                        finally{
                             lock.unlock();
         public static void main(String[] args){
              SyncTest st = new SyncTest();
              new Thread(st.new Task1()).start();
              new Thread(st.new Task2()).start();
    }

    Johnny_hunter wrote:
    My explaination is that the fact that Thread#1's waiting expired only means now it's mode switch to runnable, still it can't run until it re-acuquire the lock.
    Am I right?yes, you are correct.

  • Writing to files on windows

    Hi
    I have a jvm that will write some text to a file on a windows file system. There is some another process that will read it. This other process is beyond my control i.e. it wont be written by me and won't be java.
    How do i ensure that my jvm that writes to this file only when no other process is reading and also blocks on the write to prevent the other process trying to read when a write is in progress?
    I have read about FileChannel and FileLock and have tried writing a test app. My FileChannel tryLock call always seems to succeed, meaning that my write then goes ahead even when the other process is reading, which can cause this read to then fail.
    Any ideas? I know there are lots of hits for FileChannel and FileLock on this forum but nothing matching my requirements that i can see.
    appreciate any advice
    thanks

    Locks tend to be [advisory versus mandatory|http://java.sun.com/javase/6/docs/api/java/nio/channels/FileLock.html], so unless both processes are using locks, they don't work.
    One way to keep the reader from reading while you are writing is to write to a different fille in the same folder (say fileXXXXXXXX.tmp) then when you are done writing, rename it (say fileXXXXXXXX.txt).
    To keep from over-writing the file while another process is reading an earlier version.... hmmm.. include a unique timestamp in the name of the file?

Maybe you are looking for

  • After 10.7.5 update, Bluetooth can't connect, help!

    I'd been using a BT speaker (Logitech Boombox) with more or less reliable connectivty with my MacBook Air (2012) (my Android phone never has a problem connecting to speaker), but after updating to 10.7.5 now, I can't connect to any BT device!  The MB

  • Can iPod shuffle be used with any FM recivers for car listening?

    Can my iPod Shuffle be used with any FM receivers so that I can listen to songs through my car radio? I know Alot of FM recievers say that they are compatable with variouse mp3 players. I just want to know if I can plug in my Ipod shuffle to any of t

  • Banner size video - how can I set the canvas to an odd size?

    I'm interested in creating web page ad banners that include some looping video. Is there a way to set the canvas size to 350x250 or some other odd size? If not, do you know if any other video editing software can allow this? Thanks, DAN PowerBook G4

  • Says apple id has been disabled

    on app store , i get a message : your apple id has been disabled , i have resetted it several times?

  • Siri Microphone Activation Button Intermittent Defect

    I recently got my new iPhone 5 and love the new Siri capabilities on it.  I use it for quite a lot of things and enjoy that it can be used hands-free to do many tasks on the iPhone. I have noticed, however, that sometimes when Siri gets finished proc