Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

POF Exception , java.io.IOException: previous property index=4...

810106Oct 13 2011 — edited Oct 17 2011
I am getting the following error when the following application code runs:

public void testPOF() {

Token T1 = new Token(1,1,"Toronto",3,5);
NamedCache aceCache = CacheFactory.getCache("ACE");
aceCache.put("TokenTest1", T1);

Token T2 = (Token) aceCache.get("AnkitAsthana");
if (T1.getNeID().equals(T1.getNeID())) {
System.out.println(" Works and equal ");
}
System.out.println("===============\n");
}

As you might already guess Token is a POF object , its artifacts are attached below. Coherence-cache-server seemed to startup fine.

<Oct 13, 2011 7:56:47 PM PDT> <Warning> <EJB> <BEA-010065> <MessageDrivenBean threw an Exception in onMessage(). The exception was:
(Wrapped) java.io.IOException: previous property index=4, requested property index=1 while writing user type 1001.
(Wrapped) java.io.IOException: previous property index=4, requested property index=1 while writing user type 1001
at com.tangosol.util.ExternalizableHelper.toBinary(ExternalizableHelper.java:215)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ConverterValueToBinary.convert(PartitionedCache.CDB:3)
at com.tangosol.util.ConverterCollections$ConverterMap.put(ConverterCollections.java:1578)


Plz help I have no idea what the issue is?
======================================================================================================================
tokens-pof-config.xml
======================================================================================================================
<?xml version="1.0"?>
<pof-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-pof-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-pof-config coherence-pof-config.xsd">

<user-type-list>
<!-- coherence POF user types -->
<include>coherence-pof-config.xml</include>

<!-- com.tangosol.examples package -->
<user-type>
<type-id>1001</type-id>
<class-name>Token</class-name>
</user-type>
</user-type-list>
<allow-interfaces>true</allow-interfaces>
<allow-subclasses>true</allow-subclasses>
</pof-config>

======================================================================================================================
Token.java
======================================================================================================================

import java.io.IOException;
import java.io.Serializable;
import com.tangosol.io.pof.PortableObject;
import com.tangosol.io.pof.PofReader;
import com.tangosol.io.pof.PofWriter;
import java.sql.*;
import java.util.Enumeration;

public class Token implements PortableObject {

/**
* 1 - Unassigned
* 2 - Available
* 3 - Reserved
* 4 - defunct
*/
private int state;

/**
* NE-ID(s)
*/
private String neID;

/**
* Number of tokens currently Active
*/
private int tokensCurrentlyActive;

/**
* Max - Number of tokens available
*/
private int maxTokensAvailable;

/**
* unqiue Token ID, used to identify Tokens
*/
private int tokenID;

/**
*
* POF index for data members
*/
public static final int TOKENID = 0;
public static final int STATE = 1;
public static final int NEID = 2;
public static final int CURTOKEN = 3;
public static final int MAXTOKEN = 4;

/**
*
* @param state
*/
public void setState(int state) {
this.state = state;
}

/**
*
* @return
*/
public int getState() {
return state;
}

/**
*
* @param neID
*/
public void setNeID(String neID) {
this.neID = neID;
}

/**
*
* @return
*/
public String getNeID() {
return neID;
}

/**
*
* @param tokensCurrentlyActive
*/
public void setTokensCurrentlyActive(int tokensCurrentlyActive) {
this.tokensCurrentlyActive = tokensCurrentlyActive;
}

/**
*
* @return
*/
public int getTokensCurrentlyActive() {
return tokensCurrentlyActive;
}

/**
*
* @param maxTokensAvailable
*/
public void setMaxTokensAvailable(int maxTokensAvailable) {
this.maxTokensAvailable = maxTokensAvailable;
}

/**
*
* @return
*/
public int getMaxTokensAvailable() {
return maxTokensAvailable;
}

/**
*
* @param tokenID
*/
public void setTokenID(int tokenID) {
this.tokenID = tokenID;
}

/**
*
* @return
*/
public int getTokenID() {
return tokenID;
}


public Token(int state, int tokenID, String neID, int maxTokensAvailable, int tokensCurrentlyActive){
this.state = state;
this.tokenID = tokenID;
this.neID = "Toronto";
this.maxTokensAvailable = maxTokensAvailable;
this.tokensCurrentlyActive = tokensCurrentlyActive;
}

// ----- PortableObject interface ---------------------------------------

/**
* {@inheritDoc}
*/
public void readExternal(PofReader reader)
throws IOException
{
tokenID = Integer.parseInt(reader.readString(TOKENID));
neID = reader.readString(NEID);
tokensCurrentlyActive = Integer.parseInt(reader.readString(CURTOKEN));
maxTokensAvailable = Integer.parseInt(reader.readString(MAXTOKEN));
state = Integer.parseInt(reader.readString(STATE));
}

/**
* {@inheritDoc}
*/
public void writeExternal(PofWriter writer)
throws IOException
{
writer.writeString(TOKENID,Integer.toString(tokenID));
writer.writeString(NEID,neID);
writer.writeString(CURTOKEN,Integer.toString(CURTOKEN));
writer.writeString(MAXTOKEN,Integer.toString(MAXTOKEN));
writer.writeString(STATE,Integer.toString(STATE));
}
}

======================================================================================================================
coherence-cache-config.xml
======================================================================================================================
<distributed-scheme>
<scheme-name>example-distributed</scheme-name>
<service-name>DistributedCache</service-name>
<serializer>
<class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
<init-params>
<init-param>
<param-type>string</param-type>
<param-value>tokens-pof-config.xml</param-value>
</init-param>
</init-params>
</serializer>

<backing-map-scheme>
<local-scheme>
<scheme-ref>example-binary-backing-map</scheme-ref>
</local-scheme>
</backing-map-scheme>

<autostart>true</autostart>
</distributed-scheme>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 14 2011
Added on Oct 13 2011
4 comments
661 views