Caused by java io EOFException Oracle Coherence

Caused by java io EOFException Oracle Coherence

While working with Oracle Coherence cache and during deserialization if you are getting below exception:

Caused by: java.io.EOFException
at com.tangosol.io.AbstractByteArrayReadBuffer$ByteArrayBufferInput.readPackedInt(AbstractByteArrayReadBuffer.java:503) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]

ChangeControlApprovalModel [approvedBy=approvedBy, approvedTime=Tue Aug 30 14:06:39 EDT 2016]
30-08-2016 14:06:45.811 [main] WARN  com.wachovia.cib.spt.cacheutil.NamedCacheWrapper - Error invoking get on cache: OTCChangeControlInfo parameters: [changeControlInfoModel_dotNet]
com.tangosol.util.WrapperException: (Wrapped) null
	at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:271) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.tangosol.coherence.component.net.extend.RemoteNamedCache$ConverterFromBinary.convert(RemoteNamedCache.CDB:4) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.oracle.common.collections.ConverterCollections$ConverterMap.get(ConverterCollections.java:1522) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.tangosol.coherence.component.net.extend.RemoteNamedCache.get(RemoteNamedCache.CDB:1) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.tangosol.coherence.component.util.SafeNamedCache.get(SafeNamedCache.CDB:1) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51]
	at com.wachovia.cib.spt.cacheutil.NamedCacheWrapper.invokeWithRetry(NamedCacheWrapper.java:138) [eqdframework-v_10_0_20141003.jar:?]
	at com.wachovia.cib.spt.cacheutil.NamedCacheWrapper.get(NamedCacheWrapper.java:172) [eqdframework-v_10_0_20141003.jar:?]
	at com.wfs.otc.model.common.serializers.ChangeControlInfoModelSerializerTest.ChangeControlInfoModelSerializer(ChangeControlInfoModelSerializerTest.java:22) [classes/:?]
	at com.wfs.otc.cache.SerializerTest.main(SerializerTest.java:214) [classes/:?]
Caused by: java.io.EOFException
	at com.tangosol.io.AbstractByteArrayReadBuffer$ByteArrayBufferInput.readPackedInt(AbstractByteArrayReadBuffer.java:503) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.tangosol.io.pof.PofBufferReader.readCollection(PofBufferReader.java:2378) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.wfs.otc.model.common.serializers.ChangeControlInfoModelSerializer.deserialize(ChangeControlInfoModelSerializer.java:36) ~[classes/:?]
	at com.tangosol.io.pof.PofBufferReader.readAsObject(PofBufferReader.java:3316) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.tangosol.io.pof.PofBufferReader.readObject(PofBufferReader.java:2604) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.tangosol.io.pof.ConfigurablePofContext.deserialize(ConfigurablePofContext.java:376) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.tangosol.util.ExternalizableHelper.deserializeInternal(ExternalizableHelper.java:2844) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:267) ~[coherence-12.1.3.0.2.jar:12.1.3.0.2]
	... 12 more
30-08-2016 14:06:50.820 [main] WARN  com.wachovia.cib.spt.cacheutil.NamedCacheWrapper - Retrying...1

Solution: This exception happens if you forget to call PoPofReader readRemainder() or PofWriter writeRemainder(null) method after method deserialization OR serialization is over as shown below:

Caused by java io EOFException Oracle Coherence

Please include above method to your class.

  • Example serialization class:
import java.io.IOException;
import java.util.Date;

import com.tangosol.io.pof.PofReader;
import com.tangosol.io.pof.PofSerializer;
import com.tangosol.io.pof.PofWriter;
import com.wfs.otc.model.common.ChangeControlApprovalModel;

public class TestSerializer implements PofSerializer{
	
	@Override
	public Object deserialize(PofReader pofReader) throws IOException {
		
		String approvedBy = pofReader.readString(10);
		Date approvedTime = pofReader.readDate(11);
		
		pofReader.readRemainder();
		
		return new ChangeControlApprovalModel(approvedBy, approvedTime);
	}

	@Override
	public void serialize(PofWriter pofWriter, Object o) throws IOException {
		
		ChangeControlApprovalModel changeControlApprovalModel = (ChangeControlApprovalModel) o;
		
		pofWriter.writeString(10, changeControlApprovalModel.getApprovedBy());
		pofWriter.writeDate(11, changeControlApprovalModel.getApprovedTime());
		
		pofWriter.writeRemainder(null);
		
	}
}

For more information please refer Oracle Coherence tutorial

One thought on “Caused by java io EOFException Oracle Coherence”
  1. I didn’t work for me. I am trying to serialize data using PortableObject and earlier
    I was getting NotSerializable error , now I am getting this error.

Leave a Reply

Your email address will not be published. Required fields are marked *