StackOverflowError serializing POF objects

Hi,
I have run into an issue while attempting to store objects in the cache that results in a StackOverflowError. The situation is that I have a number of classes that reference each other so while storing one the other is serialized which in turn attempts to serialize the other. An example is as follows:
public class DeskSerializer extends AbstractVersionedDomainEntitySerializer<DeskImpl> {
     private static final int NAME = 11;
     private static final int REGION = 12;
     private static final int COUNTRIES = 13;
     private static final int BOOKS = 14;
     private static final int DESK_ID = 15;
     @Override
     protected DeskImpl createInstance() {
          return new DeskImpl();
     public void serialize(PofWriter out, Object o) throws IOException {
          DeskImpl obj = (DeskImpl) o;
          super.serialize(out, obj);
          out.writeString(NAME, obj.getName());
          out.writeObject(REGION, obj.getRegion());
          out.writeCollection(COUNTRIES, obj.getCountries());
          out.writeCollection(BOOKS, obj.getBooks());
          out.writeLong(DESK_ID, obj.getDeskId());
          out.writeRemainder(null);
     @SuppressWarnings("unchecked")
     public Object deserialize(PofReader in) throws IOException {
          DeskImpl obj = (DeskImpl) super.deserialize(in);
          obj.setName(in.readString(NAME));
          obj.setRegion((Region) in.readObject(REGION));
          obj.setCountries((Set<Country>) in.readCollection(COUNTRIES, new HashSet<Country>()));
          obj.setBooks((Set<Book>) in.readCollection(BOOKS, new HashSet<Book>()));
          obj.setDeskId(in.readLong(DESK_ID));
          in.readRemainder();
          return obj;
public class BookSerializer extends AbstractVersionedDomainEntitySerializer<BookImpl> {
     private static final int NAME = 11;
     private static final int PORTFOLIO_SWAPS = 12;
     private static final int DESK = 13;
     private static final int LEGAL_ENTITY = 14;
     private static final int CLIENT = 15;
     private static final int BOOK_ID = 16;
     private static final int BUSINESS_UNIT_ID = 17;
     private static final int PORTFOLIO_ID = 18;
     private static final int NM_PRTF = 19;
     private static final int BOBOOK_ID = 20;
     @Override
     protected BookImpl createInstance() {
          return new BookImpl();
     public void serialize(PofWriter out, Object o) throws IOException {
          BookImpl obj = (BookImpl) o;
          super.serialize(out, obj);
          out.writeString(NAME, obj.getName());
          //out.writeCollection(PORTFOLIO_SWAPS, obj.getPortfolioSwaps());
          out.writeObject(DESK, obj.getDesk());
          //out.writeObject(LEGAL_ENTITY, obj.getLegalEntity());
          //out.writeObject(CLIENT, obj.getClient());
          out.writeLong(BOOK_ID, obj.getBookId());
          out.writeString(BUSINESS_UNIT_ID, obj.getBusinessUnitId());
          out.writeInt(PORTFOLIO_ID, obj.getPortfolioId());
          out.writeString(NM_PRTF, obj.getNmPrtf());
          out.writeString(BOBOOK_ID, obj.getBoBookId());
          out.writeRemainder(null);
     @SuppressWarnings("unchecked")
     public Object deserialize(PofReader in) throws IOException {
          BookImpl obj = (BookImpl) super.deserialize(in);
          obj.setName(in.readString(NAME));
          //obj.setPortfolioSwaps((Set<PortfolioSwap>) in.readCollection(PORTFOLIO_SWAPS, new HashSet<PortfolioSwap>()));
          obj.setDesk((Desk) in.readObject(DESK));
          //obj.setLegalEntity((LegalEntity) in.readObject(LEGAL_ENTITY));
          //obj.setClient((Client) in.readObject(CLIENT));
          obj.setBoBookId(in.readString(BOOK_ID));
          obj.setBusinessUnitId(in.readString(BUSINESS_UNIT_ID));
          obj.setPortfolioId(in.readInt(PORTFOLIO_ID));
          obj.setNmPrtf(in.readString(NM_PRTF));
          obj.setBoBookId(in.readString(BOBOOK_ID));
          in.readRemainder();
          return obj;
}in the above classes DeskSerializer tries to serialize a collection of Books which in turn try to serialize a Desk. This then just goes round and round until the exception is thrown.
Is there a neat solution to this situation? I can't change the domain objects as this is a legacy system so the only thing I could come up with would be to add a set of CoherenceDomainObjects that store the keys of the objects instead of the objest themselves and deconstruct the real objects into the Coherence version on the way in and reconstruct on the way out. Any ideas?

Hi Willy,
the problem is that you have a circle in your object graph which you are trying to serialize.
That needs to be broken, because POF does not support breaking the circle on its own, and you need to write custom PofSerializers for these classes which are able to deal with this problem. The problem is if you can not break the circle easily and traverse the full graph without entering into circles without recording references as you go then this is not going to be fast (this is the same reason why Java serialization is slow) or limit traversal of the graph.
Best regards,
Robert

Similar Messages

  • Packaging POF object class in a jar file

    I have the following issue packaging a POF class.
    I have two POF classes which are defined in the package oracle.communications.activation.asap.ace;
    1. Token.java
    2. Asdl.java
    For simplicity i package them in the coherence.jar along with the other nessary artifacts.
    "tokens-pof-config.xml"
    <?xml version="1.0"?>
    <pof-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.oracle.com/coherence/coherence-pof-config"
    xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-pof-config coherence-pof-config.xsd">
    <user-type-list>
    <!-- coherence POF user types -->
    <include>coherence-pof-config.xml</include>
    <!-- com.tangosol.examples package -->
    <user-type>
    <type-id>1001</type-id>
    <class-name>Token</class-name>
    </user-type>
    <user-type>
    <type-id>1002</type-id>
    <class-name>Asdl</class-name>
    </user-type>
    </user-type-list>
    <allow-interfaces>true</allow-interfaces>
    <allow-subclasses>true</allow-subclasses>
    </pof-config>
    Then I startup the CacheServer it startsup fine. However when I invoke the POF classes from my weblogic artifacts I get the following error message.
    <Oct 26, 2011 10:04:24 PM PDT> <Warning> <EJB> <BEA-010065> <MessageDrivenBean threw an Exception in onMessage(). The exception was:
    (Wrapped) java.io.IOException: unknown user type: oracle.communications.activation.asap.ace.Token.
    (Wrapped) java.io.IOException: unknown user type: oracle.communications.activation.asap.ace.Token
    ======================================================================================================================
    If I however define the classes in the default package or no package instead of package oracle.communications.activation.asap.ace;
    Keeping everything else the same everything works fine.
    ====================================================================================
    What do I need to do to make this work if I am packaging my POF classes not in the default package ?

    Hi JK,
    Well i have modified my POF classes since then and now created a package for them before I was just playing around and had them defined in a default package.
    Second Baby steps here, once I get things working by packaging things in the coherence.jar file I will create my own jar artifact and add it to class path. As it is I have classpath issues. ...
    So as I mentioned earlier.
    I created the oracle/communications/activation/asap/ace directory added my two POF classes to it and then repackaged the jar.
    It returns this error!
    2011-10-27 06:48:03.355/4.696 Oracle Coherence GE 3.6.0.4 <Error> (thread=main, member=1): Error while starting service "DistributedCache": (Wrapped) (Wrapped: error configuring class "com.tangosol.io.pof.ConfigurablePofContext") java.lang.NoClassDefFoundError: oracle/communications/activation/asap/ace/Token (wrong name: Token)
    So any ideas ?
    "tokens-pof-config.xml"
    ==============
    <?xml version="1.0"?>
    <pof-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.oracle.com/coherence/coherence-pof-config"
    xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-pof-config coherence-pof-config.xsd">
    <user-type-list>
    <!-- coherence POF user types -->
    <include>coherence-pof-config.xml</include>
    <!-- com.tangosol.examples package -->
    <user-type>
    <type-id>1001</type-id>
    <class-name>oracle.communications.activation.asap.ace.Token</class-name>
    </user-type>
    <user-type>
    <type-id>1002</type-id>
    <class-name>oracle.communications.activation.asap.ace.Asdl</class-name>
    </user-type>
    </user-type-list>
    <allow-interfaces>true</allow-interfaces>
    <allow-subclasses>true</allow-subclasses>
    </pof-config>
    cache-server.sh_
    #!/bin/sh
    # This will start a cache server
    # specify the Coherence installation directory
    COHERENCE_HOME=.
    # specify the JVM heap size
    MEMORY=512m
    if [ ! -f ${COHERENCE_HOME}/bin/cache-server.sh ]; then
    echo "coherence.sh: must be run from the Coherence installation directory."
    exit
    fi
    if [ -f $JAVA_HOME/bin/java ]; then
    JAVAEXEC=$JAVA_HOME/bin/java
    else
    JAVAEXEC=java
    fi
    #JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY -Dtangosol.pof.enabled=true -Dtangosol.pof.config=tokens-pof-config.xml"
    #JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY -Dtangosol.coherence.clusteraddress=224.3.6.0 -Dtangosol.coherence.clusterport=3059"
    JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY"
    #JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY"
    $JAVAEXEC -server -showversion $JAVA_OPTS -cp "$COHERENCE_HOME/lib/coherence.jar:." com.tangosol.net.DefaultCacheServer $1
    Token.java for example (Asdl.java looks very similar)
    ================================
    package oracle.communications.activation.asap.ace;
    import java.io.IOException;
    import java.io.Serializable;
    import com.tangosol.io.pof.PortableObject;
    import com.tangosol.io.pof.PofReader;
    import com.tangosol.io.pof.PofWriter;
    import java.sql.*;
    import java.util.Enumeration;
    * This class represents the domain object Token. This class is also packaged on the classpath
    * for the Cache-Server when it starts up. The Token class implements the PortableObject format.
    * @author Ankit Asthana
    public class Token implements PortableObject {
         * The state associated with a token
         * 1 - Unassigned, 2 - Available, 3 - Reserved, 4 - defunct
         private int state;
         * The network ID associated with each token
         private String neID;
         * Unique Token ID, used to identify Tokens
         private String tokenID;
         * State of the token possible
         public static int TOKEN_AVAILABLE = 2;
         public static int TOKEN_RESERVED = 3;
         * The following are static final indices required for the implementation
         * for a POF object, they have to be sequential in order.
         public static final int TOKENID = 0;
         public static final int STATE = 1;
         public static final int NEID = 2;
         * setter Method for state of the token
         * @param state
         public void setState(int state) {
              this.state = state;
         * getter Method for the state of the token
         * @return
         public int getState() {
              return state;
         * setter Method for the network ID
         * @param neID
         public void setNeID(String neID) {
              this.neID = neID;
         * getter Method for the network ID
         * @return
         public String getNeID() {
              return neID;
         * returns the TokenID for the current token
         * @return
         public String getTokenID() {
              return tokenID;
         * Default Constructor required by POJO's, Do not remove!
         public Token() {
         * This is a utility method and returns the state of the token in a String format using the
         * integer value representing the state of the token passed to it.
         * @param tokenStateInteger
         * @return
         public static String tokenToString(int tokenStateInteger) {
              if (tokenStateInteger == TOKEN_AVAILABLE)
                   return "Available";
              else if (tokenStateInteger == TOKEN_RESERVED)
                   return "Reserved";
              return "Unknown";
         * Parameterized constructor for a token.
         * Can be used to initialize a token with the following parameters
         * @param tokenID: Unique ID representing the Token
         * @param state: The state for the token, by default available
         * @param neID: The network ID this token associates to
         public Token(String tokenID, int state, String neID) {
              this.state = state;
              this.tokenID = tokenID;
              this.neID = "" + neID;
         // ----- PortableObject interface ---------------------------------------
         * The readExternal method is required for the implementation of the POF portableObject.
         * This method is used for serialization purposes
         * {@inheritDoc}
         public void readExternal(PofReader reader) throws IOException {
              tokenID = reader.readString(TOKENID);
              state = Integer.parseInt(reader.readString(STATE));
              neID = reader.readString(NEID);
         * The writeExternal method is required for the implementation of the POF portableObject.
         * This method is used for de-serialization purposes
         * {@inheritDoc}
         public void writeExternal(PofWriter writer) throws IOException {
              writer.writeString(TOKENID, tokenID);
              writer.writeString(STATE, Integer.toString(state));
              writer.writeString(NEID, neID);
    Edited by: 807103 on Oct 27, 2011 8:55 AM
    Edited by: 807103 on Oct 27, 2011 9:00 AM

  • The Proper way to go - Passing Serialized Java Objects vs. Web Services?

    The team which I am apart of in our little "community" is trying to convince some "others" (management) that we should not use web services to communicate (move large data) within the same application (allbeit a huge application spanning across many servers).
    Furthermore these "others" are trying to tell us that in this same application when two small apps. inside of this large app. are both java we should not communicate via serialized java objects but instead we should use Web Services and XML. We are trying to convince them that the simplest way is best.
    They have asked us to provide them with proof that passing serialized java objects back and forth between two smaller java applications inside of a larger one is an Industry Standard. Can anyone help either straighten my fellow workers and I out or help us convince the "others" of the proper way to go?

    When I was a consultant we always gave the client what they wanted. Even if it was the wrong choice. Suck it up.
    I'm glad I wasn't one of those customers. Although I agree that a customer is the one who decides what to do, when I pay someone for consultancy, I expect them to consult me. If they know I'm trying to do something that I shouldn't be doing, I expect a good consultant to be able to show me that there's a better way (not just tell me I'm not doing it right, mind you).
    We pass a lot of data using XML and we don't have any transmission or processing speed issues.
    Then you either have a much better network than our customer did, or we're not talking about the same amounts of data here.
    I used the JAX-RPC RI ...
    That's cool... our customer was, unfortunately, infected with Borland products, so we had to use BES. The web services on BES were run by Axis.
    How large were these messages?
    Huge... each element had about 15 attributes, so 1,200 elements would require 19,200 XML nodes (envelope not included). By comparison, the serialized messages weren't even a quarter that size. It's not just about what you send across the network; it's also the effort of parsing XML compared to desrializing Java objects. Our web service wasn't exactly the only process running at the server.
    Anyone who understand the fundamental difference between ASCII (XML) and binary (serialized) formats realizes that no web service can possibly achieve the performance of binary Java services. Why do you think that work is being put into binary web services? I'm not saying XML is never a good thing; just that it's not The Holy Grail that a lot of people are making it look like.
    http://issues.apache.org/jira/browse/AXIS-688
    Ouch.

  • Un-serializing java objects.

    Hi,
    I have a serialized java object.How can I convert it to a normal object or string object?
    Thanks
    Vivek

    Hi,
    I am not writing object into a file.I am
    just creating a objectoutputstream object.I have to
    convert it to string which i guess can be done using
    objectInputstream object .So is there any way out?
    Thanks
    vivekI'm confused by what you are trying to accomplish. An ObjectOutputStream is intended to write objects to a file. You can't convert an ObjectOutputStream to a String, they aren't related. Are you trying to write the objects to a String? I don't see the point of that.

  • Serializing & Deserializing objects through ObjectMessage

    Hi,
    I'm having trouble sending objects/instances of a class (Data) through the message queue. I also made Data to be serializable.
    public class Data implements Serializable {
    }The following are snippets of code from the Message producer side:
    objectMessage = mySess.createObjectMessage();
    MessageProducer myMsgProducer = mySess.createProducer(myQueue);
    Data e = new Data();
    objectMessage.setObject(e);
    myMsgProducer.send(objectMessage);And the following are snippets of code from the message consumer:
    public void onMessage(Message message) {
                 if(message instanceof ObjectMessage ){
             try{
                  ObjectMessage objMsg = (ObjectMessage) message;
                  Data myData = (Data)objMsg.getObject();
             catch(JMSException e){
                  System.out.println("Exception occured: " + e.toString());
    }The result of attempting to cast the objMsg to a Data is an exception thrown.
    i did noticed however, that when I was debugging the message consumer, that the byteArrayInputStream values for both message and objMsg are null meaning that the data is not being sent or received. Any help would be greatly appreciated, thanks!
    Edited by: 883631 on Sep 13, 2011 4:09 PM
    Edited by: EJP on 14/09/2011 09:22: added {noformat}{noformat} tags. Please use them.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Sorry, the exception thrown is:
    Exception occured: com.sun.messaging.jms.MessageFormatException: [C4015]: Deserialize message failed. - cause: java.lang.ClassNotFoundException: MsgSender.Data
    Sep 14, 2011 8:53:50 AM com.sun.messaging.jmq.jmsclient.ExceptionHandler logCaughtException
    WARNING: [I500]: Caught JVM Exception: java.lang.ClassNotFoundException: MsgSender.Data
    where MsgSender is the name of the project that produces the messages to the queue.
    Data is the class that is both on the sender and receiver side, and the exception is thrown as a result of casting the object message back into a type Data.
    Data myData = (Data)objMsg.getObject();
    I hope this isn't too confusing. What I'm wondering is if there are extra steps to serializing your object or if the ObjectMessage's setObject method automatically does that for you so as long as you declare your class to implement Serializable. And if that's the case, how do you deserialize it back to the original object?
    Thank you

  • How to get POF object's field value from query result

    hi,all:
    I want to get field value from the query result, my code is below
    Set setResults = cache.entrySet(createFilter("homeAddress.state = 'MA'"));
    for (Iterator iter = setResults.iterator(); iter.hasNext(); )
    Contact c=(Contact)iter.next();
    System.out.println ("firstame####=" + c.getFirstName());
    * but I get error*
    Exception in thread "main" java.lang.ClassCastException: com.tangosol.util.ConverterCollec
    tions$ConverterEntrySet$ConverterEntry cannot be cast to com.oracle.handson.Contact
    at com.oracle.handson.QueryExample.printResults(QueryExample.java:159)
    at com.oracle.handson.QueryExample.query(QueryExample.java:86)
    at com.oracle.handson.QueryExample.main(QueryExample.java:43)
    who can tell me how to get POF object's field value from query result

    Hi,
    If you look at the Java Doc for the entrySet method here http://download.oracle.com/docs/cd/E15357_01/coh.360/e15725/com/tangosol/util/QueryMap.html#entrySet_com_tangosol_util_Filter_ you will see that it returns a Set of Map.Entry instances so you need to do this...
    Set setResults = cache.entrySet(createFilter("homeAddress.state = 'MA'"));
    for (Iterator iter = setResults.iterator(); iter.hasNext(); )
        Map.Entry entry = iter.next();
        Contact c=(Contact)entry.getValue();
        System.out.println ("firstame####=" + c.getFirstName());
    }JK

  • How to use Java NIO to implement disk cache for serialized java objects

    Hi,
    I have a cache (implemented as hahstable etc.) that contains java objects (mostly strings) and swaps objects from runtime memory to the disk and back based on some algorithms. Currently, the reading and writing from the disk is implemented using java.io.* package i.e. fileInputstream and FileOutputStream. Essentially, I serialize the java object and write to the disk and the deserialize and give it back to the Hashtable cache.
    The performance of swapping from disk to memory is kinda slow. I have read that memory mapping would improve the performance.
    My idea is to do the following:
    Have one big file mapped to memory. I write the serialized objects to different portions of the file and then read those portions when needed. I can use the MappedByteBuffer for that but then I have the following questions. I will not store objects in the hashtable anymore.
    1. How do I delete things from the cache in the above design i.e. how do I delete portions of a mapped file?
    2. How do I serialize objects using ByteBuffers and then deserialize them? I guess this shouldn't be hard but just want to confirm.
    Do you think this is the right design or should I change? Right now using the old io package, I have a separate file for each object. When using the NIO package, I want to store all objects in a single file in different portions of the file, is that the right way to go?
    As you can see, I am beginner in memory mapped io and need help.

    Have one big file mapped to memory. I write the serialized objects to different portions of the file and then read those portions when needed. I can use the MappedByteBufferThis is a good idea, one that I have worked on. It involves quite a bit of manipulation with temporary buffers and a deep working knowledge of object serialization.
    1. How do I delete things from the cache in the above design i.e. how do I delete portions of a mapped file?The best way to handle this is do a two-step process, cutting the file into two pieces and gluing it back together where the original one is...
    2. How do I serialize objects using ByteBuffers and then deserialize them? I guess this shouldn't be hard but just want to confirm.It is hard. Wrapping the streams and making the IO work properly is not the challenge however. The hard part comes in hacking the object streams. The object input/output streams use a ClassDescriptor object which only gets written once/ read once. This shouldn't be a problem if you will read/write the entire file at once, but will bring you grief if you want random access to your objects. You will also need an indexing mechanism to support random access.
    Do you think this is the right design or should I change? Right now using the old io package, I have a separate file for each object. When using the NIO package, I want to store all objects in a single file in different portions of the file, is that the right way to go?I guess it depends on your needs. Do you require random access to objects? NIO provides some performance gains, but mostly for very large amounts of data (>10M in my experience).
    You can always write all your objects into the same file using normal io techniques and you can still generate an index and acheive random access. It might be easier...
    Good luck

  • Convert Serialized Java Objects to XML

    I have seen numerous ways that you can modify a java application to serlialize it's data as XML rather than a binary stream. Does anyone know if there are any utilities, libraries, DLLS, tools, whatever to convert an already serialized binary stream to an XML file.
    At the moment I am working on a script to do this, and it works for simple objects, but I am hitting snags as I test with more complicated class heirachies. I would love to find something that already does this for me.

    I want to read data serialized by a java program in a C++ application. I don't want to have to modify the java application, but I do want to make it's data available in other applications.
    I could modify the java app and serialize it's data in XML, but that isn't the prefered solution. :)

  • Static fields in serialized Vector objects

    just a curious question:
    If I have a Vector filled with Objects of all the same type, and the Object contains a static field, and I then Serialize the Vector, will it still give better performance than if the field wasn't static? Thanks,
    Max

    nevermind - found out the hard way that static fields won't get Serialized

  • Serializing/Deserializing Objects..Urgent !!!

    Hello Everyone,
    Out of the blue I got an exception like
    java.io.StreamCorruptedException: invalid stream header
         at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
         at java.io.ObjectInputStream.<init>(Unknown Source)
    I am implementing "Applet to Servlet communication".
    Actually i am trying to deserialize the object which was passed to the servlet.But when i read it back i am geting the above exception.
    Can anyone throw some light on it?
    Her is my code
    APPLET CODE:
    private void interactWithServlet() {
    WBObject result = null;
    try {
    // Create an object we can use to communicate with the servlet
    URL servletURL = new URL(sURL);
    URLConnection servletConnection = servletURL.openConnection();
    servletConnection.setDoOutput(true);
    servletConnection.setUseCaches(false);
    servletConnection.setRequestProperty("Content-Type", "application/octet-stream;charset=utf-8");
    ObjectOutputStream request = new ObjectOutputStream(
    new BufferedOutputStream(servletConnection.getOutputStream()));
    WBObject wbObj=m_whiteBoardComponent.getDesignPanel().getWBObject();
    int size=wbObj.getChildren().size();
    for(int i=0;i<size;i++){
    PickObject pick=(PickObject)wbObj.getChildren().get(i);
    System.out.println("the pick object name is"+pick.getName());
    int count=pick.getChildren().size();
    for(int j=0;j<count;j++){
    ItemObject item=(ItemObject)pick.getChildren().get(j);
    System.out.println("the item object name is"+item.getName());
    request.writeObject(wbObj);
    request.flush();
    request.close();
    ObjectInputStream response = new ObjectInputStream(
    new BufferedInputStream(servletConnection.getInputStream()));
    result = (WBObject)response.readObject();
    System.out.println("The object is"+(result instanceof WBObject));
    response.close();
    } catch (Exception e) {
    e.printStackTrace();
    SERVLET CODE:
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
    IOException {
    WBObject o = null;
    ObjectInputStream inputStream = new ObjectInputStream(
    new BufferedInputStream(req.getInputStream()));
    try {
    o = (WBObject)inputStream.readObject();
    inputStream.close();
    } catch( ClassNotFoundException ex ) {
    ex.printStackTrace();
    // send response
    resp.setStatus(HttpServletResponse.SC_OK);
    resp.setContentType("application/octet-stream;charset=utf-8");
    ObjectOutputStream oos = new ObjectOutputStream(
    new BufferedOutputStream(resp.getOutputStream()));
    oos.writeObject(o);
    oos.close();
    Best Regards
    Ashish

    client
    URLConnection servletConnection = servletURL.openConnection();try
    HttpURLConnection servletConnection = (HttpURLConnection)servletURL.openConnection();server
    // send response
    resp.setStatus(HttpServletResponse.SC_OK);
    resp.setContentType("application/octet-stream;charset=utf-8");
    ObjectOutputStream oos = new ObjectOutputStream(
    new BufferedOutputStream(resp.getOutputStream()));
    oos.writeObject(o);
    oos.close();try
    // send response
    //resp.setStatus(HttpServletResponse.SC_OK);
    //resp.setContentType("application/octet-stream;charset=utf-8");
    ObjectOutputStream oos = new ObjectOutputStream(
    new BufferedOutputStream(resp.getOutputStream()));
    oos.writeObject(o);
    oos.flush();
    oos.close();

  • Serializing Java Objects to XML files

    Hi,
    We looking for SAP library which can serialize Java Objects into XML files.
    Can you point us were to find it ?
    We have found such open source library called "XStream" at the following link
    http://www.xml.com/pub/a/2004/08/18/xstream.html
    Is it allowed to use that library inside SAP released software ?
    Thanks
    Orit

    How about https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/83f6d2fb-0c01-0010-a2ba-a2ec94ba08f4 [original link is broken] [original link is broken]? Depends on your use cases...
    Both are supported in SAP NW CE 7.1.
    HTH!
    -- Vladimir

  • Exchange XML document containing serialized DDIC objects

    Hi,
    Suppose you have an itab "z_table" with generic linetype. The table may contain any ddic structure or table.
    Furhter you want to exchange the itab "z_table" between the Systems A and B using XML.
    We are using the following code to serialize the itab "z_table" in system A:
      DATA: g_ixml TYPE REF TO if_ixml,
            g_stream_factory TYPE REF TO if_ixml_stream_factory,
            g_encoding TYPE REF TO if_ixml_encoding,
            ostream TYPE REF TO if_ixml_ostream.
      CONSTANTS: encoding TYPE string VALUE 'utf-8'.
      g_ixml = cl_ixml=>create( ).
      g_stream_factory = g_ixml->create_stream_factory( ).
      g_encoding = g_ixml->create_encoding(
        character_set = encoding
        byte_order = 0 ).
      ostream = g_stream_factory->create_ostream_xstring( string = ex_xml_string ).
      ostream->set_encoding( encoding = g_encoding ).
      CALL TRANSFORMATION id_indent
        SOURCE z_table = z_table
        RESULT XML xml_string
        OPTIONS data_refs = 'heap'
                xml_header = 'full'.
    And the following code to deserialize the itab in system B:
      CALL TRANSFORMATION id_indent
        SOURCE XML xml_string
        RESULT z_table = z_table.
    The serialization in System A creates an XML document containing <dic:z_structure> tags. If you now try to deserialize this document ("z_table")
    in System B, the deserialization fails in case z_table contains DDIC structures which are not known in system B.
    Is there any way to have the definition (e.g. type + length) of those ddic structures included in the XML document, so that
    a deserialization is possible even if the ddic structure is not known in system B? e.g. Rendered into a XML scheme, or directly as an
    attribute into the <dic:..> tag for instance?
    Any ideas are appreciated..
    Best regards,
    Georg

    Hello Raja,
    many thanks first for your answer. I tried the FM and got a table with the definition details I want.
    Unfortunately, I'm not really sure, how to continue working with the definition details. There are still some questions open:
    - How do I proficient include these table details into my xml with my original table z_table? Would it be possible to include the table details in a way, that a "call transformation" can easily deserialize my z_table with this table details?
    - How do I convert the lt_dfies table definition details back to a ddic object that I can use? Can this be done in memory only, so that I don't have to create real ddic objects on the target system?
    Many thanks and kind regards, Oliver<b></b><b></b>

  • Serializing large objects

    Dear All,
    I am trying to serialize a HashMap containing Strings as keys and and ArrayLists as values. This works fine when the number of entries is small, but does not work when the number of entries are really large, in which case an java.lang.OutOfMemoryError: Java heap space is thrown. This happens when the number of entries is about 50,000 and the total number of objects stored in the lists exceed 500,000.
    Some posts suggest that this should have been fixed in Java 1.6 but it still doesn't seem to work. Do I need to provide the "-mx" flag to get this to work, or is there another way to serialize large objects? Any thoughts welcome.
    Cheers,
    Fred

    How about implementing custom serialization (by implementing Externalizable), and writing the values as zippied entries. As keys are strings, they can be easily zipped and the array list values should be zipped. Is it possible? ...am I crazy????. Just give it a try :-)

  • Serializing unserializable objects - serious

    We are currently implementing a replacement for an existing communication infrastructure.
    Part of the service is to make remote method calls via message oriented middleware. Unfortunately some of the parameters of these methods are not serializable, and we cannot change these classes.
    Is there any way (i.e. API, product) to marshal these objects to a byte array?

    When you say that you can't change the class, does this mean that you cannot extend it either?

  • Urgent: Problem serializing server objects

    hi there
    i have deployed an application in jboss. it uses instances of javax.media.rtp.RTPManager which is not serializable. now jboss requires each in-memory object to be Serializable. and i have to accomplish the transmission task on server side. so whats the solution? because trying these objects to serialize server throws NotSerializableException
    thanx in advance
    ra4a

    Maybe you can define:
    Class MyRTPManager extends javax.media.rtp.RTPManager implements Serializable {
    You can have this empty definition and then replace all RTPManager with myRTPManager.
    PC

Maybe you are looking for

  • Process Chain for Real Time Demon

    Please help I am stuck I followed the step by sdn but this is missing in step. how to create now process chain. I created the below DSO CONNECTED TO dATASOURCE via Trans, Real Time IP Real Time DTP assigned to Datasource and assigned the DS, IP, DTP

  • How to Run an IP Sequence in Background

    Hello: We call a sequence (containing a FOX formula) from a command button on a workbook and it keeps timing out.  Does anyone know how we could arrange to run this in the background and still have it triggered by the workbook button? We tried writin

  • Error when transporting an Openhub to QA

    hi guys I did some enhancements on two open hubs (added a couple of fields on each one). I updated the transformations as well and everything worked fin on DEV system. Activated everything and then moved to QA, but then I got an error in the transpor

  • How to save content of JPanel into jpeg or png file

    I have to independent classes: Class A and Class B. Each class constructs its own graphical objects: Class A { //do something public void paintComponent(Graphics g) int x = 0; int y = 0; int w = getSize().width; int h = getSize().height; bi = new Buf

  • Oracle Database 10gHome page

    Hi, I have installed "Oracle Database 10g Express Edition" in my Linux system using the .deb file available in the Oracle Downloads site. When i try to start as given in the documentation "On Linux, click the Application menu (on Gnome) or the K menu