(ObjectInputStream) first time it works, second time I get an error!

hi,
Using the following code I am sending a query to a server socket using a PrintWriter.println function and retrieve a vector object (results).
Client Code
     public Vector getDBResultSet(String query) throws ClientException, IOException{
          Object obj = new Object();
          if (socket != null)
               try{                    
                    System.out.println("Sending "+query+" to Server");
                    writer.println(query);
                    try{
                         ois = new ObjectInputStream(input);
                         while ((obj = ois.readObject()) != null)
                              obj = ois.readObject();
                    }catch (EOFException eofx){
                         System.out.println("EOF @ object input stream!");
                    finally{
                         ois.close();
                    return (Vector)obj;
               }catch(Exception e){
                    e.printStackTrace();
                    throw new ClientException("<html>Error: <br>"+e.toString()+"#"+e.getMessage()+"</html>");
               }finally{
                    //writer.close();
          }else throw new ClientException("no connection!");
     }Server side code
     public void communicate()
          try{          
               while (true){
                    String q = reader.readLine();
                    Vector vec = db.getResults(q);
                    oos = new ObjectOutputStream(output);
                    oos.writeObject(vec);
                    oos.flush();
                    oos.close();
          }catch(Exception e){
               e.printStackTrace();
     }First time everything goes OK.
Second time on the Client-Side I get strange errors like "ClassCastException Java.lang.Object" and if I comment out the "while" line I get a "socket closed" error...
any ideas what is wrong with it?

Thank you. input and output variables are Inputstream and outputStream objects.
However if you notice, I open the ObjectInputStream inside getDBResultSet() method. So whenever this method is called a new ObjectIputStream shall be initialized. That is why I close the ObjectInput/outputStreams right after the try/catch portion.
I tried starting the ObjectInputStream inside the connect method (which initialized the connection with the ServerSocket object) but wheneven connect() was called the GUI hanged!
I don't know what am I doing wrong...
     public void connect() throws Exception
          if (socket == null){
               try{
                    System.out.println("opening connection...to "+host+" at port "+port);
                    socket = new Socket(host, port);
                    input = socket.getInputStream();
                    output = socket.getOutputStream();
                    in = new DataInputStream(input);
                    out = new DataOutputStream(output);
                    reader = new BufferedReader(new InputStreamReader(in));
                    writer = new PrintWriter(out, true);          
                    //ois = new ObjectInputStream(input);
                    System.out.println("Connection established!");
               }catch(IOException e){
                    try{
                         if (socket != null)
                              socket.close();
                         System.out.println("ERROR WHILE CONNECTING... SOCKET IS NOW CLOSED!");
                    }catch(IOException x){
                         x.printStackTrace();
          else
               throw new ClientException("connection active!");
     }

Similar Messages

  • When starting Lightroom 5.6 for the first time I get the error message "AgPathUtils.getStandardFilePath: can't create directory at: /Users/.../Pictures" when trying to import pictures

    Today I installed Lightroom 5.6 on Mac OS 10.9.4. Photoshop Elements 11 is also installed on this computer. This Lightroom Version is the 30 day test version. My Picture folder is linked to a secondary hdd, but this worked fine with any other program so far. This error keeps me from editing / opening pictures. Any help is appreciated.

    I replaced the symlink with a folder named "Pictures" and it actually worked. At least a new menu shows up. BTW Photoshop Elements does not complain.

  • Using iPod shuffle 4th generation for first time and receiving the error : one of the USB devices attached to this computer has malfunctioned, and windows does not recognize it. For assistance in solving this problem, click this message

    Using iPod shuffle 4th generation for first time and receiving the error : one of the USB devices attached to this computer has malfunctioned, and windows does not recognize it. For assistance in solving this problem, click this message.
    Using win 7 and latest iTunes [10.6.3]. Have already gone through below links and did not find any solution.
    http://support.apple.com/kb/HT2292
    http://support.apple.com/kb/TS1369
    http://support.apple.com/kb/HT1923
    http://en.kioskea.net/forum/affich-17997-ipod-not-detected

    I was hoping it would be something like a USB device conflict, but now the shuffle is the only thing connected...
    This article was one of the ones you linked to above in your initial post
    http://support.apple.com/kb/TS1369
    Under Part 9. Verify that USB drivers are installed, did you try the steps in If only "Unknown Device" appears?  That appears to be your situation.
    Also, you said that the shuffle initially worked well enough to do a sync, then it had the same problem again.  If you can get it to work again initially, before doing anything else, try the following.  Select the shuffle in the iTunes sidebar, under DEVICES.  Over to the right, go to the Summary tab.  By default, the checkbox for Enable disk use should be unchecked.  If so, check it and Apply the change.  See if that makes any difference. 
    (If Enable disk use was already checked, try unchecking it and Apply the change.  Basically, set it the "other way" and see if there is any improvement.)
    NOTE:  When disk use is enabled, you have to eject the iPod in iTunes before disconnecting it physically.
    If the disk use change makes a difference, that may provide a clue about the actual cause.

  • When i try to use my apple acocunt for the first time i get a prompt to put in my CC info but after i agree to the TOS the ipad only displays a black box no text, ive erased the ipad and still the same thing

    When i try to use my apple acocunt for the first time i get a prompt to put in my CC info but after i agree to the TOS the ipad only displays a black box no text, ive erased the ipad and still the same thing

    1. Turn router off for 30 seconds and on again
    2. Settings>General>Reset>Reset Network Settings

  • ADF Table with check box on each row  - First time selection gets unchecked

    Hi,
        The ADF Table has a check box in each, whenever a select box is clicked for the first time , it gets unselected automatically.
    Also if I select a row / click on a row and then select the check box, it is properly getting selected. I see there is some kind of autosubmit happens. Is there a way to handle this scenerio?
    Regards,
    Dhamo

    I had this same issue happen in 11.1.1.6.x  This is a bug involving an autosubmit when the checkbox is selected.
    After migrating to 11.1.1.7.0 on J Developer and Weblogic, the problem was fixed.
    One thing to check is to make sure you are using the jars from ADF 11.1.1.7.0.
    Hope that helps

  • When connecting my iphone 4 to itunes for the first time i get the following message "cannot connect to this device because Apple Mobile Service is not started" what does this mean and how do I solve it?

    when connecting my iphone 4 to itunes for the first time i get the following message "cannot connect to this device because Apple Mobile Service is not started" what does this mean and how do I solve it?

    I'd start with the following document with that one:
    iPhone, iPad, iPod touch: How to restart the Apple Mobile Device Service (AMDS) on Windows

  • Getting error while synchronising for the first time to get Device ID

    Hi All,
    When I am trying to synchronise for the first time to get device ID I am getting following error.
    Could any body through some light on this please.
    • Synchronization started 
    • Connection set up (without proxy) to: http://XYZ:portno/meSync/servlet/meSync?~sysid=MOB& 
    • Connection to server failed. 
    • Synchronisation problems: Transport-layer (http) sync exception raised (root cause: Exception while synchronizing (java.io.IOException: Not in GZIP format)) 
    Regards,
    Ameer Baba.

    Hi,
    please let us know what patch level your middleware is running on.
    The mobileengine.config file is placed in the MI client installation directory in subfolder settings. On PC it is in
    c:\Program files\Sap Mobile Infrastructure\settings.
    From the URL you mentioned above you are using the "old" technology. Please go the service.sap.com/instguides and follow the setup guid for the old technology.
    When you enter the URL directly into the browser you should get a LOGON popup. This shows the service is running. I would expect that you do not get this popup due to missing setup.
    If you want to use the new sync service in SICF and you have configured this. have a look into the manual. In that case you are missing some settings on the MI client. The problem is, that the old MI client uses old sync service by default.
    Regards,
    Oliver

  • Having trouble with Face Time app, get following error messages

    Since having a new hard drive installed in computer my Face Time account no longer works. Everytime i try and sign into my Face Time account= get following error message
    "the server encountered an error processing registration. Please try again later.
    = when try and install the app from mac store error message says
    "A newer version of this app is already installed on this computer
    If you want to replace it with this version, move the existing app to the trash.
    BUT WHEN TRY TO DELETE APP ON COMPUTUER (AS IT IS NOT WORKING)
    Get following error message " Face Time.app" can't be modified or deleted because it is required by Mac OS X.
    have MacBook Pro
    mountain Lion
    Software OS X 10.8.3
    Hope you can assist, best wishes GG

    This could be a complicated problem to solve, as there are many possible causes for it. Test after taking each of the following steps that you haven't already tried. Back up all data before making any changes.
    Before proceeding, test on another network, if possible. That could be a public Wi-Fi hotspot, if your computer is portable, or a cellular network if you have a mobile device that can share its Internet connection. If you find that iMessage works on the other network, the problem is in your network or at your ISP, not in your computer.
    Step 1
    Check the status of the service. If the service is down, wait tor it to come back up. There may be a localized outage, even if the status indicator is green.
    Step 2
    Restart your broadband device and your router, if different. You may have to skip this step if you don't control those devices.
    Step 3
    From the menu bar, select
     ▹ About This Mac
    Below the "OS X" legend in the window that opens, the OS version appears. Click the version line twice to display the serial number. If the number is missing or obviously invalid, take the machine to an Apple Store or other authorized service center to have the problem corrected.
    Step 4
    Back up all data, then take the steps suggested in this support article.
    There are five steps in that article. Please take all of them. If you don't understand some of the steps or can't carry them out, ask for guidance.
    Step 5
    From the menu bar, select
     ▹ System Preferences ▹ Network
    If the preference pane is locked, click the lock icon in the lower left corner and enter your password to unlock it. Then click the Advanced button and select the Proxies tab. If any proxy options are selected, make a note of them and then deselect them. You don’t need to change the bypass or FTP settings. Click OK and then Apply. Test. The result may be that you can't connect to any web server. Restore the previous settings if that happens.
    Step 6
    Reset the NVRAM.
    Step 7
    Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    If iMessage worked in the guest account, stop here and post your results.
    Step 8
    Boot in safe mode and log in. Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including Wi-Fi on certain iMacs.  The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. After testing, reboot as usual (i.e., not in safe mode) and test again.
    If iMessage worked in safe mode, but didn't work when you booted out of safe mode, stop here and post your results.
    Step 9
    According to one anecdotal report, Flash Player may interfere with iMessage, though I don't know how and can't confirm. To test this theory, select from the menu bar
     ▹ System Preferences… ▹ Flash Player ▹ Storage
    and click
    Block all sites from storing information on this computer
    Close the preference pane. If this action solves the problem, please post your results.
    Step 10
    Boot into Recovery and reinstall OS X.
    Step 11
    If none of the above steps resolves the issue, make a "Genius" appointment at an Apple Store, or contact Apple  Support.

  • I have a new Ipad air. I have synced it to my PC before. This time I get an error message saying iTunes could not connect to the iPad because the device time out - what do I do?

    I have a new Ipad air. I have synced it to my PC before. This time I get an error message saying iTunes could not connect to the iPad because the device time out - what do I do?

    Quit iTunes, restart your computer, reset the iPad and try again.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • I have the new iPad and I could not use I tunes , every time I get an error says "cannot connect to itunes store " please help

    I have the new iPad and I could not use I tunes , every time I get an error says "cannot connect to itunes store " please help

    Sorry, yes iTunes on your computer.
    When I updated my iPad 3 and iPod Touch 4th generation to iOS 6 a few months back, I was able to update the iPad effortlessly over WiFi. but I kept getting error messages when trying to update the iPod over WiFi, so I used iTunes on my MacBook Pro.
    Connect the iPad to the computer, launch iTunes. Select the iPad under the devices heading on the left, click on the Summary tab and then click on Check for Update
    If you are using iTunes 11, go to View>Show Sidebar at the top - so the sidebar is visible.

  • My Time Machine / Time capsule gets the error:  The backup disk image could not be mounted

    My time machine / time capsule gets the error:  The backup disk image could not be mounted.

    Reboot the TC.
    If you normally have multiple computers backing up, under Lion there seems to be some issues.. you need to force other users off the system. You can do that through the Airport utility, manual setup, disks, disconnect all users. Note carefully if you use Lion you probably need to download the real airport utility.. 5.6 to accomplish anything useful.

  • HT5429 i m using iphone 4s . when i try to set direction that time i get one error like the map server is not available . will you help me ?

    i m using iphone 4s . when i try to set direction that time i get one error like the map server is not available . will you help me ?
    how to help this problem..?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • My adobe cloud desktop app seems to have stopped working.  I keep getting a error message saying Unable to reach adobe servers, please check firewall settings.

    My adobe cloud desktop app seems to have stopped working.  I keep getting a error message saying Unable to reach adobe servers, please check firewall settings.
    The creative cloud icon on the top menu bar is greyed out, and not updates show.
    I have spoke to our internal IT and my settings are the same as my colleagues who's is working fine, can anybody help with this ongoing problem?

    Grafix121 please ask your I.T. department to review the Adobe Creative Cloud Security FAQ for IT section of Creative Suite Enterprise Deployment | Adobe Developer Connection for information on how to configure your network to allow connections to the Adobe servers.

  • HT4489 I am attempting to import a vcard from my outlook into my icloud contacts. Exporting works fine but I get the error...could not import some contacts becaus ethere was a problem reading the vcard. Any suggestions?

    I am attempting to import a vcard from Outlook 2010 into my iCloud. Exporting to Outlook works fine but I get an error ..could not be imported there was a problem reading the vcard. Any suggestions?

    bmitch3 wrote:
    I am attempting to import a vcard from Outlook 2010 into my iCloud. Exporting to Outlook works fine but I get an error .
    You mean exporting from Outlook surely, what exactly are you you importing to?

  • Using wall charger for first time I get error message "charging not supported by this accessory."  Been using since December and not seen this before.

    Using wall charger and am now getting error message "charging not supported by this accessory."  Have been using since December and this is first time I have encountered this.

    Did you look to see if there is debris or dust causing the problem? Get a flashlight and take a look to make sure.
    Is there something in the USB end of the cord perhaps?
    You didn't answer this question ....Are you using the charger and cord that came with your iPad?
    You could try changing cords if you have another one available to see if it is the cord. Have you tried connecting to your computer to see if you get the same message?
    You could try a hard reset by holding down on the sleep and home buttons at the same time for about 10 seconds until the Apple logo appears, let go of the buttons and let the iPad restart. Then try the charger again.

Maybe you are looking for

  • Ip_local_port_range - what are the right range

    Hi all, we got a little 'problem' Currently the range for the dynamic TCP/IP port allocation in our FlexFrame LINUX systems is from 9000 to 65500 (LINUX kernel parameter ip_local_port_range). That means, the pre-defined ports for sapstartsrv (5<inst>

  • How do  I get music in playlists to show up in the Library again?

    I recently accidentally changed the info on some music along with an audiobook. The original change changed them all to audiobook media type, one title, one author, etc. I have changed the info back on all of them but now a large number of the songs

  • Jasper Report  Integration Examples

    Hi Can any one of you send examples/source/link that shows how to implement jasper report in JAVA .I tried it in google.but i won't wrok. A simple and detailed example that shows finally how a PDF is generated

  • Show movement in area from 30m video, smart objects - stack mode - range - 90k frames

    Hey, So I have a real challenge and need help figuring out the logistics of how to get it to work sensibly. I'm trying to visually show the movement through a space (which will later be generated into a 3d form etc..) To do this I think the best way

  • How do I find out if my iphone is locked to a network or not?

    I have an iphone 5 which is on 3network, I need to find out if it is locked to that network or not, I would like it to be opened up to any network as I am going abroad next month and would like to put a local SIM card in while I am away