Results 1 to 2 of 2
  1. #1
    cajunthomas is offline Member
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Default ObjectOutputStream & ObjectInputStreams - null trouble

    I have two apps that work in conjunction with one another. One is a "server" type app that does not have any GUI interface and handles queries to a database and processes requests from a client. The other is a "client" that is primarily a GUI and is for users to interact with database information in a structured manner.

    ISSUE / TROUBLE / HELP NEEDED WITH


    The problem that I am having is that I can send one Object (a String[]) to the server successfully and with no problems. Client app sends it, Server app receives it an processes it successfully.

    If I try and send a second String[], the the client compiles the array and thinks it gets sent, but the server never receives is (gets only null) and produces a IOException.

    This is even with Arrays that contain the exact same number of positions and the exact same text in the exact same format and positions.

    The error produced by the printStackTrace() is:

    Java Code:
    Java.io.OptionalDataException
    at java.io.ObjectInputStream.readObject0 (ObjectInputStream.java:1367)
    at java.io.ObjectInputStream.readObject (ObjectInputStream.java:369)
    at server.ConnectionThread.processClientRequests(ConnectionThread:204)
    at server.ConnectionThread.processClientRequests(ConnectionThread:50)
    at javalang.Thread.run(Thread.java:722)
    The code at line 204 that is the point where the ObjectStream is being read from:

    Java Code:
    String[] addArray = (String[]) ois.readObject();
    ois is an ObjectInputStream and is initialized as follows:

    Java Code:
    private ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
    CLIENT CODE

    The client code used to send these objects TO the server app is:

    Java Code:
    ObjectToServer.writeObject(String[] var);
    ObjectToServer.flush();
    ObjectToServer.reset();
    COMMENTS

    What does NOT make sense to me is that this exact same code format is used to successfully send a number of String[] over the objectOutputStream from the SERVER to the CLIENT app without ever sending a "null"

    I have Google searched this and all to absolute no avail.

    Someone please help if you can!!

  2. #2
    cajunthomas is offline Member
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

Similar Threads

  1. ObjectInputStream not the same as ObjectOutputStream
    By L19htn1n9 in forum Advanced Java
    Replies: 9
    Last Post: 06-27-2012, 07:36 PM
  2. trouble with actionlistener and null pointer exception.
    By flamewolf393 in forum New To Java
    Replies: 1
    Last Post: 04-04-2012, 02:13 AM
  3. ResultSet through ObjectOutputStream
    By FlyNn in forum Advanced Java
    Replies: 4
    Last Post: 03-07-2011, 08:16 PM
  4. Replies: 17
    Last Post: 10-14-2010, 11:26 PM
  5. ObjectOutputStream Example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-20-2008, 10:21 AM

Tags for this Thread

Posting Permissions

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