Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

Setting up Mirror with OpenSpaces config

I'm trying to set up the Mirror service as detailed here: Open Spaces Persistency Scenarios - Mirror

I've got 2 PU's that my project builds, one which does the work and one which is just the configuration for the mirror service and the Hibernate hbm.xml files. They both include a jar file of the domain classes which my app uses.

The problem I'm having is that it doesn't seem to like my ID's for one reason or another. I first tried having the id I have mapped as the PK field in Hibernate be an auto-generated space id field, like this:

@SpaceId(autoGenerate = true)
    public String getId() {
        return id;

Where the id field was empty when the object was created, and mapped like this in my Hibernate file:

<id column="ID" name="id" type="java.lang.String">
            <generator class="assigned"/>

Unfortunately, when I went to write these objects into the space I got this error:

java.lang.IllegalArgumentException: Write operation failed. UID must be supplied for write operation when using External
        at com.j_spaces.obf.ko.a(SourceFile:1017)
        at com.j_spaces.obf.ko.write(SourceFile:1779)
        at com.j_spaces.core.JSpaceImpl.write(SourceFile:1585)
        at sun.reflect.GeneratedMethodAccessor84.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        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(ThreadPoolExecutor.java:650)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)

Having no idea why this is, I've been trying other options. Now I'm generating UUIDs for my id field when the object is created. I'm sure these are being built, and I've changed my id field like this:

    public String getId() {
        return id;

So it doesn't have the autoGenerate anymore. The Hibernate mapping is the same.

Originally, I was getting different errors with this configuration, and the POJO's were not written to the space. After re-doing the configurations, now I'm not getting any errors and the POJO's are written to the space, but nothing is being replicated to the mirror space and nothing is written to the database. I do see the entry in the list of classes under the Mirror space for my POJO class, but there's zero items in it, and a query of the table does not show anything in the table.

Anyone have any ideas for me?

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

asked 2008-02-05 08:53:14 -0500

jcarreira gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted


You should make your POCO class persistent to allow the data to be pushed into the Mirror:
@SpaceClass (persist=true)
public class MyClass{

Please note that when you run in auto generate = false you must provide unique ID to be used for the space Entry UID. The auto generate = true is not supported with in ExternalDataSource mode.

When running in ExternalDataSource mode (write behind/through) the space must have some sort of application UID embedded into the object to correlate it with the database table row data.


answered 2008-02-05 11:31:33 -0500

shay hassidim gravatar image
edit flag offensive delete link more

May be related to: http://www.gigaspaces.com/wiki/displa... See section about adding a member "transient public String mUID" and get/set methods for the member. sm.

answered 2008-02-05 10:56:53 -0500

wasefmasood gravatar image
edit flag offensive delete link more


Does this apply? I'm using a POJO with OpenSpaces annotations, not something that implements the Entry interface.

jcarreira gravatar imagejcarreira ( 2008-02-05 11:07:39 -0500 )edit

Shay, here's the annotation on my class:

@SpaceClass(replicate = true, persist = true, fifo = false, includeProperties = SpaceClass.IncludeProperties.IMPLICIT)

as you can see, it's already annotated as persistent.

For the 2nd try, where I'm giving it a UUID, I'm generating a UUID in the constructor, so I know it's there.

I'm not using ExternalDataSource mode... I'm using mirror="true". Here's the space declaration from my main processing PU:

<os-core:space id="space" url="/./hfsSpace" mirror="true"/>

<os-core:local-tx-manager id="transactionManager" space="space" clustered="true"/>

<!-- OpenSpaces simplified space API built on top of IJSpace/JavaSpace. -->
<os-core:giga-space id="gigaspace" space="space" clustered="true" tx-manager="transactionManager"/>

For my mirror PU I'm defining the space like this (taken from the examples on the Wiki):

<bean id="hibernateDataSource" class="com.gigaspaces.datasource.hibernate.HibernateDataSource">
    <property name="sessionFactory" ref="sessionFactory"/>

<os-core:space id="space" url="/./mirror-service" schema="mirror" external-data-source="hibernateDataSource"/>

My PK is set to my id property in my POJO class in my Hibernate mapping, and I'm also using the @SpaceId annotation on the getId() method.

jcarreira gravatar imagejcarreira ( 2008-02-05 11:40:23 -0500 )edit

The com.gigaspaces.datasource.hibernate.HibernateDataSource is implementation of the ExternalDataSource interface.

See here example for how custom Mirror PU should be configured: http://www.gigaspaces.com/wiki/displa...

Does this works for you?


shay hassidim gravatar imageshay hassidim ( 2008-02-05 11:55:37 -0500 )edit

I sent you a reply to your email, not sure if you saw it.

The docs you sent show an example of setting up a custom mirror service. I'm not trying to do that, I'm trying to use the standard Hibernate mirroring, but unlike the examples I've found, I'm trying to use POJOs with the OpenSpaces annotations instead of a class implementing Entry, and I'm not having any luck.

jcarreira gravatar imagejcarreira ( 2008-02-08 10:01:59 -0500 )edit

You can use the custom Mirror as a base line to be modified and have your POJO and Mirror class implementation. Can you post your full POJO class and the pu.xml?

Please note we are working now on optimized Hibernate HibernateDataSource. This provides better performance and tuned for large data sets. Let me know if you want to test this. Shay

shay hassidim gravatar imageshay hassidim ( 2008-02-09 01:46:03 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2008-02-05 08:53:14 -0500

Seen: 94 times

Last updated: Feb 05 '08