Results 1 to 7 of 7
  1. #1
    80mins is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default Help with a project

    Hey there I am having trouble with my project,
    and now as I am overdue Im asking for help.

    My project is sending a unusual amount of nullpointerexceptions.
    I know what these exceptions are, I just have no idea how to find them.

    I am ready to give up but as this is the last hurdle before I can graduate I wish to finish what
    I have started.

    I dont know how to upload my project to this site. but if anybody can spear some time
    to help me. I can email them a copy of the project.

    Cheers julian.

    juliancassidy@hotmail.com

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    There will be a stack trace with your exceptions.
    That stack trace will point you to the line of code that is throwing the exception.
    If you aren't getting a stack trace then it is probably because you are doing something like:
    Java Code:
    catch (Exception e) {
        System.out.println(e.getMessage());
    }
    instead of:
    Java Code:
    catch (Exception e) {
        e.printStackTrace();
    }

  3. #3
    80mins is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default

    hey Tolls I have done what you sujested.

    but as i am only newish to java I dont understand how to read the output.

    I get this when trying to delete a field.

    run:
    Running ok
    Sent location to propertiesC:\Users\Julian Cassidy\Desktop\db-2x2.db
    Error in findRecord java.io.EOFException
    Error in getFileRecords java.lang.NullPointerException
    Error connect in ClientSocketjava.net.ConnectException: Connection refused: connect
    sending data over sockets
    Error connect in ClientSocketjava.net.ConnectException: Connection refused: connect
    java.lang.NullPointerException
    Error send in ClientSocket java.lang.NullPointerException
    at sjdsuncertify.Socket.ClientSocket.send(ClientSocke t.java:303)
    at sjdsuncertify.Socket.ClientSocket.lock(ClientSocke t.java:212)
    at sjdsuncertify.GUI.MainGUI.btnDeleteActionPerformed (MainGUI.java:434)
    at sjdsuncertify.GUI.MainGUI.access$400(MainGUI.java: 23)
    at sjdsuncertify.GUI.MainGUI$5.actionPerformed(MainGU I.java:198)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.jav a:6267)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
    at java.awt.Component.processEvent(Component.java:603 2)
    at java.awt.Container.processEvent(Container.java:204 1)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4630)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2099)
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4577)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478 )
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    Error disconnect in ClientSOcketjava.lang.NullPointerException
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
    Error lock in ClientSocket java.lang.NullPointerException
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
    java.lang.NullPointerException
    at sjdsuncertify.Socket.ClientSocket.lock(ClientSocke t.java:212)
    at sjdsuncertify.GUI.MainGUI.btnDeleteActionPerformed (MainGUI.java:434)
    at sjdsuncertify.GUI.MainGUI.access$400(MainGUI.java: 23)
    at sjdsuncertify.GUI.MainGUI$5.actionPerformed(MainGU I.java:198)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.jav a:6267)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
    at java.awt.Component.processEvent(Component.java:603 2)
    at java.awt.Container.processEvent(Container.java:204 1)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4630)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2099)
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4577)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478 )
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
    sending data over sockets
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
    Error connect in ClientSocketjava.net.ConnectException: Connection refused: connect
    java.lang.NullPointerException
    Error send in ClientSocket java.lang.NullPointerException
    at sjdsuncertify.Socket.ClientSocket.send(ClientSocke t.java:303)
    at sjdsuncertify.Socket.ClientSocket.delete(ClientSoc ket.java:145)
    at sjdsuncertify.GUI.MainGUI.btnDeleteActionPerformed (MainGUI.java:434)
    at sjdsuncertify.GUI.MainGUI.access$400(MainGUI.java: 23)
    at sjdsuncertify.GUI.MainGUI$5.actionPerformed(MainGU I.java:198)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.jav a:6267)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
    at java.awt.Component.processEvent(Component.java:603 2)
    at java.awt.Container.processEvent(Container.java:204 1)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4630)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2099)
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4577)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478 )
    at java.awt.Component.dispatchEvent(Component.java:44 60)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599Error disconnect in ClientSOcketjava.lang.NullPointerException
    )
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
    Error in findRecord java.io.EOFException
    Error in getFileRecords java.lang.NullPointerException

    I do realise that this could be because my laptop wont let me run the socket on the one computer.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Error send in ClientSocket java.lang.NullPointerException
    at sjdsuncertify.Socket.ClientSocket.send(ClientSocke t.java:303)

    Somethign on that line is null.

    Considering prior to this you have:
    Error connect in ClientSocketjava.net.ConnectException: Connection refused: connect

    I'm guessing it's your connection object.

  5. #5
    80mins is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default

    i am currently trying to run it on another computer.

  6. #6
    80mins is offline Member
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default

    after looking more into this problem.

    I have descovered the reason for everything starts with my find record method. which is throwing a EOFException. on line 7.

    Java Code:
     private Record findRecord(long locationInFile, RandomAccessFile raf)
        throws IOException{
           final byte[] input = new byte[Record.TOTAL_LENGTH];
    
           Record returned = null;
    
           try{
               
               raf.seek(locationInFile);
               System.out.println("input = " + input);
               raf.readFully(input);
               
               
               
               
                  
           class InputReader{
               private int offset = 0;
               
               String read(int length) throws UnsupportedEncodingException{
                   String newString = new String(input, offset, length);
                   
                   offset += length;
                   return newString.trim();
               }
           }
               InputReader inputReader = new InputReader();
    
               String name = inputReader.read(Record.LENGTH_NAME);
               String location = inputReader.read(Record.LENGTH_LOCATION);
               String specialties = inputReader.read(Record.LENGTH_SPECIALTIES);
               int size = Integer.parseInt(inputReader.read(Record.LENGTH_SIZE));
               String rate = inputReader.read(Record.LENGTH_RATE);
               String owner = inputReader.read(Record.LENGTH_OWNER);
               
           
               returned  = new Record(recNo, name, location, specialties, size,
                           rate, owner);
           }
           catch(Exception ex){
               System.out.println("Error in findRecord  " + ex.toString());
               System.out.println("location in file: " + locationInFile);
               System.out.println("input = " + input);
           }
               return returned;
       }
    I need a way to tell the computer that it should stop reading as the database is at the end of the file.

    the output of this code is.


    Java Code:
    run:
    Running ok
    Sent location to propertiesC:\Users\Julian Cassidy\Desktop\db-2x2.db
    input = [B@148cc8c
    input = [B@152544e
    input = [B@1cdeff
    input = [B@17471e0
    input = [B@1e04cbf
    input = [B@cec0c5
    input = [B@1d2068d
    input = [B@1ac2f9c
    input = [B@169ca65
    input = [B@66e815
    input = [B@ece65
    input = [B@106082
    input = [B@1301ed8
    input = [B@3901c6
    input = [B@a37368
    input = [B@edc3a2
    input = [B@1c6f579
    input = [B@11ddcde
    input = [B@18fb1f7
    input = [B@ed0338
    input = [B@6e70c7
    input = [B@ae506e
    input = [B@228a02
    input = [B@192b996
    input = [B@1d63e39
    input = [B@8f4fb3
    input = [B@b988a6
    input = [B@ba6c83
    input = [B@12a1e44
    Error in findRecord  java.io.EOFException
    location in file: 5221
    input = [B@12a1e44
    Error in getFileRecords java.lang.NullPointerException
    Error connect in ClientSocketjava.net.ConnectException: Connection refused: connect
    BUILD SUCCESSFUL (total time: 19 seconds)
    So my question is,
    is there a way to tell the computer to stop trying to read when it reaches the end of file.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Print stack traces!
    Java Code:
           catch(Exception ex){
               System.out.println("Error in findRecord  " + ex.toString());
               System.out.println("location in file: " + locationInFile);
               System.out.println("input = " + input);
           }
    This is losing you so much information.
    Like where this is being thrown from.

    And when you know that then you can highlight the line for us.

Similar Threads

  1. Need help with my project..
    By secretsau in forum Jobs Offered
    Replies: 1
    Last Post: 11-23-2010, 12:40 PM
  2. Adding a project to an existing project
    By Seijuro in forum NetBeans
    Replies: 4
    Last Post: 08-08-2010, 11:15 AM
  3. open existing project project ..
    By itaipee in forum Eclipse
    Replies: 1
    Last Post: 12-28-2008, 09:12 PM
  4. Need Help With Project
    By maggie_2 in forum New To Java
    Replies: 1
    Last Post: 12-02-2008, 09:24 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
  •