3

I'm trying to embedded Symmetricds 3.7 in a java application which uses H2 database. The application is a client node and uses the class ClientSymmetricEngine from SymmetricDS API.

The master node runs standalone symmetricds server and I was able to synchronize the data when I used an already configured databsae from previous tests in the application.

When running the application on a new database, it throws this exception:

java.lang.IllegalStateException: This node has not been configured.Could not find a row in the identity table
at 
org.jumpmind.symmetric.service.impl.RegistrationService.openRegistration(RegistrationService.java:562)
at 
org.jumpmind.symmetric.service.impl.RegistrationService.openRegistration(RegistrationService.java:530)
at 
org.jumpmind.symmetric.service.impl.RegistrationService.openRegistration(RegistrationService.java:519)
at 
org.jumpmind.symmetric.AbstractSymmetricEngine.openRegistration(AbstractSymmetricEngine.java:890)
at syncdemo.ClientNode.<init>(ClientNode.java:32)
at syncdemo.SyncDemo.main(SyncDemo.java:37)

How do I create SYM Tables in the client node through the API?

I got the code for syncing from here. Which is being used in the ClientNode class as follows:

public class ClientNode {
private ClientSymmetricEngine cEngine;
private File propFile;


public ClientNode(File file) throws FileNotFoundException, IOException {
    propFile = file;
    Properties propertiesFile = new Properties();
    propertiesFile.load(new FileReader(propFile));
    cEngine = new ClientSymmetricEngine(propertiesFile, true);
    getcEngine().openRegistration("store", "001");
    getcEngine().setup();
    getcEngine().start();
}

public ClientSymmetricEngine getcEngine() {
    return cEngine;
}

public void setcEngine(ClientSymmetricEngine cEngine) {
    this.cEngine = cEngine;
}
}

Calling clientNode class from here:

public class SyncDemo {       

public static void main(String[] args) {

      try 
        {
        new ClientNode(new File("/client.properties"));
        }
        catch (Exception e) 
        {
        e.printStackTrace();
        }

}
}

Content of client.properties file:

external.id=001
engine.name=store-001
sync.url=http://192.168.1.107:31415/sync/corp-000
group.id=store
db.url=jdbc:h2:./syncdata/store001;AUTO_SERVER=TRUE;LOCK_TIMEOUT=60000
db.driver=org.h2.Driver
db.user=symmetric
registration.url=http://192.168.1.107:31415/sync/corp-000
db.password=
auto.config.database=true  

I just noticed that even if the SYM Tables are present in the client node's database, same exception is thrown unless appropriate data is inserted in SYM_NODE and SYM_NODE_IDENTITY tables.

Community
  • 1
  • 1

2 Answers2

1

The issue was resolved by modifying the code:

public ClientNode(File file) throws FileNotFoundException, IOException {
propFile = file;
Properties propertiesFile = new Properties();
propertiesFile.load(new FileReader(propFile));
cEngine = new ClientSymmetricEngine(propertiesFile, true);
getcEngine().setup();
getcEngine().openRegistration("store", "001");
getcEngine().start();
}

I think the setup() function creates the config tables in the database and needs to be called before registration.

0

The accepted answer did not work for me, I still got the same error. I got it working with a combination of the change in the accepted answer, plus understanding:

  1. the sync.url on each client node comes from the server at registration time.
  2. the registration.url tells the client nodes where to find the configuration (master) node.
  3. If you've ever screwed either of those up in the past, something in your sym_ tables is messed up. You're probably better off wiping your database and starting again.
  4. the sym_ tables are not auto-populated for you in an embedded app. You must manually populate them. The .../samples/insert_sample.sql file is your friend.
Autumn
  • 1,750
  • 12
  • 29
  • You are correct, your's is the better explainatory response. I must admit, It took considerable time and a lot of fiddling around to learn these details. – Prabal Kajla Apr 01 '17 at 17:04