Exception: invalid stream header:

518 views
Skip to first unread message

Amit Gupta

unread,
Aug 12, 2013, 6:51:51 AM8/12/13
to memc...@googlegroups.com, Raghuven...@spicedigital.in, Devende...@spicedigital.in, amit....@spicedigital.in, Ritika Gupta
Hi All,
        I am using the MemCachedClient for the storing the class object by using the Serialization.
        when i getting the object using 
        MemCachedClient mcc1=new MemCachedClient();
        mcc1.get(0) metthod it will show the below error.
        
        88 [main] ERROR com.danga.MemCached.MemCachedClient - ++++ exception thrown while trying to get object from cache for key: TestClass
88 [main] ERROR com.danga.MemCached.MemCachedClient - test$TestClass
java.io.IOException: test$TestClass
at com.schooner.MemCached.ObjectTransCoder.decode(Unknown Source)
at com.schooner.MemCached.AscIIClient.get(Unknown Source)
at com.schooner.MemCached.AscIIClient.get(Unknown Source)
at com.schooner.MemCached.AscIIClient.get(Unknown Source)
at com.danga.MemCached.MemCachedClient.get(Unknown Source)
at test.main(test.java:56)
        i am also  trying the another way for storing the class object it will also show the below error.  
        Exception in thread "main" java.io.StreamCorruptedException: invalid stream header: EFBFBDEF
        at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:802)
        at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)
        at amit.main(amit.java:96)
        
       following i am also giving the application source.Kindly Please tell where i  am stuck ?
       how can be getting the storing class object using the MemCachedClient ?
       
import com.danga.MemCached.MemCachedClient;
import com.danga.MemCached.SockIOPool;
import java.util.HashMap;
import java.io.*;
import java.lang.*;
public class amit
{
protected static MemCachedClient mcc1=new MemCachedClient();
public static void main(String args[]) throws IOException, ClassNotFoundException
{



String [] servers={ "localhost:11211",};
Integer []weights={1};
SockIOPool pool=SockIOPool.getInstance();
pool.setServers(servers);
pool.setWeights(weights);
pool.setInitConn(5);
pool.setMinConn(5);
pool.setMaxConn(250);
pool.setMaxIdle(1000*60*60*6);
pool.initialize();
pool.setHashingAlg(SockIOPool.NEW_COMPAT_HASH);

mcc1.setSanitizeKeys(true);


//ReadWriteObject inputObject = new ReadWriteObject(18, "Amit", "gupta");

Ctest inputObject =new Ctest();

System.out.println("inputObject of CTest value "+inputObject+"\n");

ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(inputObject);
byte[] rawData = baos.toByteArray();


String rawString = new String(rawData);


mcc1.set("name4",rawString);
String rawS=mcc1.get(args[0]).toString();

byte[] byteArrayFromString =rawS.getBytes();
System.out.println("*byteArrayFromString*"+byteArrayFromString);
ByteArrayInputStream bais = new ByteArrayInputStream(byteArrayFromString);
System.out.println("**SyteArrayInputStream**"+bais);
ObjectInputStream ois = new ObjectInputStream(bais);
System.out.println(" ***ObjectInputStream*** "+ois);
Object outputObject = ois.readObject();
        System.out.println("outputObject value is "+outputObject);


}


}

class Ctest implements Serializable
{


}




Thanks & Regards
Amit gupta
Reply all
Reply to author
Forward
0 new messages