Sending HashMap over network

hi there,
Is there any way I can get around this HashMap bug?
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4756277
I tried to write a HashMap object over a network and the following exception was generated:
java.io.NotSerializableException: java.util.HashMap$EntrySet
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
Regards,

Due to this bug you can't use serialization mechanism on HashMap. A workaround should be to implement a SerializedHashMap class which extends HashMap and reimplement method for serialization. Methods to reimplement are:private void writeObject (java.io.ObjectOutputStream out) throws IOException;and
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;You can found useful tips of about write your code here: java.sun.com/docs/books/tutorial/essential/io/objectstreams.html

Similar Messages

  • Urgent help:send image over network using rmi

    hi all,
    i have few question about send image using rmi.
    1) should i use ByteArrayOutputStream to convert image into byte array before i send over network or just use fileinputstream to convert image into byte array like what i have done as below?
    public class RemoteServerImpl  extends UnicastRemoteObject implements RemoteServer
      public RemoteServerImpl() throws RemoteException
      public byte[] getimage() throws RemoteException
        try{
           // capture the whole screen
           BufferedImage screencapture = new Robot().createScreenCapture(new     Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );
           // Save as JPEG
           File file = new File("screencapture.jpg");
           ImageIO.write(screencapture, "jpg", file);
            byte[] fileByteContent = null;
           fileByteContent = getImageStream("screencapture.jpg");
           return fileByteContent;
        catch(IOException ex)
      public byte[] getImageStream(String fname) // local method
        String fileName = fname;
        FileInputStream fileInputStream = null;
        byte[] fileByteContent = null;
          try
            int count = 0;
            fileInputStream = new FileInputStream(fileName);  // Obtains input bytes from a file.
            fileByteContent = new byte[fileInputStream.available()]; // Assign size to byte array.
            while (fileInputStream.available()>0)   // Correcting file content bytes, and put them into the byte array.
               fileByteContent[count]=(byte)fileInputStream.read();
               count++;
           catch (IOException fnfe)
         return fileByteContent;           
    }2)if what i done is wrong,can somebody give me guide?else if correct ,then how can i rebuild the image from the byte array and put it in a JLable?i now must use FileOuputStream but how?can anyone answer me or simple code?
    thanks in advance..

    Hi! well a had the same problem sending an image trough RMI.. To solve this i just read the image file into a byte Array and send the array to the client, and then the client creates an imegeIcon from the byte Array containing the image.. Below is the example function ton read the file to a byte Array (on the server) and the function to convert it to a an imageIcon (on the client).
    //      Returns the contents of the file in a byte array.
        public static byte[] getBytesFromFile(File file) throws IOException {
            InputStream is = new FileInputStream(file);
            // Get the size of the file
            long length = file.length();
            // You cannot create an array using a long type.
            // It needs to be an int type.
            // Before converting to an int type, check
            // to ensure that file is not larger than Integer.MAX_VALUE.
            if (length > Integer.MAX_VALUE) {
                // File is too large
            // Create the byte array to hold the data
            byte[] bytes = new byte[(int)length];
            // Read in the bytes
            int offset = 0;
            int numRead = 0;
            while (offset < bytes.length
                   && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                offset += numRead;
            // Ensure all the bytes have been read in
            if (offset < bytes.length) {
                throw new IOException("Could not completely read file "+file.getName());
            // Close the input stream and return bytes
            is.close();
            return bytes;
        }to use this function simply use something like this
    public byte[] getImage(){
    byte[] imageData;
              File file = new File("pic.jpg");
              // Change pic.jpg for the name of your file (duh)
              try{
                   imageData = getBytesFromFile(file);
                   // Send to client via RMI
                            return imageData;
              }catch(IOException ioe){
                           // Handle exception
                           return null; // or whatever you want..
    }and then on the client you could call a function like this
    public ImageIcon getImageFromServer(){
         try{
              // get the image from the RMI server
              byte[] imgBytes = myServerObject.getImage();
              // Create an imageIcon from the Array of bytes
              ImageIcon ii = new ImageIcon(imgBytes);
              return ii;
         }catch(Exception e){
              // Handle some error..
              // If yo get here probably something went wrong with the server
              // like File Not Found or something like that..
              e.printStackTrace();
              return null;
    }Hope it helps you..

  • Sending images over network socket

    I'm working on a java web server. So far i have managed to get it to send html documents sucessfully to the client web browser, using a BufferedReader, and a PrintWriter object.
    But how should i send images over the socket? using this method doesn't work. Any suggestions?
    Thanks in advance.
    hornetau

    I did it first. You may pay me $10 and get XM2 WebServer 1.2 from my company.
    Ok, I'll help ya out here...
    HTTP protocol in Internet Explorer is "juiced up" meaning that it does not require HTTP data to be correctly sent. To send an image to be deisplayed...
    <html>
    <img src="theImage.gif"></img>
    </html>
    Now, the server will see a GET request like this...
    GET /theImage.gif HTTP/1.1
    Accepts: Image/jpeg, Image/gif, ...
    Your web server (in the IE case just needs to send)...
    output.println(data);
    The data object is a string, that represents the contents of the image.
    To do that, just get the correct File object, connect reader to it, then loop it
    until the reader is no longer ready (reader.ready() != true), as it loops, just append
    the readLine() command to the end of the data string and it will be ok.
    Now this works on IE just fine, using vary small file sizes due to it being loaded directly into
    memory. Casing problem if your app has only 500K of memory and the file size is 700K, 500-700=-200K, so use only small file sizes with this method.
    There is also the URLConnection and HttpURLConnection classes to use that will do this better, but
    they dont have any real way of getting the file's data - that's still YOUR job.

  • Problem with sending message over network

    ssc = (ServerSocketConnection) Connector.open("socket://:5000");
    sc = (SocketConnection) Connector.open("socket://localhost:5000");my app works over the network in the emulator, but wont work on real devices, or do i just need to pair somehow with the device before i start.
    are the above lines okay is it meant to be localhost that's what they use in the socket part of the network demo that comes with the wireless toolkit, anyone have any ideas why that app doesnt seem to work for me on the real devices.
    i know for bluetooth you have to pair with the device before running the application do you have to do something like this

    Vishal,
    Couple of questions. 
    How are you sending this message.  Is it a message that you create and send Internally with an attachment.
    As you reply me, please also check if the <b>Attachments folder</b> has been set under <b>Administration > System Initialization > General Settings.....Path Tab</b>
    SBO tries to copy the attachment from the location you select to the Path defined for Attachments.
    Let me know
    Suda

  • Client/server - sending ArrayList over network

    Hi all
    I have have written a multithreaded client/server application where multiple clients connect to the server. For each client, the server spawns a new thread to handle the connected client. When a client connects to the server, the client sends its name to the server. The server stores the name in an ArrayList and sends the whole ArrayList to all the connected clients.
    It worked fine a few days ago. But now I have a problem: When I send the ArrayList to all the connected clients then only the newly connected client gets the updated ArrayList while the previously connected clients get the ArrayList that they got previously i.e. they are not updated. If instead of sending an ArrayList, I just send the name of the newly connected client to all other connected clients then it works i.e. each client gets updated with that name. It also works fine if I just send an Integer value to all the clients upon a new connection.
    I know the ArrayList implements Serializable, but I dont know how it doesnt work anymore!
    Plz help me with this. I have been trying all combinations, but no luck so far.
    thank you
    taurean

    thank you jwentling
    to make sure that we are on the same page, here is the relevant code.
    This method updates the list of the peers' names on the Gui (that extends JFrame).
    public void update(final ArrayList dataPacket)
              SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        setTitle(dataPacket.toString());
                        peerList.setListData(dataPacket.toArray());
                        peerList.updateUI();
         }This inner class continuously listens to server to get the arraylist that contains the names of the other peers/clients that are connected.
    The con varibale is the Connection where I obtain input/output streams for this client.
    Note: con.getInputStream() returns ObjectInputStream.
         private class Listener implements Runnable
              public void run()
                   while(true)
                        ArrayList dataPacket = (ArrayList) Receiver.receiveObject(con.getInputStream());
                        if (dataPacket != null)
                             update(dataPacket);
         }Here is how the static receiveObject() metod looks like:
    public static Object receiveObject(ObjectInputStream stream)
              Object obj = null;
              try
                   obj = stream.readObject();
              catch(ClassNotFoundException cnfe)
                   System.out.println(cnfe.getMessage());
              catch(IOException ioe)
                   System.out.println(ioe.getMessage());
              return obj;
         }i think that the receiveObject() method should return the updated list (sent from server), but i get the previoulsy sent list fromt his method!!!
    Has it to do something with the stream? I mean could it be that the list is still in the stream (as you pointed out) and instead of the updated list, i just get the one from the stream that i got initially?!
    thank you for ur time

  • BBM over network. STILL DOWN

    When sending BBM over network (EE uk) all I have is a red clock. This has been doing this since Monday last week. Come on BB sort yourselves out. EE say they have raised loads of tickets re this issue. its not just ee. over other networks as well it would seem. 
    BB Europe say they have not got an issues at present. 
    Who is telling the truth? 

    I've been chatting off and on all week with friends in Europe, first I've heard of any anthing being down.
    Do a simple reboot on the BlackBerry in this manner: With the BlackBerry device POWERED ON, remove the battery for a minute, and then reinsert the battery to reboot. A reboot in this manner is prescribed for most glitches and operating system errors, and you will lose no data on the device doing this.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Sending Video over the wireless network

    I am considering capturing images from a IEEE 1394 camera and sending it over the Wireless network to another computer.  The reason we want to do that is to make the
    camera device light and portable by connecting it to a portable tablet computer.
    What kind of protocol is the best way to transfer the image. The TCP or UDP in labview convert data into string before the transmission which are very inefficient. I just want to streaming the raw image data, maybe with some protocol overhead.  Did National Instrument has any package to do that or any other software packages available?
    There might be another solution is to use the Ethernet cameras instead of 1394 cameras.
    Would it be possible for the Labview application on a remote desktop computer to acquire the Ethernet camera over a WiFi wireless connnetction in between ?
    Thanks
    Cindy

    Hello Cindy,
    If you want to transfer data across a
    network, TCP would be the most efficient method (wireless is typically not as
    successful as Ethernet due to the overhead).  There is actually a very useful knowledgebase
    document that discusses the various methods used to transfer image data across
    a network.  If you go to our main site http://www.ni.com and search using the keywords “Images
    Over Network”, the first link is entitled Streaming
    IMAQ Images Over a Network (or Internet) which gives brief descriptions if
    you choose to use TCP/IP, Datasocket, LabVIEW web server, or ActiveX.  Another very informative document results in
    that same search and is titled Transfer Images Over the Network
    which actually gives examples
    illustrating different ways to send images.  I hope this helps.  Please let us know if you would like further
    clarification or assistance regarding this issue.Vu D

  • I cannot send email over 3G. Receiving email is ok. Using wifi from my landfibre allows me to send email. No idea where to find the solution. Suggestions please. Thanks ia

    I cannot send email over 3G. receiving email over 3G is ok. Using wifi from my landline (glass) is ok. No idea where to find the solution. Suggestions please. Thanks i.a.
    TheOne

    You need a DATA service enabled by your carrier to be able to send e-mail via thier network.  Do you have a data plan with your carrier ?  If so - is it enabled ?
    Can you access internet thru your network (not wifi) ?

  • Why is my iPhone 5 sending data over cellular while on wifi using Vodafone Germany?

    Hello,
    I know that this is a common mistake on verizon iphone 5. i have the same problem with my iPhone 5 in Germany. It keeps sending data over cellular while I am on wifi. The wifi connection itself works though, even when I turn off cellular data. So my wifi is not broken.
    Another thing that makes me curious is that my iPhone keeps sending data to somewhere and I don't know what it is sending. This led to the point that I reached my Monthly limit of 200mb within 2 days!!! And almost 95% of that was upstream. So I bought another 300mb and turned off cellular. Now I turned it back on and the megabytes are just running through. I thought it might be diagnosis and iCloud but I turned both off and it's still the Same way. Due to the enormous amount of data that is being sent the battery empties really really fast!! I was on a 20 minute car drive and my battery went down 23%!!! When I turn cellular off and use wifi it behaves completely normal.
    So this is really annoying me and I hope that Apple will fix this or one of you guys can help me.
    Best regards from Germany,
    Sitham

    You may have a problem with your WiFi network if your iPhone can't stay connected to it.
    If you are having WiFi problems it is necessary to isolate whether the problem is with your network or your iPhone. Note: Do NOT consider your network to be blameless if some other devices can connect to it.
    First, test your iPhone on some other networks: a friend's, Starbucks, Barnes & Noble, etc.
    If it works well there then the problem is with your network. Try restarting your router by removing power for 30 seconds. If that does not help check for a firmware update for your router. If none exists which corrects the problem consider replacing the router.
    If your iPhone does not function well on other networks it possibly has a hardware problem. Contact Apple Support or visit an Apple store for evaluation. They can provide a replacement if your iPhone is bad.
    If you need more help please give the make, model, and version of your WiFi router and how you have it configured.

  • Problem sending mail over GPRS/EDGE

    problem sending mail over GPRS/EDGE
    i am in thailand right now with my iPhone 3G 16 GB (italian, no SIM-lock, 2.2). my problem: the iPhone does not send emails via GPRS/EDGE of local AIS mobile provider (there is no 3G in thailand right now). each time i try, i will get a prompt saying 'cannot send mail, the connection to the outgoing server "mail.gmx.net" failed'.
    in germany, i use a contract SIM from o2, in thailand a prepaid SIM from AIS. i have configured 2 german pop mail accounts on my phone (gmx.de, o2online.de). receiving and sending email work fine on WLAN (everywhere, also here in thailand) and in germany on 3G/EDGE/GPRS. internet works everywhere, too. so, configuration seems to be okay. for each account, i use the same (smtp) sending server for all networks (ie i do not change configurations, using mail.gmx.net and pop.o2online.de). for a test, i changed smtp server to the AIS proprietary server mail.cscoms.com, but no change in behaviour.
    so, any ideas how i can get my iPhone to not only receive but also send emails via GPRS of AIS?
    thank you!

    ok. i found the solution.
    The problem is not in the iphone, the problem was DNS resolution in the server side.

  • Sending File Over Serial PORT

    Hi,
    I'm able to read/write data over serial port using Java Comm APIs in Linux.
    Can anybody please tell me how to write/read a file over Serial port?
    Is it similar to sending a file over network?
    An early response is appreciated...

    Same stream I/O as used over the port works from a file. Dead simple.
    Also dead slow. If you want to do large amounts of data, use a RandomAccessFile and read a big chunk at a time into a byte array. Then send the byte array.

  • Remotely extend AWT over network protocol?

    Hello, I am planning a highly interactive web-oriented application (a control panel). I have considered implementing it with pure HTML+JSP, possibly with some AJAX, but I don't really have the time to learn the AJAX toolkits out there, not does it seem fully worth it for this app.
    The best solution would be to use a Java Applet, since it's easy to build a GUI in today's IDEs, and it integrates well with what I know. The problem is, this application must access an SQL database and possibly some other "private" classes that I don't want anyone snooping in. I could learn how to manaully send data over the HTTP connection from the applet, maybe even using tricks to asychronously perform this, but things become a bit confusing, and hard to scale.
    What I'd like to be able to do is take an existing solution, hopefully open-source, and use it to extend an AWT/Swing interface, hopefully via an HTTP connection (for HTTP proxy/firewall's sake, if there is one), which simply renders the AWT interface on the client's end, but sends back events to the server. This way, it'd be transparent and convient. The client would get a GUI to use, but would be unable to sneak into classfiles in attempt to exploit the application. The app would essentially run on the server, but be rendered to the client in an applet (it'd be so seamless you could do it with any AWT-based app).
    It'd be nice if I could specify code/classes to work client-side (i.e. "business logic"), to lower some networking load, but I may be getting a bit too wishful.
    I am prepared to implement this myself, but I know a more robust and feature-rich AWT-stand-in API must already exist!
    Thanks for any help you can provide!

    I've been googling like crazy and sadly I've only come to two examples of what I'm talking about...but...
    1) "RAWT - Remote AWT" - http://www.vm.ibm.com/java/rawt.html#terms - This is an old IBM project that is no longer supported. It appears to have been designed for a specific server series, but the binaries are nowhere to be found anyway. It basically replaced the standard AWT classes with it's own to extend the GUI to a remote client.
    2) This is more of an example that what I really need ( http://www.bmsi.com/tuipeer/ ) - it renders an AWT interface simply as text (put simply), in order to be compatible with older terminal systems. If I were crazy, I could throw this in with an SSH or telnet connection and have quite an archaic looking GUI, but I certainly wouldn't want to do that!

  • Can not send mail over Edge

    My boss has an original iPhone and I am constantly having problems keeping his e-mail functioning properly.
    The latest issue is he can not send e-mail over the Edge network. I visited the AT&T support page, and they say to contact Apple for support.
    Here is the message I get when attempting to send mail:
    "Cannot send mail. One of the recipient addresses was invalid."
    It is a POP account that works fine when sending mail over a wi-fi network. I have our smtp settings for our pop mail entered in his account as the main smtp server. There is also an additional server named AT&T SMTP Server.
    When trying to send mail over the Edge network, I turn off the wi-fi access to force it to use the AT&T smtp server (cwmx.com) and every time I get the above error message.
    I have another boss here with an identical iPhone and email settings that has no issues. The problem phone was brought to the local Apple Store and had the sim chip replaced, other than that they have no idea what is wrong.

    My boss has an original iPhone and I am constantly having problems keeping his e-mail functioning properly.
    The latest issue is he can not send e-mail over the Edge network. I visited the AT&T support page, and they say to contact Apple for support.
    Here is the message I get when attempting to send mail:
    "Cannot send mail. One of the recipient addresses was invalid."
    It is a POP account that works fine when sending mail over a wi-fi network. I have our smtp settings for our pop mail entered in his account as the main smtp server. There is also an additional server named AT&T SMTP Server.
    When trying to send mail over the Edge network, I turn off the wi-fi access to force it to use the AT&T smtp server (cwmx.com) and every time I get the above error message.
    I have another boss here with an identical iPhone and email settings that has no issues. The problem phone was brought to the local Apple Store and had the sim chip replaced, other than that they have no idea what is wrong.

  • Can't send email over wi fi

    I am not able to send email over the wi fi connection. I recieve it but can't respond or send an email that I compose. Also, I do not get the option to send from the general message folder even though it allows me to compose or reply from that location. I tried to get into the setup menu to check my email settings but it won't let me in there without connection to a mobil network, and I live in a dead spot, so the wi fi is critical. Do I have to go find a mobil connection to access these settings?

    I'm glad you got it sorted. There may have been another option, though...see this page:
    http://na.blackberry.com/eng/support/blackberry101/setup.jsp#tab_tab_email
    If your carrier makes their BIS available via a website, then you could have logged into it via PC/Browser and done the configuration. The downside of that is that you must create credentials for your BIS account to use that pathway -- and then also use them on the BB BIS interface...but it has a "remember me" box so you'd only have to enter them once. Plus, it is also possible that you'd still have to use your BB BIS interface to create the BIS credentials...hard to say for sure.
    Now that you have it resolved, you should check out if your carrier presents BIS via a website...then you could do things with it when you are at home and out of their OTA signal area.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Hi, does anyone know why I cant send email over 3g but can over wi-fi.  My provider is ntlworld

    Hi, does anyone know why I cant send email over 3g but can over wi-fi.  My provider is ntlworld.  As soon as I get home and connect to wi-fi the mail sends no problem

    We use ntlworld as our home broadband provider and main email address.  In my experience ntl doesn't usually allow sending of email except on its own network which is why yours works at home.  My iPhone is set up to send my ntl email using my second email account's smtp setting (in my case is is a mac.com account and I haven't found any network this doesn't work on  to send email). 
    So my advice is to get yourself another email account with a different provider like yahoo or google, then use the new provider smtp address to send your ntl email on your iPhone.

Maybe you are looking for

  • Sending the key with Socket

    Hello! I have made an application that encrypts a byte[], sends it to a server. And after that i am trying to decrypt it. But that gives me problem. The exception i get is: BadPaddingException: javax.crypto.BadPaddingException: Given final block not

  • JVM heap parameter setting...

    hi body we have two HP machine. and each machine hardware configration is :  8  CPU  and  40G memory software environment: 1. system sofeware :  HP-UX 11.31  64bit 2. NetWeaver 7.0 (2004s) 3. HP JDK 1.4.2 64bit in machine one, also host one ,  the  M

  • Getting Disk Utility to copy a DVD

    I created a DVD copy of a laserdisk on DVD+RW, and it works. I wanted to use my Mac to copy it to a DVD-R for my permanent backup, so I connected my Mad Dog USB drive to my iMac, put in a brand new DVD-R blank in it, and put my movie into my iMac's d

  • How do I move photo files and keep them connected in Elements 12

    I have filled up the C drive in my PC with about 8,000 photo files.  I have installed a second hard drive in my PC and want to move all of my photo files to what is now drive F.  How do I do this while ensuring that the files remain connected to the

  • TNsNAMES.ORA

    Dear All, I am a new user of sql devloper.I have a tnsnames.ora which regularly updates the ip of the database. How can i set the file to sql devloper. Regards Rajat