Hashtable serialization

Hi, i've a problem with the deserialization of my hashtable...
Here are my serialization and deserialization functions:
String serializeParameters(Hashtable parameters) throws IOException {
try
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream outputToString = new ObjectOutputStream(baos);
outputToString.writeObject(parameters);
outputToString.close();
return new String(baos.toByteArray());
catch (Exception ex)
return null;
Hashtable deserializeParameters(String serializedParameters) throws
IOException, ClassNotFoundException {
try{
byte baSend[]=new byte[serializedParameters.length()];
baSend = serializedParameters.getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(baSend);
ObjectInputStream ois = new ObjectInputStream(bais);
return (Hashtable) ois.readObject();
catch (Exception ex)
The deserialization function catch an ugly
java.io.StreamCorruptedException: invalid stream header
when trying "ObjectInputStream ois = new ObjectInputStream(bais);"
Is there anything wrong in my code? (Of course there is! It is not working!! ;) )
If anyone can help me, thanks by advance!

You cannot assume that you can validly create a String from an arbitrary array of bytes.The String constructor specially mentions this point. Consequently, the transformation from byte array to Strring and back to byte array will not in general produce the same byte array for arbitrary byte array data.
So the fact that the resuling stream is corrupted is not in the least bit surprising.
Sylvia.

Similar Messages

  • Hashtable lost entries after rmi

    hallo,
    i gernerat o a server a hashtable wie int as key and an object with 2 vectors as the value.
    after rmi transfer to the client, the hashtable lost some entries. why?
    i debug the server side and stop at the return argument. all entries found. than i debug at client side at the first command and some entries lost.
    thanks
    thorsten

    Is this a java.util.Hashtable or one you have written yourself?
    Are all the objects in the hashtable serializable?
    Do they all have equals() and hashcode() methods, or are you just relying on Object.equals and Object.hashcode()?

  • Problem with Serializable JDO objects containing Hashtables

    Hi,
    I have a simple JDO object which contains a Hashtable and I would like to
    declare as Serializable. It seems though, that whenever I serialize this
    object, I get a NullPointerException. I've written a bare-bones test case
    and reproduced the exception, so I suspect this may be an enhancement issue.
    Thanks,
    Eric
    Exception in thread "main" javax.jdo.JDOException
    NestedThrowables:
    java.lang.NullPointerException
    at
    sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteC
    all.java:245)
    at
    sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
    at
    org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invoke(Unknown
    Source)
    at
    org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericPr
    oxy.java:357)
    at
    org.jboss.ejb.plugins.jrmp.interfaces.StatefulSessionProxy.invoke(StatefulSe
    ssionProxy.java:136)
    at $Proxy1.getHash(Unknown Source)
    at test.HashEjb.getHash(Unknown Source)
    at test.Test.doIt(Test.java:13)
    at test.Test.main(Test.java:7)

    Thanks for the prompt reply Patrick. I can hold off on this until early
    next week...
    "Patrick Linskey" <[email protected]> wrote:
    This is a confirmed bug. We do not correctly deserialize any proxy map
    classes.
    How soon is ASAP? None of us can work on it until later this evening at
    the earliest.
    -Patrick
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Jax-ws 2.1 - problems returning hashtable and hashmap

    Hi,
    We're developing a set of applications that communicate via web services.
    The company decided that to do this we should use jax-ws 2.1.
    Everything is going ok, its really easy to use, except for a web method that returns a java.util.Hashtable.
    In the endpoint there's no problem, it compiles and deploys to a tomcat 5.5 without a problem.
    The client can access the wsdl via url, download it and create the necessary files (we use netbeans 5.5 for this).
    We can invoke the method getConfig without a problem, but the object returned only has the java.lang.Object 's methods, not the java.util.Hastable 's .
    Endpoint:
    package xxx.cdc_pm_i;
    import java.util.Hashtable;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebService;
    import javax.xml.bind.annotation.*;
    @WebService()
    public class cdc_pm_i{
    @WebMethod
    public Hashtable getConfig() {
    Hashtable<String,String> config = new Hashtable<String,String>();
         config.put("1","1");
         config.put("2","2");
    return config;
    Client:
    try { // Call Web Service Operation
    xxx.CdcPmIService service = new xxx.cdc_pm_i.CdcPmIService();
    xxx.cdc_pm_i.CdcPmI port = service.getCdcPmIPort();
    // TODO process result here
    xxx.cdc_pm_i.Hashtable result = port.getConfig();
    } catch (Exception ex) {
         ex.printStackTrace();
    I'm fairly unexperienced in Web Services and i have no idea why this works for any kind of return object (as long as its serializable) and has this problem with hashtables and hashmaps.
    Any idea on how to solve this?
    Thanks in advance,
    Rui

    Didn't find the solution for this, but any object that contains an Object in its methods / attributes had the same problems, so i just built my own table that only supports Strings and the problem was solved.
    If anyone knows why i had this problem and wants to share a solution, please do so.

  • HashTable cannot be resolved to a Type

    Hey Guys,
    I want to use a HashTable to assign Integer object values to the to String keys defined by the getActionCommand() methods of an array of JButtons. Now I tried to construct a HashTable like this:
    private HashTable<String, Integer> commandParser = new HashTable<String, Integer>();Eclipse gives me the error "HashTable cannot be resolved to a Type" .
    I thought I had done it all as was stated in the APIs. What?s wrong here?
    Sum1 hlp pls i cant figger ths oot ;-)
    EDIT: While I?m here, I get a warning:
    The serializable class BuildPane does not declare a static final serialVersionUID field of type long
    for every one of my classes.
    What is that about? I ignored it because it?s just a warning, but always safe, never sorry.
    Edited by: AikmanAgain on Mar 29, 2008 5:29 AM

    AikmanAgain wrote:
    Hey Guys,
    I want to use a HashTable to assign Integer object values to the to String keys defined by the getActionCommand() methods of an array of JButtons. Now I tried to construct a HashTable like this:
    private HashTable<String, Integer> commandParser = new HashTable<String, Integer>();Eclipse gives me the error "HashTable cannot be resolved to a Type" .
    I thought I had done it all as was stated in the APIs. What?s wrong here?There is no class called HashTable in the JRE. Look again ... and remember Java is case sensitive.
    The serializable class BuildPane does not declare a static final serialVersionUID field of type long
    for every one of my classes.
    What is that about? I ignored it because it?s just a warning, but always safe, never sorry.The serialVersionUID is a field that's used in serialization (as the name and the warning should have suggested).
    Google for any serialization tutorial and you'll learn what it's good for.

  • NullpointerException in java.util.Hashtable.access$100 ???

    Hi folks.
    I am trying to reconstruct a Hashtable using my own way of serialization/deserialization via Java Reflection. It works fine with most classes, but a reconstructed hashtable is seriously screwed up. After reconstruction, it is passed as an argument to a class that uses the putAll-Method, which causes a NullpointerException.
    The root in the stack trace is java.util.Hashtable.access$100 at line 90 in java.util.Hashtable. Unfortunately, if you check the source of hashtable, you will only find the class header on this line.
    Is it correct, that javac creates access-methods for inner classes? What are they used for?
    Any idea what could cause this?

    The exception happens whenever I try methods like toString, putAll or hashCode on the hashtable. The code of the deserialization is just a bit to complex to post here.
    I have been able to track the problem down to the internal creation of creation of an iterator by the hashtable.
    Here is the stack trace:
    Exception in thread "main" java.lang.NullPointerException
    at java.util.Hashtable.access$100(Hashtable.java:90)
    at java.util.Hashtable$EntrySet.iterator(Hashtable.java:592)
    at java.util.Collections$SynchronizedCollection.iterator(Collections.java:1096)
    at java.util.Hashtable.hashCode(Hashtable.java:728)
    at java.util.Hashtable.get(Hashtable.java:315)
    at mypackage.serializer.XMLSerializer.buildXML(XMLSerializer.java:205)
    at mypackage.serializer.XMLSerializer.buildXML(XMLSerializer.java:178)
    at mypackage.serializer.XMLSerializer.main(XMLSerializer.java:66)

  • Java.io.NotSerializableException: java.util.Hashtable$KeySet

    Hi,
    i have a
        private Hashtable<IDInterface, String> globalPeerFarmMap_=new Hashtable<IDInterface,String>();    in one class and it can be serialized OK.
    In another class, however i have a     private Hashtable<IDInterface, PeerBasic> thesePeers_=new Hashtable<IDInterface, PeerBasic>();     and a java.io.NotSerializableException is thrown - on the KeySet it seems.
    However, ID (which implements IDInterface) is serializable (and all its fields are serializable) and it works in the first case.
    Any ideas? Didn't want to be confusing, but if simplistic i will post some code.
    Thanks

    Found it. The compiler didn't provice much info. Somewhere inside PeerBasic, i call keySet on a Hashtable. I don't understand why this cause a problem.

  • Hashtable imcompletely deserialized?!

    If anyone could help me with this I would be most appreciative.
    I appear to have a situation where a serializable class with an internal Hashtable is not deserilizing correctly. The class containing the Hashtable is called PropDb. In PropDb I have this method...
    protected Hashtable  m_names = new Hashtable();
    public synchronized String getStringVal(String key) {
      if ((key != null) && (key.length() != 0))
        return (String)m_names.get(key);
      else
        return null;
    }Now here is the exception that is sometimes thrown...
    java.lang.NullPointerException
            at java.util.Hashtable.get(Unknown Source)
            at util.PropertyDB.getString(PropertyDB.java:635)Given that the key is not null, and looking at the source for Hashtable... the only other entities in Hashtable.get() that could throw the NullPointer are the internal data array or one of the data items in the data array!
    The reason I'm suspecting the serializing/deserializing is because it this NullPointer seems to come up "randomly"-- often enough to be a problem, but with no identifiable pattern!! So, can anyone tell me there are know issues with Hashtables deserializing in an incorrect state?
    Thank you very much.

    Hi there,
    I just wanted to mention that Hashtable's actions are strongly
    dependent by the hashcodes of the keys. Let's say that your
    KEY objects don't have constant hashCodes. Then the result of
    get() method is often wrong 'cause of the formula
         int hash = key.hashCode();
         int index = (hash & 0x7FFFFFFF) % tab.length;
       So if you want to serialize /deserialize Hashtable , I recommend you
    to override the hashCode() method of you Keys and write it in a way
    that gives you assurance that your key's hashcodes will remain constant after serialize/deserialize
    regards, Kaloyan

  • Filesystem-based Hashtable

    I need to store a lot of data in an associative memory. Does anyone know of some HashMap / HashTable or other associative memory equivalent that uses the file system instead of RAM for storage of the data (the data needs only be stored during one java session but is a few GB large, so only the file system can serve as storage space).
    So far I found JDBMHashtable on Sourceforge, however, its implementation is lousy and very slow.
    Cheers,
    Andreas

    depending on your data-access needs, perhaps this would work ?import java.util.HashMap;
    class BufferedFileHashMap {
         private int bufferSize;
         private HashMap mymap;
         private volatile int additionCount = 0;
         private int buffered = 0;
         public BufferedFileHashMap(int bufferSize){
              mymap               = new HashMap(bufferSize);
              this.bufferSize     = bufferSize;
         public Object put(Object key, Object obj){
              if(additionCount == bufferSize){
                   buffered++;
                   // serialize mymap and get a new one
                   mymap = new HashMap();
              additionCount++;
              return mymap.put(key, obj);
         public Object get(Object key){
              Object obj;
              // check current map ...
              obj = mymap.get(key);
              if(obj != null)
                   return obj;
              // save current map to a temp
              // file and read in previously
              // serialized maps.
              for(int k = 0; k < buffered; k++){
                   obj = mymap.get(key);
                   if(obj != null)
                        break;
                   // read in next
              // read back in the current map
              // from the temp location
              return obj;
    public class Test {
         public static void main(String[] args){
              BufferedFileHashMap map = new BufferedFileHashMap(1000); // buffer 1000 objects
    } allthought, just a thought (never done this before), will the hashmap serialize
    all the objects who are also in the map ... ? hmm, perhaps it won't and potentially the
    reason this is a big problem, anyway.

  • Serialization error when using Jheadstart LOV's

    I am using Jheadstart 11.1.1.4.26 and JDev 11.1.1.5
    I have 2 applications, One of them uses JHeadstart LOV's and drop downs throught and has no errors. The other application gets a serialization error on the task flow at runtime if I use a JHeadstart LOV. If I use all ADF Model LOV's it is happy.
    I have spent hours comparing the 2 applications looking for what is causing the serialization error on the one app but not the other. I was under the impression that upgrading to the latest jheadstart fixed this problem on the good app. Upgrading has not fixed the other one though.
    Can anyone shed some light on this for me?
    Thanks,
    Jim
    <SessionBasedScopeMap> <writeScopeMap> ADFc: Scope object serialization failed (object not serializable), scope='pageFlowScope[WEB-INF/adfc-config-CgRefCodesDescriptor2.xml#CgRefCodesDescriptor2TaskFlow]', objectKey='jhsLovPopup', objectType='oracle.jheadstart.controller.jsf.bean.UIComponentBinder'.
    <SessionBasedScopeMap> <writeScopeMap>
    java.io.NotSerializableException: oracle.jheadstart.controller.jsf.bean.UIComponentBinder
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at oracle.adfinternal.controller.util.Utils.verifySerializable(Utils.java:341)
         at oracle.adfinternal.controller.state.SessionBasedScopeMap.writeScopeMap(SessionBasedScopeMap.java:122)
         at oracle.adfinternal.controller.state.PageFlowScope.writeObject(PageFlowScope.java:156)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at java.util.concurrent.ConcurrentHashMap.writeObject(ConcurrentHashMap.java:1247)
         at sun.reflect.GeneratedMethodAccessor249.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at java.util.Hashtable.writeObject(Hashtable.java:824)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at weblogic.servlet.internal.session.SessionData.writeExternal(SessionData.java:1095)
         at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1429)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1398)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at weblogic.servlet.internal.session.FileSessionContext.sync(FileSessionContext.java:407)
         at weblogic.servlet.internal.ServletRequestImpl$SessionHelper.syncSession(ServletRequestImpl.java:2860)
         at weblogic.servlet.internal.ServletRequestImpl$SessionHelper.syncSession(ServletRequestImpl.java:2835)
         at weblogic.servlet.internal.ServletResponseImpl$1.run(ServletResponseImpl.java:1485)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:1479)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1462)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    <SessionBasedScopeMap> <writeScopeMap> ADFc: Scope object serialization failed (object not serializable), scope='pageFlowScope[WEB-INF/adfc-config-CgRefCodesDescriptor2.xml#CgRefCodesDescriptor2TaskFlow]', objectKey='jhsLovPopup', objectType='oracle.jheadstart.controller.jsf.bean.UIComponentBinder'.
    <SessionBasedScopeMap> <writeScopeMap>
    java.io.NotSerializableException: oracle.jheadstart.controller.jsf.bean.UIComponentBinder
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at oracle.adfinternal.controller.util.Utils.verifySerializable(Utils.java:341)
         at oracle.adfinternal.controller.state.SessionBasedScopeMap.writeScopeMap(SessionBasedScopeMap.java:122)
         at oracle.adfinternal.controller.state.PageFlowScope.writeObject(PageFlowScope.java:156)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at java.util.concurrent.ConcurrentHashMap.writeObject(ConcurrentHashMap.java:1247)
         at sun.reflect.GeneratedMethodAccessor249.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at java.util.Hashtable.writeObject(Hashtable.java:824)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at weblogic.servlet.internal.session.SessionData.writeExternal(SessionData.java:1095)
         at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1429)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1398)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
         at weblogic.servlet.internal.session.FileSessionContext.sync(FileSessionContext.java:407)
         at weblogic.servlet.internal.ServletRequestImpl$SessionHelper.syncSession(ServletRequestImpl.java:2860)
         at weblogic.servlet.internal.ServletRequestImpl$SessionHelper.syncSession(ServletRequestImpl.java:2835)
         at weblogic.servlet.internal.ServletResponseImpl$1.run(ServletResponseImpl.java:1485)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:1479)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1462)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

    Thanks Stephen, You jarred my memory. It was the weblogic.xml settings. In the application without the serialization error I had commented out some persistence settings. When I did the same with the problem application the serialization error went away.
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd" xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
    <!--
    If you change this file, make sure to change it's counterpart in src/main/deployment/weblogic.xml
    -->
    <!-- Comment out persistent store to fix serialization problem with JHS Lov's
    <session-descriptor>
    <persistent-store-type>file</persistent-store-type>
    <persistent-store-dir>/tmp</persistent-store-dir>
    </session-descriptor>
    -->
    </weblogic-web-app>

  • POF Serialization Issue (HashMap)

    Hi.
    It looks like the following use, produced EOFException error in java serialization.
    I couldn't find any clear documentation regarding whether readMap (java) should be paired to readDictionary (.net) for pof, but currently by using a type pair of Dictionary<String, Double> in .NET side and HashMap<String, Double> in java we started getting the error below.
    Is it a wrong use? Should Hashtable be used instead? Or some other collection? Please advise.
    Error: An exception occurred while decoding a Message for Service=Proxy:ExtendTcpProxyService:TcpAcceptor received from: TcpConnection(Id={CUT}, Open=true, Member(Id=0, Timestamp=3981-11-15 06:40:05.166, Address=10.111.12.147:0, MachineId=0, Location={CUT}, Role=.NET RTC client), {CUT}): java.io.EOFException
         at com.tangosol.io.nio.ByteBufferReadBuffer$ByteBufferInput.readByte(ByteBufferReadBuffer.java:340)
         at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readUnsignedByte(AbstractReadBuffer.java:435)
         at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readPackedInt(AbstractReadBuffer.java:560)
         at com.tangosol.io.MultiBufferReadBuffer$MultiBufferInput.readPackedInt(MultiBufferReadBuffer.java:683)
         at com.tangosol.io.pof.PofBufferReader.readAsUniformObject(PofBufferReader.java:3344)
         at com.tangosol.io.pof.PofBufferReader.readMap(PofBufferReader.java:2537)
    Java Pof where it occurs:
    writer.writeMap(40, getMyDict());
    setMyDict((HashMap<String, Double>)reader.readMap(40, new HashMap<String, Double>()));
         public HashMap<String, Double> getMyDict() {
              return myDict;
         public void setMyDict(HashMap<String, Double> MyDict) {
              this.myDict = MyDict;
    .NET Pof:
    writer.WriteDictionary<String, Double>(40, MyDict);
    MyDict = ((Dictionary<String, Double>)reader.ReadDictionary<String, Double>(40, new Dictionary<String, Double>()));
    public Dictionary<String, Double> MyDict
    get { return myDict; }
    set { myDict = value; }
    Notes: If it helps, 40 is the last pof index on that object. The error appears sometime, not constantly based on data.

    AntonZ wrote:
    Hi.
    It looks like the following use, produced EOFException error in java serialization.
    I couldn't find any clear documentation regarding whether readMap (java) should be paired to readDictionary (.net) for pof, but currently by using a type pair of Dictionary<String, Double> in .NET side and HashMap<String, Double> in java we started getting the error below.
    Is it a wrong use? Should Hashtable be used instead? Or some other collection? Please advise.
    Error: An exception occurred while decoding a Message for Service=Proxy:ExtendTcpProxyService:TcpAcceptor received from: TcpConnection(Id={CUT}, Open=true, Member(Id=0, Timestamp=3981-11-15 06:40:05.166, Address=10.111.12.147:0, MachineId=0, Location={CUT}, Role=.NET RTC client), {CUT}): java.io.EOFException
         at com.tangosol.io.nio.ByteBufferReadBuffer$ByteBufferInput.readByte(ByteBufferReadBuffer.java:340)
         at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readUnsignedByte(AbstractReadBuffer.java:435)
         at com.tangosol.io.AbstractReadBuffer$AbstractBufferInput.readPackedInt(AbstractReadBuffer.java:560)
         at com.tangosol.io.MultiBufferReadBuffer$MultiBufferInput.readPackedInt(MultiBufferReadBuffer.java:683)
         at com.tangosol.io.pof.PofBufferReader.readAsUniformObject(PofBufferReader.java:3344)
         at com.tangosol.io.pof.PofBufferReader.readMap(PofBufferReader.java:2537)
    Java Pof where it occurs:
    writer.writeMap(40, getMyDict());
    setMyDict((HashMap<String, Double>)reader.readMap(40, new HashMap<String, Double>()));
         public HashMap<String, Double> getMyDict() {
              return myDict;
         public void setMyDict(HashMap<String, Double> MyDict) {
              this.myDict = MyDict;
    .NET Pof:
    writer.WriteDictionary<String, Double>(40, MyDict);
    MyDict = ((Dictionary<String, Double>)reader.ReadDictionary<String, Double>(40, new Dictionary<String, Double>()));
    public Dictionary<String, Double> MyDict
    get { return myDict; }
    set { myDict = value; }
    Notes: If it helps, 40 is the last pof index on that object. The error appears sometime, not constantly based on data.How is the class containing the map serialized? Is it a PortableObject or do you use a PofSerializer for serializing it? If you use a PofSerializer, please verify that you did not forget the writeRemainder / readRemainder calls from the end of the serialize/deserialize methods.
    Best regards,
    Robert

  • Very strange serialization problem(in what should be a simple solution)

    I'm trying to serialize a hashTable. And i'm trying to do it the same way that I serialized my binaryTree(which had no problems)
    But, for some reason it isn't working. I'm getting a SER file of only 3kb, and when I try to read the file after writing it my hashTable is coming out null.
    Here is a few code snippets:
    public class DictionaryController implements Serializable
         private static final long serialVersionUID = 1L;
         private HashTable hash;
         private Input inputer;
         private RandomAccessFile raf;
         public DictionaryController()
              if(checkDictionary() == true)
                   try
                        FileInputStream inFile = new FileInputStream("res/dictionaryHash.ser");
                        ObjectInputStream inStream = new ObjectInputStream(inFile);
                        hash = (HashTable) inStream.readObject();
                        inStream.close();
                   catch(IOException ioe)
                   catch(ClassNotFoundException cnfe)
              else
                   hash = new HashTable(50000, 0.8);
                   createRandomDictionary();
         }This is where I try to open it. when I say hash = new HashTable, hash is coming as null when I debug it.
         public void save()
              try
                   FileOutputStream outFile = new FileOutputStream("res/dictionaryHash.ser");
                   ObjectOutputStream outStream = new ObjectOutputStream(outFile);
                   outStream.writeObject(hash);
                   outStream.close();
              catch(IOException ioe)
         }That is the save. It only writes the file to the hard drive when I close the GUI.
    I've got all of my other classes implementing serializable, so I really can't figure out what is wrong.
    Anyone have any ideas? I have long values being stored in my hashTable, but all primitives are already Serializable right??
    argg. this seems like it should be such a simple problem but it just won't work. And its almost exactly the same as what I did before...

    Yeah, my fault for leaving the catch statements empty.
    Anyway, it is the output stream IO that is throwing the exception
    What do you mean by: You're probably hiding an instance variable with a member variable, but it's impossible to tell from the little bit of code you've shown.
    I can print out more code just need to know what stuff to post.
    Here is what i get from the printstacktrace:
    java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: hashTable.HashTable$TableEntry
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1278)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
         at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1603)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1271)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
         at dictionary.DictionaryController.<init>(DictionaryController.java:50)
         at dictionary.MainClass.main(MainClass.java:11)
    Caused by: java.io.NotSerializableException: hashTable.HashTable$TableEntry
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
         at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1224)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1050)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
         at dictionary.DictionaryController.save(DictionaryController.java:157)
         at dictionary.DictionaryGUI$ButtonHandler.actionPerformed(DictionaryGUI.java:91)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
         at java.awt.Component.processMouseEvent(Component.java:5100)
         at java.awt.Component.processEvent(Component.java:4897)
         at java.awt.Container.processEvent(Container.java:1569)
         at java.awt.Component.dispatchEventImpl(Component.java:3615)
         at java.awt.Container.dispatchEventImpl(Container.java:1627)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
         at java.awt.Container.dispatchEventImpl(Container.java:1613)
         at java.awt.Window.dispatchEventImpl(Window.java:1606)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

  • Circular references in Hashtable

    Hi,
    I was wondering if anyone could help me in determining when circular references appear in java.util.Hashtable I have written a class that serializes any arbitrary java object into XML. The problem occurs when the object contains many references to Hashtables. The serializer does not know how to handle circular references and goes into an infinite loop causing a stack overflow. Any help would be greatly appreciated.

    Hi.
    The solution is simple: keep all the processed objects in a set or map. Before sending an object check if it was already processed. If not, process it. If yes, place a reference in the XML file that will enable you to read find it during the read.
    Java Serialization uses a "serial number" for the objects it serializes. It keeps something like an HashMap of the objects already serialized. When writing, if it finds an object already writen it only writes its serial number. When reading a serial number it uses a map of the objects already read to find the object.
    Hope this helps,
    Nuno

  • Store a Hashtable in a cookie

    Hi.
    is it possible to store a Hashtable (or other objects) in a cookie?
    i have only found the method ck.addCookie("name", value);
    where value is a String.
    thanks for your help
    bye

    thankx for your help
    i have already stored in the cookie a string containing all the values i want and then i parse it to get them, but i didn't know if there was a better method.
    the problem is that a user can edit the cookie and modify its value.
    is it correct to create a cookie for every value i want to store?
    i need it to create a discussion forum and let user do the autologin.
    i need to store a value in a cookie to understand if the user choose to login automatically or not.
    but i need also a value that represents the user id to create a session variable. and also a password because if i don't put the password in the cookie every user can login automatically changing manually the value of the user id in the cookie.
    i read something about serialize.
    can serialize help me to hide the id user in the cookie if i store only and not the password?
    how can i use serialize to write in a cookie an hashtable?
    there are a lot of problems.........
    thanks for your help
    bye

  • Object Serialization and IO Error

    Hi,
    I am trying to serialize 3 hashtable objects, with serializable keys and elements, on to disk. Here is a snippet of the code disk management code:
         public void loadData(StoreManager s_man) {
              // read from disk
              Hashtable o = (Hashtable)readObjects();
              Hashtable c = (Hashtable)readClasses();
              Hashtable i = (Hashtable)readIndex();
              //Hashtable e = (Hashtable)readEnv();
              Integer id = (Integer)readEnv();
              // set the store manager objects
              s_man.setObjects(o);
              s_man.setClasses(c);
              s_man.setIndex(i);
              Env.setCurrentID(id);
    Here is what the readObject method looks like:
         * Deserialize disk data and return Object data.
         public synchronized Object readObjects() {
              if (!objectdatafile.exists())
                   return null;
              Object o = new Object();
              try {
                   FileInputStream istream = new FileInputStream(objectdatafile);
                   ObjectInputStream pack = new ObjectInputStream(istream);
                   o = pack.readObject();
                   istream.close();
              catch (Exception e) {
                   e.printStackTrace();
    Occasionally, when starting the program (i.e. when it initially reads all data from disk), I am getting the following exceptions:
    java.io.EOFException
    at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2426)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1238)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:325)
    at java.util.Hashtable.readObject(Hashtable.java:799)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:42)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:28)
    at java.lang.reflect.Method.invoke(Method.java:327)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:812
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1736)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
    639)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1267)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:325)
    at DiskManager.readObjects(DiskManager.java:165)
    at DiskManager.loadData(DiskManager.java:42)
    at LoadDataAction.run(LoadDataAction.java:30)
    at java.lang.Thread.run(Thread.java:539)
    java.lang.ClassCastException: java.lang.Object
    at DiskManager.loadData(DiskManager.java:42)
    at LoadDataAction.run(LoadDataAction.java:30)
    at java.lang.Thread.run(Thread.java:539)
    I would like to repeat that I am not getting this error everytime, but about once every two runs. Please share your feelings about possible errors I am making or if there is an inherent bug with serialization of hashtables.
    Thanks

    the java.io.EOFException looks like you did not properly close the stream on writing. to me this seems like there is an error in the writing code rather than the reading code. although there are some things you can improve...
    robert

Maybe you are looking for