java.lang.IllegalArgumentException: object is not an instance of declaring

I am trying to write a POJO to a persistent space by calling

spaceInstance.write(person, null, Lease.FOREVER);

However I get this issue:
SEVERE com.gigaspaces.pojo: Failed to convert the POJO to Entry due to : java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.gigaspaces.converter.pojo.Pojo2ExternalEntryConverter.toEntry(SourceFile:274)
    at com.j_spaces.core.client.action.common.PreConvertProxyActionListener.onAction(SourceFile:152)
    at com.j_spaces.core.client.action.common.PreConvertProxyActionListener.onAction(SourceFile:26)
    at com.j_spaces.core.client.AbstractSpaceProxy.write(SourceFile:430)
at com.j_spaces.core.client.AbstractSpaceProxy.write(SourceFile:420)

16:43:27,969 INFO STDOUT GigaSpaces J2EE/ReplicatedSessionBean -- com.gigaspaces.converter.ConversionException: Failed to convert the Entry to POJO
16:43:27,969 ERROR STDERR com.gigaspaces.converter.ConversionException: Failed to convert the Entry to POJO
16:43:27,969 ERROR STDERR at com.gigaspaces.converter.pojo.Pojo2ExternalEntryConverter.toEntry(SourceFile:423)
16:43:27,969 ERROR STDERR at com.j_spaces.core.client.action.common.PreConvertProxyActionListener.onAction(SourceFile:152)
16:43:27,969 ERROR STDERR at com.j_spaces.core.client.action.common.PreConvertProxyActionListener.onAction(SourceFile:26)
16:43:28,000 ERROR STDERR at com.j_spaces.core.client.AbstractSpaceProxy.write(SourceFile:430)
16:43:28,000 ERROR STDERR at com.j_spaces.core.client.AbstractSpaceProxy.write(SourceFile:420)

Heree's the POJO class
public class Person implements Serializable{
private String firstName;

private String lastName;

private Integer id;
//private Set adresses;

// must have empty constructor
    public Person() {
}

public Person(String firstName, String lastName, Integer id) {
        this.firstName = firstName;
        this.lastName = lastName;
this.id = id;

}
    public String toString() {
        String tmp;
        tmp = "ID:" + id + " firstName:" + firstName + " lastName:" + lastName;// +" Adress " ;
        //Iterator inter = adresses.iterator();
        //while(inter.hasNext()){
        // tmp += "\n\t" + inter.next().toString();
        //}
        return tmp;
}

public static String __getSpaceIndexedFields() {
        return new String { "id", "firstName" };
}

public String getFirstName() {
        return firstName;
}

public void setFirstName(String firstName) {
        this.firstName = firstName;
}

public String getLastName() {
        return lastName;
}

public void setLastName(String lastName) {
        this.lastName = lastName;
}

public Integer getId() {
        return id;
}

public void setId(Integer id) {
        this.id = id;
    }
}

Hibernate mapping:
<hibernate-mapping>
    <class name="com.j_spaces.examples.datasource.Person" table="Person">
        <id name="id" type="integer">
            <column name="ID" />
            <generator class="assigned" />
        </id>
        <property name="firstName" type="string">
            <column name="FIRSTNAME" length="20" />
        </property>
        <property name="lastName" type="string">
            <column name="LASTNAME" length="20" />
        </property>
    </class>
</hibernate-mapping>

gs mapping:
<gigaspaces-mapping>
    <class name="com.j_spaces.examples.datasource.Person" persist="true"
    replicate="true" fifo="false">
        <property name="firstName" index="none" />
        <property name="lastName" index="none" />
        <id name="id" auto-generate="false"/>
    </class>
</gigaspaces-mapping>

Also, I tried querying existing object in space using GS UI, and same exception:
java.sql.SQLException: Select failed
 Failed to getCacheContext.; nested exception is:
    com.jspaces.core.sadapter.SAException: com.gigaspaces.converter.ConversionException: Failed to convert the Entry to POJO :com.jspaces.examples.benchmark.messages.Message
    at com.j_spaces.jdbc.SelectQuery.executeOnSpace(SourceFile:362)
    at com.j_spaces.jdbc.QueryHandler.a(SourceFile:97)
    at com.j_spaces.jdbc.QueryProcessor.executeQuery(SourceFile:294)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.j_spaces.obf.iw.a(SourceFile:333)
    at com.j_spaces.obf.fh.b(SourceFile:292)
    at com.j_spaces.obf.fh.a(SourceFile:358)
    at com.j_spaces.obf.jk.dispatch(SourceFile:118)
    at com.j_spaces.obf.ca.run(SourceFile:62)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.rmi.RemoteException: Failed to getCacheContext.; nested exception is:
    com.jspaces.core.sadapter.SAException: com.gigaspaces.converter.ConversionException: Failed to convert the Entry to POJO :com.jspaces.examples.benchmark.messages.Message
    at com.j_spaces.obf.ko.readMultiple(SourceFile:2084)
    at com.j_spaces.core.JSpaceImpl.readMultiple(SourceFile:1546)
    at com.j_spaces.core.lrmi.LRMIRemoteSpaceImpl.readMultiple(SourceFile:216)
    at com.j_spaces.core.client.single.action.AbstractSingleSpaceReadTakeMultipleActionListener.readMultiple(SourceFile:74)
    at com.j_spaces.core.client.single.action.SingleSpaceReadMultipleActionListener.onAction(SourceFile:35)
    at com.j_spaces.core.client.single.action.SingleSpaceReadMultipleActionListener.onAction(SourceFile:16)
    at com.j_spaces.core.client.AbstractSpaceProxy.readMultiple(SourceFile:623)
    at com.j_spaces.core.client.AbstractSpaceProxy.readMultiple(SourceFile:596)
    at com.j_spaces.jdbc.SelectQuery.b(SourceFile:1215)
    at com.j_spaces.jdbc.SelectQuery.executeOnSpace(SourceFile:181)
    ... 14 more
Caused by: com.jspaces.core.sadapter.SAException: com.gigaspaces.converter.ConversionException: Failed to convert the Entry to POJO :com.jspaces.examples.benchmark.messages.Message
    at com.j_spaces.sadapter.datasource.DataAdapter.makeEntriesIter(SourceFile:932)
    at com.j_spaces.obf.cj.E(SourceFile:242)
    at com.j_spaces.obf.cj.next(SourceFile:27)
    at com.j_spaces.obf.ko.a(SourceFile:4640)
    at com.j_spaces.obf.ko.readMultiple(SourceFile:2042)
    ... 23 more
Caused by: com.gigaspaces.converter.ConversionException: Failed to convert the Entry to POJO :com.j_spaces.examples.benchmark.messages.Message
    at com.gigaspaces.converter.pojo.Pojo2ExternalEntryConverter.toPojoFromIGSEntry(SourceFile:814)
    at com.j_spaces.obf.z.toObject(SourceFile:59)
    at com.j_spaces.sadapter.datasource.EntryAdapter.toObject(SourceFile:99)
    at com.j_spaces.sadapter.datasource.DataAdapter.makeEntriesIter(SourceFile:861)
    ... 27 more
Caused by: java.lang.IllegalArgumentException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.gigaspaces.converter.pojo.Pojo2ExternalEntryConverter.toPojoFromIGSEntry(SourceFile:730)
... 30 more

This thread was imported from the previous forum.
For your reference, the original is available here

asked 2008-04-07 15:48:20 -0500

wasefmasood gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete