Results 1 to 16 of 16
  1. #1
    dnyan123 is offline Member
    Join Date
    Oct 2008
    Posts
    17
    Rep Power
    0

    Default Error trace in swing application

    I have got the following trace in one of my swing based applications,

    java.io.IOException: Bad file descriptor
    at java.io.FileInputStream.readBytes(Native Method)
    at java.io.FileInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at java.io.FilterInputStream.read(Unknown Source)
    at sun.nio.cs.StreamDecoder$ConverterSD.implRead(Unkn own Source)
    at sun.nio.cs.StreamDecoder.read(Unknown Source)
    at java.io.InputStreamReader.read(Unknown Source)
    at java.io.BufferedReader.fill(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    171)
    at javax.swing.Timer.fireActionPerformed(Unknown Source)
    at javax.swing.Timer$DoPostEvent.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    the associated code is:-

    String line;
    String query="c:\\WINNT\\system32\\tasklist.exe /FO CSV /v /nh";
    Process p = Runtime.getRuntime().exec(query);
    BufferedReader input = new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    if (!line.trim().equals("")) {
    do something
    .....
    }
    }
    p.destroy();
    input.close();

    can someone help??
    Last edited by dnyan123; 10-20-2008 at 08:46 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    at java.io.BufferedReader.readLine(Unknown Source)
    171)
    at javax.swing.Timer.fireActionPerformed(Unknown Source)
    Why did you delete a part of the stack trace line?

    db

  3. #3
    dnyan123 is offline Member
    Join Date
    Oct 2008
    Posts
    17
    Rep Power
    0

    Default

    part of the company's copyright policy.... however, i've already put the code snippet that i've used... also below is the trace that i deleted..

    at biz.***n.ta.c****nt.cl***ient.Ru***ter(cl###ent.ja va:867)
    at biz.a***n.ta.cl***ent.clo***ent.access$1100(clo*** nt.java:55)
    at biz.au***n.ta.cl***nt.clo***nt$1.actionPerformed(c l***ent.java:171)

    hope this helps...

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    So what's on line 867?

    Maybe your company needs an improved recruitment policy.

    db

  5. #5
    dnyan123 is offline Member
    Join Date
    Oct 2008
    Posts
    17
    Rep Power
    0

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Maybe your company needs an improved recruitment policy.
    db
    may be this site needs to revise the criteria it uses to determine so called senior members. The stars and hashes indicate that I am not allowed to indicate the class names. I guess anyone would understand. One more thing. Please help me if you want to. I have attached the code snippet as well the full error trace. And if you doubt the company's recruitment policy so much, may be I can forward you my resume and then you can safely remove the comments that you made.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Once again, so what's on line 867?

    Do you seriously expect that anyone here will be able to get to the root of your problem without even knowing the content of the one line that triggers the exception? After all, you have access to the entire codebase and you're stuck.

    db

  7. #7
    dnyan123 is offline Member
    Join Date
    Oct 2008
    Posts
    17
    Rep Power
    0

    Default

    here' the whole stack without any deletions...

    13 Sep 08 11:01:28 ERROR [biz.autoscan.ta.clockingclient.clockingclient:RunC lientUpdater] - RunClientUpdater
    java.io.IOException: Bad file descriptor
    at java.io.FileInputStream.readBytes(Native Method)
    at java.io.FileInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at java.io.FilterInputStream.read(Unknown Source)
    at sun.nio.cs.StreamDecoder$ConverterSD.implRead(Unkn own Source)
    at sun.nio.cs.StreamDecoder.read(Unknown Source)
    at java.io.InputStreamReader.read(Unknown Source)
    at java.io.BufferedReader.fill(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    at biz.autoscan.ta.clockingclient.clockingclient.RunC lientUpdater(clockingclient.java:867)
    at biz.autoscan.ta.clockingclient.clockingclient.acce ss$1100(clockingclient.java:55)
    at biz.autoscan.ta.clockingclient.clockingclient$1.ac tionPerformed(clockingclient.java:171)
    at javax.swing.Timer.fireActionPerformed(Unknown Source)
    at javax.swing.Timer$DoPostEvent.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    hope this helps. thanks and sorry for being rude in the previous post.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Not the stack, dnyan123, the line of code that triggers the exception.

    Line 867 of clockingclient.java

    db

  9. #9
    dnyan123 is offline Member
    Join Date
    Oct 2008
    Posts
    17
    Rep Power
    0

    Default

    yes, i realize that, and the piece of code that i feel is responsible is as follows, but im not able to figure out why this happens, as it happens not always, only after a certain amount of time..

    String line;
    String query="c:\\WINNT\\system32\\tasklist.exe /FO CSV /v /nh";
    Process p = Runtime.getRuntime().exec(query);
    BufferedReader input = new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    if (!line.trim().equals("")) {
    do something
    .....
    }

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    The error message seems to say the problem is with reading a file from disk.
    The code you've posted is reading the STD output from the process.
    How are they related?

  11. #11
    dnyan123 is offline Member
    Join Date
    Oct 2008
    Posts
    17
    Rep Power
    0

    Default

    ya thats true...however, the error messages say that the exception originates from this particular method of the class..and nowhere else in the stack trace did i find any other possible origins. Also, the piece of code i put is the only place in this method that a file is read. Is there anything you can suggest that I can do for these messages? Because I really cannot find any other place where this can originate from :(

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    at biz.autoscan.ta.clockingclient.clockingclient.RunC lientUpdater(clockingclient.java:867)
    at biz.autoscan.ta.clockingclient.clockingclient.acce ss$1100(clockingclient.java:55)
    at biz.autoscan.ta.clockingclient.clockingclient$1.ac tionPerformed(clockingclient.java:171)
    These three lines of the error message give the source line numbers. You should be able to go into the source and position to those line numbers to get the source for the error.

  13. #13
    dnyan123 is offline Member
    Join Date
    Oct 2008
    Posts
    17
    Rep Power
    0

    Default

    Hi Darryl,

    the whole method is as under:-

    private static void RunClientUpdater(){
    // CreateTaskBat();
    boolean running=false;
    boolean error = false;
    logger.info("RunClientUpdater|Checking Whether the Updater is running");
    try {
    String line;
    //String query="c:\\WINNT\\system32\\tasklist.exe /FI " +"\"" + "username eq " + System.getProperty("user.name")+"\"" +" /FI " +"\"" +"imagename eq javaw.exe"+"\"" + " /FO CSV /v /nh";
    String query="c:\\WINNT\\system32\\tasklist.exe /FO CSV /v /nh";
    Process p = Runtime.getRuntime().exec(query);
    BufferedReader input = new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    if (!line.trim().equals("")) {
    // get the process id
    logger.info("RunClientUpdater|line=>"+line);

    String appname=line.substring(0,line.indexOf(","));
    appname=appname.replaceAll("\"","");
    String processid=line.substring(line.indexOf(",")+1,line. indexOf(",",line.indexOf(",")+1));
    processid=processid.replaceAll("\"","");
    String processname= line.substring(line.lastIndexOf(",")+1,line.length ());
    String user=line.substring(line.indexOf("\\")+1,line.inde xOf(",",line.indexOf("\\")+1));
    user=user.replaceAll("\"","");
    processname=processname.replaceAll("\"","");
    if((processname.length()>=3 && processname.substring(0,3).equals("N/A")) && appname.equals("javaw.exe") && user.equals(System.getProperty("user.name"))){
    logger.info("RunClientUpdater|processname=>"+proce ssname.substring(0,3));
    logger.info("RunClientUpdater|Updater is running");
    running=true;
    break;
    }

    }
    }
    p.destroy();
    input.close();
    } catch (Exception err) {
    error=true;
    logger.error("RunClientUpdater",err);
    }

    //File file=new File("task.bat");
    //file.delete();

    if(running==false && error==false){
    logger.info("RunClientUpdater|Starting Updater");
    String startApp="javaw -jar "+"\""+System.getProperty("user.dir")+"\\ECTAClien tUpdate\\ClockingClientUpdate.jar"+"\"";
    logger.info("RunClientUpdater|startApp=>"+startApp );
    try {
    String directory=System.getProperty("user.dir")+"\\ECTACl ientUpdate";
    logger.info("RunClientUpdater|directory=>"+directo ry);
    Process p = Runtime.getRuntime().exec(startApp,null,new File(directory));
    } catch (IOException ex) {
    logger.error("RunClientUpdater",ex);
    }
    }
    }

  14. #14
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Once again, and for the last time, what's on line 867?

    Use code tags to post codes and it will look like this --
    Java Code:
    CODE
    db

  15. #15
    dnyan123 is offline Member
    Join Date
    Oct 2008
    Posts
    17
    Rep Power
    0

    Default

    the stack trace is an old trace from the user. after that a lot of commented code has been removed. hence, i can't find the corresponding line number. can you let me know something from the code i gave. i went through the bug database of sun, and there was one bug associated with the class BufferReader. the close() method to be specific. So in from the code i gave,

    Code: input.close()

    i think its not closing the InputStreamReader instance and the inputstream instance while closing the bufferReader instance. Is this why there is a Bad file descriptor error?

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Sounds like you need a source management/backup program to keep your source in synch with the distributed product. If you can't look at the program that the client is executing, you'll have problems.

Similar Threads

  1. Swing Application Framework
    By jurka in forum AWT / Swing
    Replies: 0
    Last Post: 10-09-2008, 06:01 PM
  2. Stack Trace
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-10-2007, 05:29 PM
  3. EventHandling code for Swing application
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-07-2007, 12:06 PM
  4. swing application consumes much memory
    By oregon in forum AWT / Swing
    Replies: 1
    Last Post: 08-05-2007, 08:25 AM
  5. Replies: 2
    Last Post: 07-04-2007, 06:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •