BlazeDS serialization question

I recently came into a situation when sending a nested object from Java to Flex via a HashMap the Objects were null. More precisely:
final Map<Integer, List<String>> tempMap = new HashMap<Integer, List<String>>();
would send the keys as integers but the values were all null.
But when sending the same with String keys:
final Map<String, List<String>> tempMap = new HashMap<String, List<String>>();
the objects came thru.
Are there any restrictions in BlazeDS serialization when using complex types as keys?

Just in case anyone is still looking for an answer to this issue, I just ran into the same problem.  During my investigation, I learned that BlazeDS serialization is expecting only String key values for Map objects.   Since the Map coming in has Integer keys, the key is changed to a string by the serialization.  At that point, the value cannot be obtained and serialized.  Change the Integer key to a String and it works.  Here is the site that helped me get it working.
http://agricola-online.blogspot.com/2010/01/hibernate-blazeds-java-5-enum-and-flex.html

Similar Messages

  • BlazeDS feature question!

    hi, i have a bit of a friendly bet going with my manager. He insists that BlazeDS offers such features as:
    1-paging
    2-data synchronization (specifically, live updates of underlying database in Flex components)
    he  insists that because Flash Builder facilitates linking data services in  the GUI that this must mean it is through BlazeDS, not LiveCycle  Services, since the latter costs money. I think that these services are  ONLY offered through LiveCycle.
    Can anyone prove this  DEFINITIVELY either way? Any good pages to show me either way? I showed  him the feature comparison chart, but he doesn't seem to think that is  definitive.
    Help me win this bet! i'm SURE i'm right!

    Just in case anyone is still looking for an answer to this issue, I just ran into the same problem.  During my investigation, I learned that BlazeDS serialization is expecting only String key values for Map objects.   Since the Map coming in has Integer keys, the key is changed to a string by the serialization.  At that point, the value cannot be obtained and serialized.  Change the Integer key to a String and it works.  Here is the site that helped me get it working.
    http://agricola-online.blogspot.com/2010/01/hibernate-blazeds-java-5-enum-and-flex.html

  • File Serializable question

    hi,
    i know i've seen plenty of posts asking how to transfer files, my question is why doesn't simplying sending a file object from the client to the server work, file just implement Serializable? is it because the contents don't travel with the object? i'm pretty sure the object will go across, via socket programming or rmi, but why not the contents, or will they?
    Thank you.

    Because the file object, to the best of my knowledge,
    does not hold the contents, it just contains
    information about the file, such as its path.Very true. I never thought about it in this depth before, but the [url http://java.sun.com/j2se/1.4.1/docs/api/java/io/File.html]API says:
    "An abstract representation of file and directory pathnames."
    That's all it is, a representation, not an actualy file.
    Cheers,
    Radish21

  • Serialization question: can't write an object

    this may be a simple question but I do need to find out what's wrong with the object I am trying to serialize:
    The method (included) I use to write object works fine for some simple objects but stops without giving any message for some complex objects. It stops at "out.writeObject(obj)". Is there any other exceptions need to be caught or something else. Thanks a lot.
    public void writeAnObject(Object obj) {
    ObjectOutputStream out = null;
    try {
    out = new ObjectOutputStream(new FileOutputStream("obj.saved"));
    out.writeObject(obj);
    out.close();
    } catch (FileNotFoundException e) {
    System.err.println("Caught FileNotFoundException");
    e.printStackTrace(System.err);
    } catch (IOException e) {
    System.err.println("Caught IOException ");
    e.printStackTrace(System.err);

    Ok, one last thing... don't know if it will make any differance but why not?! This is a class that I used successfully in several projects when serializising Collections to file:
    * @author Andrew
    * @version 1.0 (2000-11-24)
    public class PersistentStorage {
         // The objectoutputstream
         private ObjectOutputStream out;
         // The objectinputstream
         private ObjectInputStream in;
          * This method saves a collection persistent to specified file.
          * @param obj          The collection we want to save.
         public void saveCollection(Collection obj, String fileName)
              throws FileNotFoundException, IOException {
              // Create a objectoutputstream
              out = new ObjectOutputStream(new FileOutputStream(fileName));
              // Write the collection object to file
              out.writeObject(obj);
              // Close the objectoutputstream
              out.close();
          * This method read a collection object from specified file.
          * @return collection          The collection we have read.
         public Collection readCollection(String fileName)
              throws FileNotFoundException, IOException, ClassNotFoundException {
              // Create a objectinputstream
              in = new ObjectInputStream(new FileInputStream(fileName));
              // Asign the read object to a Collection "container"
              Collection collection = (Collection) in.readObject();
              // Close the objectinputstream
              in.close();
              return collection;
    }The differens is that I don't catch any exceptions in those method writing and reading objects. Only throw exceptions.
    Try it out and see if it helps... (last shot) ;)
    /Andrew

  • Creative suite Standard CS 5.5 Serialization question

    Hi Everyone,
    I've got the following license :
    Adobe Design Std CS5.5 5.5 MLP Upgrade License IE FROM CS4 (65122148)
    Is it possible to serialize single application with the Adobe Provisioning Toolkit Enterprise Edition?
    Because when i try to serialize Photoshop CS5.5 i get an error code 3
    adobe_prtk.exe --tool=ReplaceSN --serialize=Photoshop-CS5.5-Win-GM --serial=xxxx
    When i use :
    adobe_prtk.exe --tool=ReplaceSN --serialize=DesignSuiteStandard-CS5.5-Win-GM --serial=xxxx
    it does work.
    Tia. Grz, Gianni

    if that's a mac warning about an unrecognized publisher, OS X Mountain Lion: The app is from an unidentified developer

  • Simple serialization question with objects

    Hi, I'm really new to the whole concept of serialization and what I want to do is create a blackjack game that can have up to 4 people playing, connected to a server that will act as the dealer. I need to be able to serialize some objects from the players to the server and have the server make some changes then send the objects back.
    However every example I've run across dealing with something of this nature involves writing to a file so I'm not sure what the code to do this would look like.
    My best guess would be ObjectInputStream and ObjectOutputStream but I don't understand how I can tell these streams that I just want to send the serialized object back and forth.
    If anyone could explain to me a bit better how these streams work, or show me roughly what the code might look like, I would really appreciate it.

    It doesn't matter whether you write to a file or a socket or a byte array or whatever. That stuff is what's under the ObjectOutputStream. When you create the OOS, you wrap it around some other stream (e.g. a FileOutputStream in the examples you're talking about I guess). To send something to a server, you'd instead just wrap it around the OutputStream of a Socket that's talking to that server. Everything else is the same.
    Whether you use raw sockets or some other means is up to you, but that's completely separate from the serialize/deserialize process.
    http://java.sun.com/docs/books/tutorial/essential/io/index.html
    http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

  • Indirection/Serialization question

    Hello,
    I have the web tier and session bean tier on two different jvms. I am sending over toplink pojos from the session bean to web tier. All my pojos have a writeObject(ObjectOutputStream out) method wherein the dependent objects are instantiated prior to serialization by invoking the size() method. This works fine on the web tier and parent objects as well as the dependents are instantiated properly with the appropriate values. However when we do the calls within the same EJB we get a message saying IndirectList not instiated. When I say the calls within the same EJB I mean say one method of one bean calls another method of the same EJB. If its a remote call the indirect list is instantiated but if its same the same bean we get the above message. Can somebody tell us what we are doing wrong ?
    Regards,
    Aswin.

    Seems odd. Are your SessionBeans using local or remote interfaces locally?
    It may be that your application server is somehow optimizing the local calls, what application server are you using?
    Could you include the exception and stack trace?

  • Bean, Serialization Question

    Who can give me a good explanation of JavaBean. Or a good URL with examples.
    What are the advatages of java beans, how ca I write one.
    And what has it to do with Serialization.
    Serialization where is it used? Examples.

    There's nothing special about a JavaBean. In broad terms a JavaBean is simply a Java class that has been written using a particular style.
    The most notable points are:
    1) default constructor - ie, a constructor with no arguments
    2) property accessors - eg, public String getName(), public void setName(String name), public boolean isEnabled()
    The advantage is that you don't need to know about a JavaBean to use it - the methods indicate the various properties available and their data type. So Java can use Reflection to examine the bean and use it appropriately. In other words, you can find out and use the methods an Object has without knowing about its class in advance simply by examining their names.
    A good example would be a visual component (like a button). By following the JavaBean conventions you end up with a class that can be distributed to other people and they can just plug it into their applications. Think of how a visual GUI editor gives you a property window for a component - this is simply exposing the information it derives by looking at the bean's method signatures.
    There are other things that add extra value to JavaBeans like bean info classes and editor components but that's usually just confusing until you understand beans and their power.
    Have a look at http://java.sun.com/products/javabeans (I think)
    Serialisation is a somewhat different matter. This basically involves "saving an object". You can get a single instance of a class to be written to (eg) the filesystem and then load it again later. Obviously you can write your own methods for saving an object's state but serialisation is automatic and standard allowing it to be employed by other applications without knowledge of the objects that they're dealing with. Again, as with something like JavaBeans it enables you to represent the state without knowing about how the bean works. For example, a distributed application might serialise an object to transmit it between client and server. Note that serialisation does not require that the class being serialised follows the JavaBeans conventions, though - it's kind of a Java no-brainer if you like.
    It would take a long time to explain the full benefits of JavaBeans and serialisation, however.
    Hope this helps.

  • Object Serialization Question.

    Hello, I'm working on a MUD client and I have a DataHolder class to store settings. I'm having problems getting the serialization process to work properly, could someone please give me an example of how to serialize this class and then restore it again? I would like to save the class as "prefs.ser" Here is an example class to use:
    import java.awt.*;
    import java.net.*;
    import java.io.*;
    public class DataHolder
         public Color foreground = Color.black;
         public Color background = Color.yellow;
    // i dont want to save the socket info since it will change many times during actual operation
    // also i know you have to catch the exception from the socket creation : )
         public transient Socket socket = new Socket("lordsoftherealm.org", 1234);
         public DataHolder()
         public setColors(Color foreground, Color background)
              // set background and foreground colors
              // the actual class include methods to retrieve colors, sockets, and other relevent data
              this.foreground = foreground;
              this.background = background;
         public Socket getSocket()
              return socket;
    }Thank you for your time in helping me,
    Joeyford1

    Try this,
    I am using this method to serializeand deserialize my objects ..
    import java.util.Date;
    import java.math.BigDecimal;
    import java.io.*;
    * This object compliments MyObjectTranslator and provides a method to translate
    * any object into a type the database engine can process.
    public class MyObjectTranslator {
    public static Object translate(Object ob) {
    if (ob == null ||
    ob instanceof NullObject ||
    ob instanceof String ||
    ob instanceof BigDecimal ||
    ob instanceof Date ||
    ob instanceof ByteLongObject ||
    ob instanceof Boolean) {
    return ob;
    else if (ob instanceof Serializable) {
    return serialize(ob);
    else {
    // System.out.println("Ob is: (" + ob.getClass() + ") " + ob);
    System.out.println("Unable to translate object. " +
    "It is not a primitive type or serializable.");
    * Serializes the Java object to a ByteLongObject.
    public static ByteLongObject serialize(Object ob) {
    try {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream ob_out = new ObjectOutputStream(bout);
    ob_out.writeObject(ob);
    ob_out.close();
    return new ByteLongObject(bout.toByteArray());
    catch (IOException e) {
    System.out.println("Serialization error: " + e.getMessage());
    * Deserializes a ByteLongObject to a Java object.
    public static Object deserialize(ByteLongObject blob) {
    if (blob == null) {
    return null;
    else {
    try {
    ByteArrayInputStream bin =
    new ByteArrayInputStream(blob.getByteArray());
    ObjectInputStream ob_in = new ObjectInputStream(bin);
    Object ob = ob_in.readObject();
    ob_in.close();
    return ob;
    catch (ClassNotFoundException e) {
    System.out.println("Class not found: " + e.getMessage());
    catch (IOException e) {
    System.out.println("De-serialization error: " + e.getMessage());
    so if you want it to translate it use it something like :
    private Object translateObjectType(Object ob) {
    return MyObjectTranslator.translate(ob);
    and when you wana retrive it use it like :
    Object ds = MyObjectTranslator .deserialize((ByteLongObject) ob);

  • Blazeds Serialization

    Hi while serializing the object from server, if instance
    variable doesnt contains the setter method the values becomes null
    in client side why this kind of restriction is there .
    please explain.

    "saravanan.shun" <[email protected]> wrote
    in message
    news:gifdm0$bp8$[email protected]..
    > My class contains another object as instance variable in
    that object all
    > variables are marked as protected and i have wrote
    setter method for some
    > of
    > the variables in my class that variables alone getting
    serialed .
    >
    > i have analyzed the blazeds source code in that
    BeanProxy class they have
    > added condition as follows
    >
    > if (readMethod != null &&
    isPublicAccessor(readMethod.getModifiers()) &&
    > (includeReadOnly || pd.getWriteMethod() != null))
    > {
    > ..............................
    > }
    >
    > In this condition where the variables are filtered out.
    I am struggling
    > with
    > this issue . Any other options without writing setter
    methods to solve the
    > problem.
    I think they have to be public for the serializing to work.
    Not sure what good it does anyway to have an object where
    _all_ properties
    are protected.

  • Serialization question

    I have written a serializer to convert Java objects into XML documents. In order to allow circular references and to ensure that previously serialized objects do not have to be re-serialized I have implemented an object id tag. The object id tag was based on the objects hashcode. Unfortunately, this causes problems with hashtables as the entrySet field in Hashtable returns the same hash code as the hashtable itself. Also, the hashcode is implementation specific to the VM and the specification does not guarantee that two different objects will return different hashcodes.. Any ideas on how to get a true Object id that is unique to the object? How does java serialization achieve this? Thanks in advance.

    How to get an Object i.d. that is unique to the object? Just an ordinary reference to the object will do:
    Object obj = whatever();
    It may be true that different objects can return identical hashcodes, but when you look up an Object in a hashtable it should only return that object, not any old object that happens to have the same hashcode.

  • Serializable question

    I am trying to learn the concept of serializable in Java.
    I tried few tutorials and searched google, however i am
    still not cleared about it.
    Maybe my english is bad.
    what is the use of serializable? in simple english please

    Serialization is a way of writing an Object in to a byte stream. Seriazable object means an object of a class that implements the java.io.Seriazable interface. If an object is serializable it canbe written in to a stream through an java.io.ObjectOutputStream.
    This is usefull if you want to save the data of an object in to a file and read them later. Also very usefull if you want to send objects of one application to another through sockets (Network programming)
    Here is an small example
    //serializable class
    public class MySerializable implements Serializable{
       String data;
       public MySerializable(String data){
          this.data = data;
       public String toString(){
          return data;
    //writing to a file
    MySerializable obj = new MySerializable ("We gonna write this to a file");
    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("filename.ext"));
    oos.writeObject(obj);
    oos.close();
    //Reading
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream("filename.ext"));
    MySerializable obj = (MySerializable)ois.readObject();
    ois.close();
    System.out.println(obj);Note: This is just the basics. Serialization is a large piece of java

  • Web service serialization question

    Hi,
    Sorry if this is the wrong place to post this... if so, can you pls. point me to the right place. I'm a newbie to this ng (and weblogic in general).
    I am developing a web services client using Weblogic 8.1 sp2. I have run clientgen on the WSDL and compiled my client code with the proxy jar. The web service takes in a complex object as argument. I populate the object & invoke the service. The SOAP request seems to miss out a few important elements even though I have properly populated them in the object. This seems to be arbitrary, because the element is being populated in one request, but missing in the other, even though the code is EXACTLY the same.
    I'm trawled the web, but no one seems to have faced anything like this. I can post the WSDL & the soap requests if required.
    Regards,
    Mridul.

    Hi,
    the clientgen tool is somewhat buggy, have you tried the SP4 version ?
    If this does not work, please post more details.
    - Anders M.

  • Image serializable question

    i want to send image to another server'database,and can get it later.
    how to transport image on net, who can paste some code?
    thanks !

    Here was a discussion, and it also points to other related threads:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=411943
    Mike

  • Customizing ActionScript - Java serialization?

    Hi,
    I wonder how to customize what ActionScript class is serialized to what Java object, overriding BlazeDS's defaults.
    I have a Java class where I would like an ActionScript ArrayCollection to serialize to a custom class.
    To illustrate, normally I might have a class on the server like this:
    public MyClass {
    public void updateRecords(java.util.List[Widget]) {...}
    When this is invoked from a remote Flex client, passing an ArrayCollection as the method parameter, BlazeDS serializes that ArrayCollection into a Java List, and everything works fine.
    Suppose, however, that I have the above method signature defined in the following way:
    public MyClass {
    public void updateRecords(MyCustomCollection[Widget]) {... }
    In that situation, I'd like to be able to specify a custom serializer that takes an ActionScript ArrayCollection and serializes it into MyCustomCollection. In fact, what I'd really like to do is to use this serializer every time a Java class' interface contains MyCustomCollection.
    I looked into flex.messaging.io.TypeMarshaller, but couldn't quite figure out how to use it for that purpose. 
    Thanks,
    -- Frank

    >
    How Java Serialization works internally which algorithm it uses to serialize/deserailaize the objects?
    >
    See the Java Object Serialization Specification
    http://docs.oracle.com/javase/6/docs/platform/serialization/spec/protocol.html
    And are you aware that you have never marked a single one of your 119 previous questions as answered?
    Total Questions: 119 (119 unresolved)
    Are all of those questions really unanswered? Or have you just forgotten to mark them ANSWERED.
    Please begin revisiting your large number of previous posts and marking them ANSWERED as appropriate. This is important for several reasons. First because forum volunteers need to focus on unanswered questions - it wastes their time to read thru threads and respond to posts that have actually already been answered since the original poster isn't even going to pay attention to any new replies. That time could have been better spent helping users that have REAL unanswered questions on the forum.
    Second, when someone like yourself has large numbers of unanswered questions it basically sends a signal to the volunteers that the person posting the question may not even be reading or responding to the replies the volunteers may make. This leads some volunteers to decide to not even bother responding - why should they spend their time trying to help someone who won't even acknowledge the help that they get?
    Third, other people that have the same problem you had find your posts but never see them answered. So they never know if the information provided by the volunteers solved your problem or not. When you mark your questions answered it helps others with the same problem.
    Thanks.

Maybe you are looking for