StreamCorruptedException invalid type code: 01

ok here's the deal. this is another one of those "help me, objectinput/outputstream sucks" anyways, i'm making a program which will play a board game between two computers over a ServerSocket network and I'm using a dataTransfer class to hold any chat messages (there's a chat box incorporated in the UI), and the matrices of the different players' pieces. It was working fine until I added in the matrices. It also works fine when I run two instances of the program on the localhost, but when it's on two seperate computers I get a StreamCorruptedException error on the receiving end at this line:
input=(dataTransfer)in.readObject();
here's what my dataTransfer class looks like:
public class dataTransfer implements Serializable {
     private String s;
     private boolean chat;
     private int[][]hostPieces;
     private int[][]clientPieces;
     public dataTransfer(String s1, int[][]p1,int[][]p2, boolean c)
          chat=c;
          s=s1;
          hostPieces=p1;
          clientPieces=p2;
     public dataTransfer(int[][]p1,int[][]p2)
          chat=false;
          hostPieces=p1;
          clientPieces=p2;
     public String getString(){return s;}
     public boolean isChat(){return chat;}
     public int[][] getHostPieces()
          return hostPieces;
     public int[][] getClientPieces()
          return clientPieces;
}I'm guessing that there's something about matrices that will not allow me to send them over the ObjectOutputStream and/or receive them on the ObjectInputStream. Any tips, suggestions, comments?

ok, here's my connection method, which is only called once and which sets up my socket and in and out streams
public void connect()
    if(isHost){
        while(!connected){
    try{
    srvr=new ServerSocket(1234);
    skt=srvr.accept();
    if(skt.isConnected())connected=true;}catch(Exception e){}}}
    else{
        while(!connected){
            try{
                skt=new Socket(hostIP,1234);
                if(skt.isConnected())connected=true;
            }catch(Exception e){e.printStackTrace();}
    xtext.append("Computer: Connected"+"\n");
    if(skt.isConnected()){
    try{
     out=new ObjectOutputStream(skt.getOutputStream());
    in=new ObjectInputStream(skt.getInputStream());
    }catch(Exception e){e.printStackTrace();}}
}and here's my method which sends the text. while the actual dataTransfer class contains matrices, i've only gotten to the point of sending the text messages but even that's not working
public void SendText(String s)
data=new dataTransfer(s+"\n",myPieces,myPieces,true);
    try{
    out.writeObject(data);
    out.flush();
    out.reset();}catch(Exception e){e.printStackTrace();}
}and here is the code that's giving me so much trouble
while(!inGame)
         if(connected){
         try{
                input=(dataTransfer)in.readObject();
                System.out.println("hello");
                }catch(Exception e){e.printStackTrace();}
                if(input!=null)xtext.append("Opponent: "+input.getString());}
            repaint();
        }hope that's decently clear. any help is much appreciated

Similar Messages

  • Hi,I'm Chinese.java.io.StreamCorruptedException: invalid type code: 6A?

    Hello! please help me, thanks! I'm Chinese.first to the sun forums.My English is bad,so sorry!
    你好!感谢你的帮助!第一次来到sun 论坛来提问,很激动啊,呵呵。
    java.io.StreamCorruptedException: invalid type code: 6A
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at controller.NetController$Receiver.run(NetController.java:88)
    at java.lang.Thread.run(Thread.java:619)
    java.io.StreamCorruptedException: invalid type code: 6A
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at controller.NetController$Receiver.run(NetController.java:88)
    at java.lang.Thread.run(Thread.java:619)
    Exception in thread "Thread-3" java.lang.NullPointerException
    at controller.DoubleModeController.updateYourCtrl(DoubleModeController.java:127)
    at controller.DoubleModeController.receiveObj(DoubleModeController.java:123)
    at controller.NetController$Receiver.run(NetController.java:92)
    at java.lang.Thread.run(Thread.java:619)
    下面是NetCotroller类的一个内部类,负责接收数据:
    This is a inner class of NetCotroller class, it receive datas:
    Java code
    private class Receiver implements Runnable {
            @Override
            public void run() {
                while(isRunning) {
                    ObjectInputStream ois = null;
                    try {
                        byte[] receiveBytes = new byte[1024*2];
                        dp = new DatagramPacket(receiveBytes, receiveBytes.length);
                        ds.receive(dp);
                        System.out.println("receive ...@_@");
                        ByteArrayInputStream bais = new ByteArrayInputStream(receiveBytes);
                        ois = new ObjectInputStream(bais);
                       //到下面这句时,就抛出了那异常!
               // this sentence throw the Exception
                        receiveObj = ois.readObject();
                        ois.close();
                        ncl.receiveObj((Object[])receiveObj);
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (ClassNotFoundException e) {
                        e.printStackTrace();
        }

    1.
    I changed the code to this(when datagram was fragmented, just leave it alone,and back to "ds.receive(dp);" ):
    Is it OK?
    private class Receiver implements Runnable {
    @Override
    public void run() {
    boolean isCorrupted = false;//changed
    while(isRunning) {
    isCorrupted = false;//changed
    ObjectInputStream ois = null;
    Object o = null;
    try {
    byte[] receiveBytes = new byte[1024*5];
    dp = new DatagramPacket(receiveBytes, receiveBytes.length);
    ds.receive(dp);
    ByteArrayInputStream bais = new ByteArrayInputStream(receiveBytes);
    ois = new ObjectInputStream(bais);
    o = ois.readObject();
    } catch (IOException e) {
    isCorrupted = true;//changed
    System.out.println(o);
    System.out.println("IOException---NetController--receiver");
    // e.printStackTrace();
    } catch (ClassNotFoundException e) {
    System.out.println("ClassNotFoundException---NetController--receiver");
    if(!isCorrupted) {//changed
    System.out.println("receive ...@_@..." + Arrays.toString((Object[])o));
    ncl.receiveObj((Object[])o);
    }2.Is there a src of "Russia Block of Net"?Please send it to my e-mail ([[email protected]|mailto:[email protected]]), thank you very much!
    Edited by: HolleWorld on Jan 2, 2010 1:51 AM

  • StreamCorruptedException: invalid type code: AC

    I get the following error in java 6 running with tomcat 5.5.17.
    Error while deserializing the wrapped object: java.io.StreamCorruptedException: invalid type code: AC
    This does not happen in java 5 and my colleague does not get it with 5 or 6. We have checked our setups and can't see anything different.

    am having the same problem
    Edited by: prabhakar.s87 on Oct 12, 2007 2:27 PM

  • StreamCorruptedException: invalid type code: 00

    I try to do an online game. For this i need send some information to the server at the client. The information is an object who has other object inside. These objects implements Serializable and i overwrite the methods readObject and writeObject but the client send me the following exception: StreamCorruptedException: invalid type code: 00. I send the object with ObjectOutputStream.
    Please i need some help

    public class Jugador implements Serializable{
    Coordenada posicion;At the moment you aren't serializing 'posicion'. Is that deliberate, or a bug? If it's deliberate, make this field transient.
    private void writeObject(java.io.ObjectOutputStream out) throws IOException{
    // Enviamos los atributos a y b en un orden cualquiera.
    out.writeDouble(beta);
    out.writeBoolean(visible);
    private void readObject(java.io.ObjectInputStream in) throws IOException {
    // Leemos los atributos a y b en el mismo orden que los enviamos en writeObject()
    beta = in.readDouble();
    visible= in.readBoolean();
    }Remove both these functions. Serialization already does all that for you. This is just noise, and incorrect noise at that.
    From your other posting your main problem is that you are reading and writing to both a DataInput/OutputStream and an ObjectInput/OutputStream on the same socket. That doesn't work, because of buffering issues. It is also pointless, because ObjectInputStream implements DataInput and ObjectOutputStream implements DataOutput, so all the methods you are calling on the DataInput/OutputStreams are already present in the ObjectInput/OutputStreams. Make this change and the changes suggested above (to both serializable classes) and your problems should disappear.

  • StreamCorruptedException : invalid Type Code AC .. In case of a network app

    Hi
    I am developing a peer-peer application here.
    What i have is a client and a server on each user, both running parallell.
    User A sends an object to User B through an ObjectOutputStream through the main thread.
    User B reads it using an ObjectInputStream and passes the object that it read, to a new ObjectOutputStream, to be passed to User C.
    User C just reads the incoming object using ObjectInputStream.
    This iteration runs successfully for the first run!
    The moment I go for the second iteration using User A, the method on User B throws a "invalid type code AC".
    class Main{
    Socket sock;
    psvm(String args[]){
    Client newCli = new Client();
    newCli.setSock(<Sets the sock after getting the port and IP address from the user>);
    sock = newCli.getSock();
    ObjectOutputStream oos = new ObjectOutputStream(sock.getOutputStream());
    oos.writeObject(new Client());
    Class Server extends thread{
    public void run(){
    while(true){
    ObjectInputStream ois = new ObjectInputStream(sock.getInputStream());
    ois.readObject();
    I read through this post on this forum and "EJP" asks that one OOS and one OIS be maintained per socket.
    So what i did was add a setter method to the Client class which stores the Socket, and called the setter method instead of creating a new ObjectOutputStream object everytime. This way one ObjectOutputStream object would be maintained per socket per client class's instance.
    class Client{
    Socket sock;
    ObjectOutputStream oos;
    //Getter and setter for sock.
    getSock()....
    setSock()....
    //Getter and setter for ObjectOutputStream
    getOos()....
    setOos(){
    oos = new ObjectOutputStream(getSock().getOutputStream());
    When i do this, the initial iteration itself fails.
    I am posting the outline of my code since it is a big file. But if writing out a smaller version of the app and posting it here will help better understand the scenario, then I'll do it.
    I am re-posting this, coz in the previous posts regarding this same issue, i found that people were writing and reading on the application. While mine is a case of a client-server send and receive.
    I am just writing multiple times at the client and reading multiple times at the server. And each time i'm creating a fresh ObjectOutputStream object, and Client object.
    I don't close the streams since that closes the sockets, but i need to keep the sockets open and send multiple objects on the same socket.
    The explanation is a bit lengthy, so let me know if something is not clear. :)
    Thanks
    Akshay

    I'd be grateful if someone can throw some light on this issue, i have to get beyond this ASAP, and i cannot find a workaround at all.. :/

  • Getting "invalid type: 169" errors when using POF with Push Replication

    I'm trying to get Push Replication - latest version - running on Coherence 3.6.1. I can get it working fine if I don't use POF with my objects, but when trying to use POF format for my objects I get this:
    2011-02-11 13:06:00.993/2.297 Oracle Coherence GE 3.6.1.1 <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
    2011-02-11 13:06:01.149/2.453 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded POF configuration from "file:/C:/wsgpc/GlobalPositionsCache/resource/coherence/pof-config.xml"
    2011-02-11 13:06:01.149/2.453 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6/coherence/lib/coherence.jar!/coherence-pof-config.xml"
    2011-02-11 13:06:01.149/2.453 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6-pushreplication/coherence-3.6-common-1.7.3.20019.jar!/coherence-common-pof-config.xml"
    2011-02-11 13:06:01.165/2.469 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6-pushreplication/coherence-3.6-messagingpattern-2.7.4.21016.jar!/coherence-messagingpattern-pof-config.xml"
    2011-02-11 13:06:01.165/2.469 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6-pushreplication/coherence-3.6-pushreplicationpattern-3.0.3.20019.jar!/coherence-pushreplicationpattern-pof-config.xml"
    2011-02-11 13:06:01.243/2.547 Oracle Coherence GE 3.6.1.1 <D5> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Service DistributedCacheForSequenceGenerators joined the cluster with senior service member 1
    2011-02-11 13:06:01.258/2.562 Oracle Coherence GE 3.6.1.1 <D5> (thread=DistributedCache:DistributedCacheForLiveObjects, member=1): Service DistributedCacheForLiveObjects joined the cluster with senior service member 1
    2011-02-11 13:06:01.274/2.578 Oracle Coherence GE 3.6.1.1 <D5> (thread=DistributedCache:DistributedCacheForSubscriptions, member=1): Service DistributedCacheForSubscriptions joined the cluster with senior service member 1
    2011-02-11 13:06:01.290/2.594 Oracle Coherence GE 3.6.1.1 <D5> (thread=DistributedCache:DistributedCacheForMessages, member=1): Service DistributedCacheForMessages joined the cluster with senior service member 1
    2011-02-11 13:06:01.305/2.609 Oracle Coherence GE 3.6.1.1 <D5> (thread=DistributedCache:DistributedCacheForDestinations, member=1): Service DistributedCacheForDestinations joined the cluster with senior service member 1
    2011-02-11 13:06:01.305/2.609 Oracle Coherence GE 3.6.1.1 <D5> (thread=DistributedCache:DistributedCacheWithPublishingCacheStore, member=1): Service DistributedCacheWithPublishingCacheStore joined the cluster with senior service member 1
    2011-02-11 13:06:01.321/2.625 Oracle Coherence GE 3.6.1.1 <D5> (thread=DistributedCache, member=1): Service DistributedCache joined the cluster with senior service member 1
    2011-02-11 13:06:01.461/2.765 Oracle Coherence GE 3.6.1.1 <Info> (thread=Proxy:ExtendTcpProxyService:TcpAcceptor, member=1): TcpAcceptor now listening for connections on 166.15.224.91:20002
    2011-02-11 13:06:01.461/2.765 Oracle Coherence GE 3.6.1.1 <D5> (thread=Proxy:ExtendTcpProxyService:TcpAcceptor, member=1): Started: TcpAcceptor{Name=Proxy:ExtendTcpProxyService:TcpAcceptor, State=(SERVICE_STARTED), ThreadCount=0, Codec=Codec(Format=POF), Serializer=com.tangosol.io.DefaultSerializer, PingInterval=0, PingTimeout=0, RequestTimeout=0, SocketProvider=SystemSocketProvider, LocalAddress=[/166.15.224.91:20002], SocketOptions{LingerTimeout=0, KeepAliveEnabled=true, TcpDelayEnabled=false}, ListenBacklog=0, BufferPoolIn=BufferPool(BufferSize=2KB, BufferType=DIRECT, Capacity=Unlimited), BufferPoolOut=BufferPool(BufferSize=2KB, BufferType=DIRECT, Capacity=Unlimited)}
    2011-02-11 13:06:01.461/2.765 Oracle Coherence GE 3.6.1.1 <D5> (thread=Proxy:ExtendTcpProxyService, member=1): Service ExtendTcpProxyService joined the cluster with senior service member 1
    2011-02-11 13:06:01.461/2.765 Oracle Coherence GE 3.6.1.1 <Info> (thread=main, member=1):
    Services
    ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=3.6, OldestMemberId=1}
    InvocationService{Name=Management, State=(SERVICE_STARTED), Id=1, Version=3.1, OldestMemberId=1}
    PartitionedCache{Name=DistributedCacheForSequenceGenerators, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
    PartitionedCache{Name=DistributedCacheForLiveObjects, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
    PartitionedCache{Name=DistributedCacheForSubscriptions, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
    PartitionedCache{Name=DistributedCacheForMessages, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
    PartitionedCache{Name=DistributedCacheForDestinations, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
    PartitionedCache{Name=DistributedCacheWithPublishingCacheStore, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
    PartitionedCache{Name=DistributedCache, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
    ProxyService{Name=ExtendTcpProxyService, State=(SERVICE_STARTED), Id=9, Version=3.2, OldestMemberId=1}
    Started DefaultCacheServer...
    2011-02-11 13:08:27.894/149.198 Oracle Coherence GE 3.6.1.1 <Error> (thread=Proxy:ExtendTcpProxyService:TcpAcceptor, member=1): Failed to publish EntryOperation{siteName=csfb.cs-group.com, clusterName=SPTestCluster, cacheName=source-cache, operation=Insert, publishableEntry=PublishableEntry{key=Binary(length=32, value=0x15A90F00004E07424F4F4B303038014E08494E535430393834024E0345535040), value=Binary(length=147, value=0x1281A30115AA0F0000A90F00004E07424F4F4B303038014E08494E535430393834024E03455350400248ADEEF99607060348858197BF22060448B4D8E9BE02060548A0D2CDC70E060648B0E9A2C4030607488DBCD6E50D060848B18FC1882006094E03303038402B155B014E0524737263244E1F637366622E63732D67726F75702E636F6D2D535054657374436C7573746572), originalValue=Binary(length=0, value=0x)}} to Cache passive-cache because of
    (Wrapped) java.io.StreamCorruptedException: invalid type: 169 Class:com.oracle.coherence.patterns.pushreplication.publishers.cache.AbstractCachePublisher
    2011-02-11 13:08:27.894/149.198 Oracle Coherence GE 3.6.1.1 <D5> (thread=Proxy:ExtendTcpProxyService:TcpAcceptor, member=1): An exception occurred while processing a InvocationRequest for Service=Proxy:ExtendTcpProxyService:TcpAcceptor: (Wrapped: Failed to publish a batch with the publisher [Active Publisher] on cache [source-cache]) java.lang.IllegalStateException: Attempted to publish to cache passive-cache
         at com.tangosol.util.Base.ensureRuntimeException(Base.java:293)
         at com.oracle.coherence.patterns.pushreplication.publishers.RemoteClusterPublisher$RemotePublishingAgent.run(RemoteClusterPublisher.java:348)
         at com.tangosol.coherence.component.net.extend.proxy.serviceProxy.InvocationServiceProxy.query(InvocationServiceProxy.CDB:6)
         at com.tangosol.coherence.component.net.extend.messageFactory.InvocationServiceFactory$InvocationRequest.onRun(InvocationServiceFactory.CDB:12)
         at com.tangosol.coherence.component.net.extend.message.Request.run(Request.CDB:4)
         at com.tangosol.coherence.component.net.extend.proxy.serviceProxy.InvocationServiceProxy.onMessage(InvocationServiceProxy.CDB:9)
         at com.tangosol.coherence.component.net.extend.Channel.execute(Channel.CDB:39)
         at com.tangosol.coherence.component.net.extend.Channel.receive(Channel.CDB:26)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Peer.onNotify(Peer.CDB:103)
         at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
         at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.IllegalStateException: Attempted to publish to cache passive-cache
         at com.oracle.coherence.patterns.pushreplication.publishers.cache.AbstractCachePublisher.publishBatch(AbstractCachePublisher.java:163)
         at com.oracle.coherence.patterns.pushreplication.publishers.RemoteClusterPublisher$RemotePublishingAgent.run(RemoteClusterPublisher.java:343)
         ... 9 more
    Caused by: (Wrapped) java.io.StreamCorruptedException: invalid type: 169
         at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:265)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService$ConverterKeyToBinary.convert(PartitionedService.CDB:16)
         at com.tangosol.util.ConverterCollections$ConverterInvocableMap.invoke(ConverterCollections.java:2156)
         at com.tangosol.util.ConverterCollections$ConverterNamedCache.invoke(ConverterCollections.java:2622)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.invoke(PartitionedCache.CDB:11)
         at com.tangosol.coherence.component.util.SafeNamedCache.invoke(SafeNamedCache.CDB:1)
         at com.oracle.coherence.patterns.pushreplication.publishers.cache.AbstractCachePublisher.publishBatch(AbstractCachePublisher.java:142)
         ... 10 more
    Caused by: java.io.StreamCorruptedException: invalid type: 169
         at com.tangosol.util.ExternalizableHelper.readObjectInternal(ExternalizableHelper.java:2265)
         at com.tangosol.util.ExternalizableHelper.readObject(ExternalizableHelper.java:2253)
         at com.tangosol.io.DefaultSerializer.deserialize(DefaultSerializer.java:74)
         at com.tangosol.util.ExternalizableHelper.deserializeInternal(ExternalizableHelper.java:2703)
         at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:261)
         ... 16 more
    2011-02-11 13:08:37.925/159.229 Oracle Coherence GE 3.6.1.1 <Error> (thread=Proxy:ExtendTcpProxyService:TcpAcceptor, member=1): Failed to publish EntryOperation{siteName=csfb.cs-group.com, clusterName=SPTestCluster, cacheName=source-cache, operation=Insert, publishableEntry=PublishableEntry{key=Binary(length=32, value=0x15A90F00004E07424F4F4B303038014E08494E535430393834024E0345535040), value=Binary(length=147, value=0x1281A30115AA0F0000A90F00004E07424F4F4B303038014E08494E535430393834024E03455350400248ADEEF99607060348858197BF22060448B4D8E9BE02060548A0D2CDC70E060648B0E9A2C4030607488DBCD6E50D060848B18FC1882006094E03303038402B155B014E0524737263244E1F637366622E63732D67726F75702E636F6D2D535054657374436C7573746572), originalValue=Binary(length=0, value=0x)}} to Cache passive-cache because of
    (Wrapped) java.io.StreamCorruptedException: invalid type: 169 Class:com.oracle.coherence.patterns.pushreplication.publishers.cache.AbstractCachePublisher
    2011-02-11 13:08:37.925/159.229 Oracle Coherence GE 3.6.1.1 <D5> (thread=Proxy:ExtendTcpProxyService:TcpAcceptor, member=1): An exception occurred while processing a InvocationRequest for Service=Proxy:ExtendTcpProxyService:TcpAcceptor: (Wrapped: Failed to publish a batch with the publisher [Active Publisher] on cache [source-cache]) java.lang.IllegalStateException: Attempted to publish to cache passive-cache
         at com.tangosol.util.Base.ensureRuntimeException(Base.java:293)
         at com.oracle.coherence.patterns.pushreplication.publishers.RemoteClusterPublisher$RemotePublishingAgent.run(RemoteClusterPublisher.java:348)
         at com.tangosol.coherence.component.net.extend.proxy.serviceProxy.InvocationServiceProxy.query(InvocationServiceProxy.CDB:6)
         at com.tangosol.coherence.component.net.extend.messageFactory.InvocationServiceFactory$InvocationRequest.onRun(InvocationServiceFactory.CDB:12)
         at com.tangosol.coherence.component.net.extend.message.Request.run(Request.CDB:4)
         at com.tangosol.coherence.component.net.extend.proxy.serviceProxy.InvocationServiceProxy.onMessage(InvocationServiceProxy.CDB:9)
         at com.tangosol.coherence.component.net.extend.Channel.execute(Channel.CDB:39)
         at com.tangosol.coherence.component.net.extend.Channel.receive(Channel.CDB:26)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Peer.onNotify(Peer.CDB:103)
         at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
         at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.IllegalStateException: Attempted to publish to cache passive-cache
         at com.oracle.coherence.patterns.pushreplication.publishers.cache.AbstractCachePublisher.publishBatch(AbstractCachePublisher.java:163)
         at com.oracle.coherence.patterns.pushreplication.publishers.RemoteClusterPublisher$RemotePublishingAgent.run(RemoteClusterPublisher.java:343)
         ... 9 more
    Caused by: (Wrapped) java.io.StreamCorruptedException: invalid type: 169
         at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:265)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService$ConverterKeyToBinary.convert(PartitionedService.CDB:16)
         at com.tangosol.util.ConverterCollections$ConverterInvocableMap.invoke(ConverterCollections.java:2156)
         at com.tangosol.util.ConverterCollections$ConverterNamedCache.invoke(ConverterCollections.java:2622)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.invoke(PartitionedCache.CDB:11)
         at com.tangosol.coherence.component.util.SafeNamedCache.invoke(SafeNamedCache.CDB:1)
         at com.oracle.coherence.patterns.pushreplication.publishers.cache.AbstractCachePublisher.publishBatch(AbstractCachePublisher.java:142)
         ... 10 more
    Caused by: java.io.StreamCorruptedException: invalid type: 169
         at com.tangosol.util.ExternalizableHelper.readObjectInternal(ExternalizableHelper.java:2265)
         at com.tangosol.util.ExternalizableHelper.readObject(ExternalizableHelper.java:2253)
         at com.tangosol.io.DefaultSerializer.deserialize(DefaultSerializer.java:74)
         at com.tangosol.util.ExternalizableHelper.deserializeInternal(ExternalizableHelper.java:2703)
         at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:261)
         ... 16 more
    2011-02-11 13:08:47.940/169.244 Oracle Coherence GE 3.6.1.1 <Error> (thread=Proxy:ExtendTcpProxyService:TcpAcceptor, member=1): Failed to publish EntryOperation{siteName=csfb.cs-group.com, clusterName=SPTestCluster, cacheName=source-cache, operation=Insert, publishableEntry=PublishableEntry{key=Binary(length=32, value=0x15A90F00004E07424F4F4B303038014E08494E535430393834024E0345535040), value=Binary(length=147, value=0x1281A30115AA0F0000A90F00004E07424F4F4B303038014E08494E535430393834024E03455350400248ADEEF99607060348858197BF22060448B4D8E9BE02060548A0D2CDC70E060648B0E9A2C4030607488DBCD6E50D060848B18FC1882006094E03303038402B155B014E0524737263244E1F637366622E63732D67726F75702E636F6D2D535054657374436C7573746572), originalValue=Binary(length=0, value=0x)}} to Cache passive-cache because of
    (Wrapped) java.io.StreamCorruptedException: invalid type: 169 Class:com.oracle.coherence.patterns.pushreplication.publishers.cache.AbstractCachePublisher
    2011-02-11 13:08:47.940/169.244 Oracle Coherence GE 3.6.1.1 <D5> (thread=Proxy:ExtendTcpProxyService:TcpAcceptor, member=1): An exception occurred while processing a InvocationRequest for Service=Proxy:ExtendTcpProxyService:TcpAcceptor: (Wrapped: Failed to publish a batch with the publisher [Active Publisher] on cache [source-cache]) java.lang.IllegalStateException: Attempted to publish to cache passive-cache
         at com.tangosol.util.Base.ensureRuntimeException(Base.java:293)
         at com.oracle.coherence.patterns.pushreplication.publishers.RemoteClusterPublisher$RemotePublishingAgent.run(RemoteClusterPublisher.java:348)
         at com.tangosol.coherence.component.net.extend.proxy.serviceProxy.InvocationServiceProxy.query(InvocationServiceProxy.CDB:6)
         at com.tangosol.coherence.component.net.extend.messageFactory.InvocationServiceFactory$InvocationRequest.onRun(InvocationServiceFactory.CDB:12)
         at com.tangosol.coherence.component.net.extend.message.Request.run(Request.CDB:4)
         at com.tangosol.coherence.component.net.extend.proxy.serviceProxy.InvocationServiceProxy.onMessage(InvocationServiceProxy.CDB:9)
         at com.tangosol.coherence.component.net.extend.Channel.execute(Channel.CDB:39)
         at com.tangosol.coherence.component.net.extend.Channel.receive(Channel.CDB:26)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Peer.onNotify(Peer.CDB:103)
         at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
         at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.IllegalStateException: Attempted to publish to cache passive-cache
         at com.oracle.coherence.patterns.pushreplication.publishers.cache.AbstractCachePublisher.publishBatch(AbstractCachePublisher.java:163)
         at com.oracle.coherence.patterns.pushreplication.publishers.RemoteClusterPublisher$RemotePublishingAgent.run(RemoteClusterPublisher.java:343)
         ... 9 more
    Caused by: (Wrapped) java.io.StreamCorruptedException: invalid type: 169
         at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:265)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService$ConverterKeyToBinary.convert(PartitionedService.CDB:16)
         at com.tangosol.util.ConverterCollections$ConverterInvocableMap.invoke(ConverterCollections.java:2156)
         at com.tangosol.util.ConverterCollections$ConverterNamedCache.invoke(ConverterCollections.java:2622)
         at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.invoke(PartitionedCache.CDB:11)
         at com.tangosol.coherence.component.util.SafeNamedCache.invoke(SafeNamedCache.CDB:1)
         at com.oracle.coherence.patterns.pushreplication.publishers.cache.AbstractCachePublisher.publishBatch(AbstractCachePublisher.java:142)
         ... 10 more
    Caused by: java.io.StreamCorruptedException: invalid type: 169
         at com.tangosol.util.ExternalizableHelper.readObjectInternal(ExternalizableHelper.java:2265)
         at com.tangosol.util.ExternalizableHelper.readObject(ExternalizableHelper.java:2253)
         at com.tangosol.io.DefaultSerializer.deserialize(DefaultSerializer.java:74)
         at com.tangosol.util.ExternalizableHelper.deserializeInternal(ExternalizableHelper.java:2703)
         at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:261)
         ... 16 more
    It seems to be loading my POF configuration file - which also includes the standard Coherence ones as well as those required for PR - just fine, as you can see at the top of the trace.
    Any ideas why POF format for my objects is giving this error (NB. I've tested the POF stuff outside of PR and it all works fine.)
    EDIT: I've tried switching the "publisher" to the "file" publisher in PR. And that works fine. I see my POF format cached data extracted and published to the directory I specify. So the "publish" part seems to work when I use a file-publisher.
    Cheers,
    Steve

    Hi Neville,
    I don't pass any POF config parameters on the command-line. My POF file is called "pof-config.xml" so seems to be picked up by default. The trace I showed in my post shows the file being picked up.
    My POF config file content is as follows:
    <pof-config>
         <user-type-list>
              <!-- Standard Coherence POF types -->
              <include>coherence-pof-config.xml</include>
              <!-- Coherence Push Replication Required POF types -->
    <include>coherence-common-pof-config.xml</include>
    <include>coherence-messagingpattern-pof-config.xml</include>
    <include>coherence-pushreplicationpattern-pof-config.xml</include>
              <!-- User POF types (must be above 1000) -->
              <user-type>
                   <type-id>1001</type-id>
                   <class-name>com.csg.gpc.domain.model.position.trading.TradingPositionKey</class-name>
                   <serializer>
                        <class-name>com.csg.gpc.coherence.pof.position.trading.TradingPositionKeySerializer</class-name>
                   </serializer>
              </user-type>
              <user-type>
                   <type-id>1002</type-id>
                   <class-name>com.csg.gpc.domain.model.position.trading.TradingPosition</class-name>
                   <serializer>
                        <class-name>com.csg.gpc.coherence.pof.position.trading.TradingPositionSerializer</class-name>
                   </serializer>
              </user-type>
              <user-type>
                   <type-id>1003</type-id>
                   <class-name>com.csg.gpc.domain.model.position.simple.SimplePosition</class-name>
                   <serializer>
                        <class-name>com.csg.gpc.coherence.pof.position.simple.SimplePositionSerializer</class-name>
                   </serializer>
              </user-type>
              <user-type>
                   <type-id>1004</type-id>
                   <class-name>com.csg.gpc.coherence.processor.TradingPositionUpdateProcessor</class-name>
              </user-type>
         </user-type-list>
    </pof-config>
    EDIT: I'm running both clusters here from within Eclipse. Here's the POF bits from the startup of the receiving cluster:
    2011-02-11 15:05:22.607/2.328 Oracle Coherence GE 3.6.1.1 <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
    2011-02-11 15:05:22.779/2.500 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded POF configuration from "file:/C:/wsgpc/GlobalPositionsCache/resource/coherence/pof-config.xml"
    2011-02-11 15:05:22.779/2.500 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6/coherence/lib/coherence.jar!/coherence-pof-config.xml"
    2011-02-11 15:05:22.779/2.500 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6-pushreplication/coherence-3.6-common-1.7.3.20019.jar!/coherence-common-pof-config.xml"
    2011-02-11 15:05:22.779/2.500 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6-pushreplication/coherence-3.6-messagingpattern-2.7.4.21016.jar!/coherence-messagingpattern-pof-config.xml"
    2011-02-11 15:05:22.779/2.500 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6-pushreplication/coherence-3.6-pushreplicationpattern-3.0.3.20019.jar!/coherence-pushreplicationpattern-pof-config.xml"
    And here's the start-up POF bits from the sending cluster:
    2011-02-11 15:07:09.744/2.343 Oracle Coherence GE 3.6.1.1 <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
    2011-02-11 15:07:09.916/2.515 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded POF configuration from "file:/C:/wsgpc/GlobalPositionsCache/resource/coherence/pof-config.xml"
    2011-02-11 15:07:09.916/2.515 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6/coherence/lib/coherence.jar!/coherence-pof-config.xml"
    2011-02-11 15:07:09.916/2.515 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6-pushreplication/coherence-3.6-common-1.7.3.20019.jar!/coherence-common-pof-config.xml"
    2011-02-11 15:07:09.916/2.515 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6-pushreplication/coherence-3.6-messagingpattern-2.7.4.21016.jar!/coherence-messagingpattern-pof-config.xml"
    2011-02-11 15:07:09.916/2.515 Oracle Coherence GE 3.6.1.1 <Info> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=1): Loaded included POF configuration from "jar:file:/C:/coherence3.6-pushreplication/coherence-3.6-pushreplicationpattern-3.0.3.20019.jar!/coherence-pushreplicationpattern-pof-config.xml"
    They both seem to be reading my pof-config.xml file.
    I have the following in my sending cluster cache config:
              <sync:provider pof-enabled="true">
                   <sync:coherence-provider />
              </sync:provider>
    And this in the receiving cache config:
    <introduce:config
    file="coherence-pushreplicationpattern-pof-cache-config.xml" />
    Cheers,
    Steve
    Edited by: stevephe on 11-Feb-2011 07:05

  • Java.io.StreamCorruptedException: Type code out of  range, is 63

    Hi,
    i ma using Weblogic 7.0 ......... I got one exception in the weblogic log, Exception is as follows -
    ####<Nov 28, 2006 3:15:54 PM EST> <Info> <EJB> <atnyprd5>
    <XXXServer1> <ExecuteThread: '83' for queue: 'default'> <kernel identity>
    <11864:d63651c3623375dd> <010051> <EJB Exception during invocation from home:
    [email protected]53 threw exception:
    com.xxxxxx.exception.XXXXXXEJBException: MSG: javax.naming.CommunicationException
    [Root exceptionis java.rmi.UnmarshalException: cannot unmarshaling return; nested  exception is:   1990         
    java.io.StreamCorruptedException: Type code out of  range, is 63]null TIME: 0> 1991
    com.xxxxxx.exception.xxxxxxEJBException: MSG: javax.naming.CommunicationException
    [Root exception is java.rmi.UnmarshalException: cannot  unmarshaling return; nested exception is:   1992
    java.io.StreamCorruptedException: Type code out of  range, is 63]null TIME: 0 1993
    at com.xxxxxx.util.EJBUtil.handleSysError (EJBUtil.java:40) 1994
    at com.xxxxxx.util.EJBUtil.handleSysError (EJBUtil.java:59) 1995
    at com.xxxxxx.db.DbAccess.initConnection (DbAccess.java:98) 1996
    at com.xxxxxx.db.DbAccess.<init>(DbAccess.java:37)
    I am getting this exception while fetching a datasource connection from the connection pool of weblogic.
    My applciation is running for past 2 years and we did not got this exception before, So I suspect there is no problem in the code......... where it is going wrong ????
    Please help me in this......
    Thanks and regards

    Hi,
    atleast any idea about what the exception is and what it is related to ???
    Its bit urjent to resolve
    Thankx and Regards

  • Java.io.StreamCorruptedException: Type code out of range, is -20

    Hi ,
    When i am connecting from a client to an EJB running in Weblogic on the localhost , I got the follwoing exception.
    GENERAL-EXCEPTION: java.rmi.UnmarshalException: failed to unmarshal cookie; nest
    ed exception is:
    java.io.StreamCorruptedException: Type code out of range, is -20
    java.rmi.UnmarshalException: failed to unmarshal cookie; nested exception is:
    java.io.StreamCorruptedException: Type code out of range, is -20
    java.io.StreamCorruptedException: Type code out of range, is -20
    at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:1551)
    at java.io.ObjectInputStream.refill(ObjectInputStream.java:1679)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:278)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
    at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedO
    bjectInputStream.java:140)
    at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.ja
    va:91)
    at weblogic.rjvm.ResponseImpl.getReplicaInfo(ResponseImpl.java:171)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
    ef.java:264)
    at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
    ef.java:229)
    Can anyone tell what this type code -20 is?

    www.google.com is your friend.
    http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=Type+code+out+of+range%2C+is+-20&btnG=Google+Search

  • Java.io.StreamCorruptedException: Type code out of range, is 0, BLOB, Weblogic 7, Oracle 8i

    Test message

    Nagaraju wrote:
    Hi
    I am trying to insert a Java Object ( Serialized Bean) into Oracle BLOB. I am getting the following exception when reading back from Blob. Following is the code and the Exception stack is pasted below. I am using weblogic 7.0 Applcation server/Oracle 8.i
    If any body have an idea please let me know.
    Thanks is advance..
    Nagaraju.
    java.io.StreamCorruptedException: Type code out of range, is 0
    at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:1551)
    at java.io.ObjectInputStream.refill(ObjectInputStream.java:1679)
    at java.io.ObjectInputStream.read(ObjectInputStream.java:1655)
    at java.io.DataInputStream.readInt(DataInputStream.java:333)
    at java.io.ObjectInputStream.readInt(ObjectInputStream.java:1975)
    at java.util.SimpleTimeZone.readObject(SimpleTimeZone.java:1437)Hi. Unless you post the whole stacktrace, or at least enough of it to show
    some weblogic or even jdbc classes, we can have no clue what this is about...
    Joe

  • Java.io.StreamCorruptedException: invalid stream header

    I am having a problem with sending two objects (over a socket). I have read in other posts that this could be due to trying to receive incompatible data types but my applications work fine if I send my objects synchronously rather than asynchronously.
    I will try my best to describe what my problem is as my code is very long.
    I have a server and a client application (2 apps). Multiple clients connect to the server and send their details (as an object) to the server. The server then amends the object (adds some more data) and sends it back to the clients. Both the SendObject and ReceiveObject class are threads and I have created a Listener (within the client) that activates when an object is received (asynchronous communication). The Listener method looks to see if the event is an instance of a particular class and casts is as appropriate (as per below).
    public void receivedObject(ReceivedObjectEvent e) {
         ReceiveObjectThread obj = (ReceiveObjectThread) e.getObject();
         if(obj.getObject() instanceof Player) {
              thePlayer = (Player) obj.getObject();
              theTable.setHandData(thePlayer.getHand());
         if(obj.getObject() instanceof GameData) {
              gameData = (GameData) obj.getObject();
              theTable.setPlayerList(gameData.getOpponents());
    }The objects that are passed between applications both implement Serializable.
    This all works fine synchronously object passing. However, if I try and spawn two sendObject threads within the server and the corresponding two receive threads within the client and wait for the Listener to activate (asynchronously) I get the following error:
    java.io.StreamCorruptedException: invalid stream header: 00057372
         at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
         at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
         at ReceiveObjectThread.run(ReceiveObjectThread.java:84)
    java.io.StreamCorruptedException: invalid stream header: ACED0006
         at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
         at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
         at ReceiveObjectThread.run(ReceiveObjectThread.java:84)
    I am sure that this problem is due to my limited knowledge on socket and data transfer. Therefore any help on this one will be gratefully received.

    Hello ejp, your reply is very much appreciated.
    If I explain how I have implemented my sockets you may be able to see where I wrong.
    When a player connects, the client sends the server a �player� object. The server receives the �player� object and passes the socket from which it connected (within the server) to a socket property within the �player� class. Whenever the server needs to send an object to that client (player), it sends the output stream from the socket property within that �player� object. ( player.getSocket().getOutputStream() ).
    Below is the code from the �SendObjectThread� class.
    * This class allows an object to be passed over a Socket
    * @author Harold Clements
    * @version 1.0.1 12-Jun-2007 (12-Jul-2007)
    //http://www.seasite.niu.edu/cs580java/Object_Serialization.html
    public class SendObjectThread extends Thread {
         private OutputStream out;
         private Object obj;
          * This constructor allows the user to passes the two parameters for transmitting.
          * @param out The data stream that the object is going to be sent to.
          * @param obj The object to be sent.
         public SendObjectThread(OutputStream out, Object obj) {
              this.out = out;
              this.obj = obj;
          * The main thread
         public void run() {
              try {
                   ObjectOutputStream objOut = new ObjectOutputStream(out);
                   objOut.writeObject(obj);
                   objOut.flush();
              } catch (IOException e) {
                   e.printStackTrace();
    }The client only has one socket which is defined when the client first makes a connection with the server. The �getOutputStream()� and �getInputStream()� are used for all communication from the client.
    Is this what you described in your first option?
    The funny thing about it all is if I create a new �receiveObjectTread� and wait for that to finish, then create another �receiveObjectTread� both objects in question (Player and GameData) are received correctly and the application works. I only have the problem when I set both threads off and leave it for the �ReceivedObjectEvent� listener to pick them up and cast them (as per my first post).
    Thanks again for your help,
    Harold Clements

  • Problem with StreamCorruptedException: invalid stream header: 3C68746D

    Hi
    I am attempting to code a project in Java which involves the user of object serialization to send a String via serialization from an applet embedded in a JSP tp a servlet all files are running on the same machine for testing purposes.
    However I seem to be getting StreamCorruptedException: invalid stream header: 3C68746D whenever I attempt to read the inputstream once I have written to it.
    My code is as follows below (I apologise for the lack of details I have attempted to comment and simplify my code as much as possible for improved readability)
    ////////////////////////APPLET CODE////////////////
    import java.io.*;
    import java.io.Serializable;
    import javax.servlet.http.*;
    import java.applet.*;
    import javax.swing.*;
    import java.net.*;
    *Compiled using netbeans 5.1
    *Uses Apache server embedded with netbeans
    *JSP address http://localhost:8084/TestServ
    *Applet is embedded within this page
    *Servlet address http://localhost:8084/TestServ/TServ
    public class Main extends javax.swing.JApplet {
    JFrame jf;//frame for the test applet
    JTextArea jt;//result text box
    public Main() {
    jt=new JTextArea();//set up applet
    this.add(jt);
    URL servletURL;
    HttpURLConnection servletConnection;
    InputStream iStream=null;
    try
    {   //this address as far as is known is correct
    servletURL = new URL( "http://localhost:8084/TestServ/TServ" );
    //open connection to servlet
    servletConnection = (HttpURLConnection)servletURL.openConnection();
    //set up connection
    servletConnection.setDoInput(true);
    servletConnection.setDoOutput(true);
    servletConnection.setUseCaches(false);
    servletConnection.setDefaultUseCaches(false);
    //have tried "GET" and "POST" and "PUT"(PUT not directly compatible with apache servers)
    servletConnection.setRequestMethod("POST");
    servletConnection.setRequestProperty("Content-type","application/octet-stream");
    /*Have also tried application/x-java-serialized-object*/
    //set object output stream
    ObjectOutputStream outStream =
    new ObjectOutputStream(servletConnection.getOutputStream());
    //write a string for test purposes (As far as I am aware String implements Serializable)
    outStream.writeObject("h");
    //flush and close connection
    //have tried a combination of flush and/or close
    outStream.flush();
    outStream.close();
    //get input stream rdy for objectinput stream
    iStream = servletConnection.getInputStream();
    catch(IOException e)
    jt.setText("Error in output "+e);
    ObjectInputStream oInStream=null;
    String str = iStream.toString();
    //iStream at this point equals ""sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@6754d6
    try
    //this is where the error occurs
    //upon even trying to create a objectinputstream using iStream IOException occurs
    oInStream = new ObjectInputStream(iStream);
    //program does not get any further
    oInStream.close();
    catch(IOException e)
    //this error has been driving me crazy :(
    jt.setText("Error in input "+e);
    Servlet code is below however it does not even reach this point
    (If reading input stream is removed from the applet the servlet provides the same error message)
    /////////////////////Servlet code (however does not reach this point)///////////////
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class TServ extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    ObjectInputStream inputFromApplet = null;
    InputStream in = request.getInputStream();
    BufferedReader inTest = null;
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet TServ</title>");
    out.println("</head>");
    out.println("<body>");
    try
    inputFromApplet = new ObjectInputStream(in);
    out.println("<h2>Sucess </h1>");
    catch(EOFException e)
    out.println("<h3>ERROR: " e " Error</h3>");
    out.println("<h3>End Servlet</h3>");
    out.println("</body>");
    out.println("</html>");
    out.close();
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    public String getServletInfo() {
    return "Short description";
    Thank you for your time I have searched for an answer for some time now and how found people in similar situations however no solution has been found
    Any help is appreciated
    Az

    The servlet isn't writing any objects back in reply. It is writing text. Not the same thing. If you want to read using an ObjectInputStream you have to write using an ObjectOutputStream.

  • Bapi_Acc_Document_Post - E 018 : Invalid tax code and company code combination

    Hi All,
    I need the help of this forum once again.
    I am using bapi Bapi_Acc_Document_Post to create KR documents in SAP. The bapi works absolutely fine except for one scenario:
    For a particular type of invoice coded to Company "XXXX" with lines having tax code "I0", the bapi returns error message "E 018 : Invalid tax code and company code combination". The tax code "I0" and the company code "XXXX" has been mapped in SAP and if I try to create the invoice manually in SAP using the GUI, the invoice gets created without any issue.
    I have tried searching the forum but could not find any post on this topic.
    Therefore, requesting the masters to please help me out on this.
    Best Regards
    Sutirtha Roy

    Hi Gowthami,
    how have you solved your problem, because I am facing the similiar issue and trying desperately to post the following combination with BAPI_ACC_POST_DOCUMENT:
    001 40       490100     Aufw. aus Marge PP              R2                 15,92
    002 31       10000003   Kreditor                                R2                 15,92-
    003 50       175060     Abzugsverfahren USt            R2                  3,18-
    004 40       154060     Abzugsverfahren Vst             R2                  3,18
    THANX!
    Regards
    Marko

  • Invalid Type Expression Compile Error

    Hi,
    Can anybody help?
    C:\java>javac PointRectangle.java
    PointRectangle.java:74: Invalid type expression.
    loc=new Point(xCoord,yCoord)//*****
    ^
    1 error
    Create class Point which replaces xCoord & yCoord and
    is used in class Shapes
    TEST: Has been tested independently
    import javax.swing.JApplet;
    import java.awt.Graphics;
    class Point
         private int xCoord;
         private int yCoord;
         Point( ){}
         Point(int xCoord, int yCoord)
    set(xCoord,yCoord);
         public void set(int x, int y)
    xCoord = x;
         yCoord = y;
         public int getX()
    return xCoord;
         public int getY()
    return yCoord;
    Create new version of Rectangle by eliminating anything common to all Shapes
    TEST: class Rectangle has a point;
    class Rectangle
    private static int counter = 0;
    //xCoord = x;
    //yCoord = y;
    private Point loc;//*****
    private int width;
    private int height;
    Rectangle( )
    ++counter;
    Rectangle(int x, int y, int w, int h)
    //xCoord = x;
    //yCoord = y;
    loc = new Point(x,y)//*****
    width = w;
    height = h;
         ++counter;
    //Use any set() if you don't want to initialize dMembrs
    //through c_tors
    //set rectangle at a given x & y coord
    public void setLocation(int x, int y)
         //xCoord = x;
         //yCoord = y;
    loc.set(x,y);//*****
    public void setDimension(int w, int h)
         width = w;
    height = h;
    public void set(int x, int y, int w, int h)
    //xCoord = x;
    //yCoord = y;
    loc.set(x,y);//*****
    width = w;
    height = h;
    //Use get() if you don't want to access dMembrs directly
    //public int getX() {return xCoord;}
    public int getX() {return loc.getX();}//*****
    //public int getY() {return yCoord;}
    public int getY() {return loc.getY();}//*****
    public int getWidth() {return width;}
    public int getHeight() {return height;}
    //Rectangle's perimeter
    public int perimeter()
    return (2 * width) + (2 * height);
    //Rectangle's area
    public int area()
    return width * height;
    //output
         public void draw(Graphics g)
    //g.drawRect(xCoord,yCoord,width,height);
    g.drawRect(loc.getX(),loc.getY(),width,height);//*****
    //Convert String
         public String toString()
         //return
    // "(("+ xCoord +", "+ yCoord +"), "+ width +","+ height +")";
         return
    "(("+ loc.getX() +", "+ loc.getY() +"), "+ width +","+ height +")";//*****
    //returns number of rectangels created
         public static int recCount()
    return counter;
    }//End Class Rectangle
    public class PointRectangle extends JApplet
    Rectangle r1;
    Rectangle r2;
    Rectangle r3;
    public void init()
    //create Rectangles
    r1 = new Rectangle( );
    r1.set(20,200,50,40);
    r2 = new Rectangle(20,300,80,60);//x,y,width,height
    r3 = new Rectangle();
    } //end init()
    public void paint(Graphics g)
    g.drawString("r1 Area: " + r1.area(),20,50);
    g.drawString("r1 Perimeter: " + r1.perimeter(),20,75);
    g.drawString
    ("r1 arguments in r1.set(): " + r1.toString(),20,100);
    g.drawString
    ("r2: xCoord =" + r2.getX() + " yCoord=" +r2.getY()
    + " Width =" + r2.getWidth()
    + " Height=" + r2.getHeight(), 20,125);
    r3.setLocation(20,400);
    r3.setDimension(100,150);
    g.drawString
    ("r3: xCoord =" + r3.getX() + " yCoord=" + r3.getY()
    + " Width =" + r3.getWidth()
    + " Height=" + r3.getHeight(), 20,150);
    g.drawString
    ("r's created: "+Rectangle.recCount(),20,175);
    r1.draw(g);
    r2.draw(g);
    r3.draw(g);
    } //end paint()

    Are you referring to the following:I'm not; the message you posted is... :)
    There's only one place where you handle an object reference in that code: "loc.set(x,y);". So it must be that the reference "loc" is null; you haven't determined which object it should point to so it doesn't point to any object.
    Looking deeper at the code above, it's not a big surprise as you never actually assign loc to anything. The only place where you do "loc = ..." is a constructor which you don't seem to use.

  • Getting "java.io.StreamCorruptedException: invalid stream header"

    When creating a self made Stream (MacInputStream) and then using an ObjectInputStream over it to read Objects from a socket, I get this error:
    java.io.StreamCorruptedException: invalid stream header
         at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:764)
         at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277)
         at TServidor.run(TServidor.java:32)
    Is there any special feature that the "self-made" streams have to implement to be possible to use ObjectInput streams over them :P ?
    Here is the MacInputStream.java code:
    import java.io.Closeable;
    import java.io.FilterInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Arrays;
    import javax.crypto.Mac;
    public class MacInputStream extends FilterInputStream implements Closeable{
         private Mac mac; // algorithm
         private byte [] mmac; //message MAC
         private boolean FIRST_TIME;
         public MacInputStream(InputStream is,Mac mac) {
              super(is);
              this.mac=mac;
              FIRST_TIME=true;
    public int read() throws IOException{
              if(FIRST_TIME){
                   mmac = new byte [mac.getMacLength()];
                   super.read(mmac);
              if(super.in.available()==0){
                   FIRST_TIME=true;
                   return -1;
              int rbyte = super.in.read();
              FIRST_TIME=false;
              mac.update((byte)rbyte);
              System.out.println("available: "+super.in.available());          
              if(super.in.available()==0){
                   byte [] macres =mac.doFinal();
                   System.out.println("message MAC: "+new String(mmac));
                   System.out.println("calculated MAC: "+new String(macres));
                   if(!Arrays.equals(macres, mmac)){
                        throw new IOException("violated integrity");
              return rbyte;
    public int read(byte [] b) throws IOException{
         if(FIRST_TIME){
              mmac = new byte [mac.getMacLength()];
              super.in.read(mmac);          
         if(super.available()==0){
              FIRST_TIME=true;
              return -1;
         int rbytes = super.in.read(b);
         FIRST_TIME=false;
         mac.update(b);
         if(super.available()==0){
              byte [] macres =mac.doFinal();
              if(!Arrays.equals(macres, mmac)){
                   throw new IOException("violated integrity");
         return rbytes;
    }And here is the "main" function where the exception gets thrown:
    public void run() {
         try {
              ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
              Mac mac = Mac.getInstance("HmacMD5");
              Key key = KeyGenerator.getInstance("HmacMD5").generateKey();          
              oos.writeObject(key);
              oos.flush();
              mac.init(key);          
              ObjectInputStream cis = new ObjectInputStream(new MacInputStream(s.getInputStream(),mac));
             String test;
             try {
                   while (true) {
                        test = (String)cis.readObject();
                        System.out.println(ct + " : " + test);
              } catch (EOFException e) {
                   System.out.println("["+ct + "]");
              } finally {
              if (cis!=null) cis.close();
              if (oos!=null) oos.close();
         } catch (Exception e) {
             e.printStackTrace();
        }It's exactly in the line: ObjectInputStream cis = new ObjectInputStream(new MacInputStream(s.getInputStream(),mac));Any ideas?
    I'm starting to desperate :P

    (a) I still don't see where you are writing the MAC that you're reading. You're reading something, but it's all or part of the Object stream header I described above, which is why ObjectInputStream' constructor is throwing that exception.
    (b) You don't need to override read(byte[] b) when you extend FilterInputStream, but you do need to override read(byte[] b, int offset, int length), and you need to do it like this:
    public int read(byte[] buffer, int offset, int length) throws IOException
      int count = 0;
      do
        int c = read();
        if (c < 0)
            break;
        buffer[offset+count++] = (byte)c;
      } while (count < length && available() > 0);
      return count > 0 ? count : -1;
    }This way the read() method gets to see every byte that's read and to do its MAC thing or whatever it does. The above is one of only two correct uses of available() in existence: it ensures that you only block once while reading, which is the correct behaviour e.g. on a network.

  • INVALID RESPONSE CODE 301

    Hi Techie's..
    In a webdynpro application I have used a Web Service model to get backend data; we have a cluster environment in Test (two server nodes linked with load balancing server and a sap dispatcher).
    Using visual administrator --> web services container, the endpoint & WSDL is set to the load balancing server. The webdynpro application fails with this error
    The initial exception that caused the request to fail was:
    com.sap.engine.services.webservices.espbase.discovery.BaseIOException: Invalid Response Code 301 while accessing URL: http://lumnrs61.luminus.int:8143/inspection.wsil. Response Message: MOVED PERMANENTLY. Content Type: text/html; charset=utf-8. Body Content: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>301 MOVED PERMANENTLY</TITLE> </HEAD><BODY>
    Moved Permanently
    The document has moved here </BODY></HTML>
    at com.sap.engine.services.webservices.server.management.discovery.DestinationsResolver.resolveURL(DestinationsResolver.java:220)
    at com.sap.engine.services.webservices.server.management.discovery.DestinationsResolver.resolveEntity(DestinationsResolver.java:120)
    at com.sap.engine.services.webservices.espbase.query.WSQueryImpl.initialize(WSQueryImpl.java:184)
    at com.sap.engine.services.webservices.espbase.query.WSQueryImpl.findWSInterfaces(WSQueryImpl.java:151)
    at com.sap.engine.services.webservices.server.management.discovery.ServiceDiscoveryImpl.getWSDLUrl(ServiceDiscoveryImpl.java:71)
    ... 80 more
    The application works fine in development environment, the endpoint points to the single server node.
    Can you let me know how to resolve this issue, we need to have this scenario of load balancing in place such that the web services also get invoked in a load balanced mode.

    Hey buddy...
    The address is changed.... this code is a standard http status.
    Is a warning, saying that your target is not in this place... target changes....
    try to verify this target... under your web browser, or telnet, tracert... whatever... check what is your return...
    Regards...
    =)

Maybe you are looking for