ConfD User Community

com.tailf.cdb.CdbException: Unknown CDB operation

I am writing a program in Java that subscribes to changes in CDB. I want to subscribe to all the changes but for starter any particular path will also work.

Following is the code snippet I have written following the practices defined for tailf CDB API in NSO documents:

Socket socket;
        Cdb cdb;
        try {
            socket = new Socket("localhost", 4570);
            cdb = new Cdb("MyCdbSock", socket);
            CdbSession session = cdb.startSession();
            CdbSubscription subscription = cdb.newSubscription();
            int subid = subscription.subscribe(CdbSubscriptionType.SUB_RUNNING, 1, new Ncs(), "/");
            subscription.subscribeDone();

This code throws an error on the subscription.subscribe line, with following execption:

com.tailf.cdb.CdbException: Unknown CDB operation
	at com.tailf.cdb.CdbException.mk(CdbException.java:64)
	at com.tailf.cdb.CdbException.mk(CdbException.java:59)
	at com.tailf.cdb.CdbSubscription.subscribe(CdbSubscription.java:553)
	at com.tailf.cdb.CdbSubscription.subscribe(CdbSubscription.java:501)
	at com.tailf.cdb.CdbSubscription.subscribe(CdbSubscription.java:668)

Anyone knows what is wrong here? The error does not give much details. The java program is not running inside the NSO java vm. It is a standalone application.

you can check working example in ConfD examples package - ${CONFD_DIR}/examples.confd/intro/java/1-2-3-start-query-model
for potential differences form your code that could be causing the problems…

(you seem to have different number/type of parameters in subscription.subscribe() method, compared to original example…)

Thanks @josephm

Yes, I had different number and type of parameters, but changing it did not help. However, I removed the creation of CdbSession line and it worked fine. I am still not sure why that can be a problem but apparently that was the reason.