2

I am new to CORB, Trying to delete documents using Java code but I am getting com.marklogic.xcc.exceptions.XQueryException: XDMP-EXTVAR: (err:XPDY0002) declare variable $URI as xs:string* external; -- Undefined external variable fn:QName("","URI") exception.

I am using CORB 2.5.0 as a maven dependency in my java project.

URIS_MODULE is get-uri.xql

xquery version "1.0-ml";
let $uris := cts:uris()
return (count($uris), $uris)

PROCESS-MODULE is transform-docs.xqy

xquery version "1.0-ml";
declare variable $URI as xs:string* external;
xdmp:document-delete($URI)

here is the java code to execute the module,

    Properties properties = new Properties();
    properties.setProperty(Options.XCC_CONNECTION_URI, "xcc://admin:admin-password@localhost:8061/test");
    properties.setProperty(Options.THREAD_COUNT, Integer.toString(8));
    properties.setProperty(Options.PROCESS_MODULE, "src/test/resources/transform-docs.xqy.xqy|ADHOC");
    properties.setProperty(Options.URIS_MODULE, "src/test/resources/get-uri.xqy|ADHOC");
    properties.setProperty(Options.MODULES_DATABASE, "8061-test-modules");

    Manager executor = new Manager();
    executor.init(properties);
    executor.run();

After executing the above code I am getting this warning and code is executing forever,

    Warning at char 9 in xsl:with-param/@select on line 106 column 123 of jobStatsToJson.xsl:
  FODC0002: I/O error reported by XML parser processing
  jar:file:/C:/Users/Shivling%20Bhandare/.m2/repository/com/marklogic/marklogic-corb/2.5.0/marklogic-corb-2.5.0.jar!/: no entry name specified
Warning at char 9 in xsl:with-param/@select on line 107 column 118 of jobStatsToJson.xsl:
  FODC0002: Document has been marked not available:
  jar:file:/C:/Users/Shivling%20Bhandare/.m2/repository/com/marklogic/marklogic-corb/2.5.0/marklogic-corb-2.5.0.jar!/jobStatsToJson.xsl

Update This error went by changing CoRB version but now I am getting this exception,

Latest code is

        Properties properties = new Properties();
        properties.put(Options.PROCESS_MODULE, "src/test/resources/transform-docs.xqy");
        properties.put(Options.URIS_MODULE, "src/test/resources/get-uris.xqy");
        properties.put(Options.THREAD_COUNT, "20");
        properties.put(Options.MODULE_ROOT, "/");
        properties.put(Options.MODULES_DATABASE, "8067-TCOMP-modules");
        properties.put(Options.INSTALL, "1");
        properties.put(Options.XCC_DBNAME, "TCOMP");
        properties.put(Options.XCC_PORT, "8067");
        properties.put(Options.XCC_HOSTNAME, "localhost");
        properties.put(Options.XCC_USERNAME, "admin");
        properties.put(Options.XCC_PASSWORD, "admin");

        Manager manager = new Manager();
        manager.init(properties);
        manager.run();

The error mentioned above is gone by changing CoRB version but now I am getting

WARNING: Connection error count for ContentSource user=admin, cb=TCOMP [provider: address=localhost/127.0.0.1:8067, pool=1/64] is 1. Max limit is 3.
Sep 08, 2021 12:09:26 PM com.marklogic.developer.corb.DefaultContentSourcePool$SessionInvocationHandler invoke
WARNING: Submit request failed 1 times with ServerResponseException. Max Limit is 3. Retrying..
Sep 08, 2021 12:09:26 PM com.marklogic.developer.corb.DefaultContentSourcePool get
WARNING: Connection failed for ContentSource user=admin, cb=TCOMP [provider: address=localhost/127.0.0.1:8067, pool=1/64]. Waiting for 60 seconds before retry attempt 2

Any help is appreciated.

DevNinja
  • 1,459
  • 7
  • 10

2 Answers2

2

If you want to run a CoRB job, then you want to be using the Manager class.

Refer to this Integration Test for an example: https://github.com/marklogic-community/corb2/blob/master/src/test/java/com/marklogic/developer/corb/ManagerIT.java#L100

The ModuleExecutor class is used to execute a single main module.

Both the CoRB Manager and ModuleExecutor are configured in a similar fashion, with same properties, so the ModuleExecutor was attempting to execute your configured PROCESS-MODULE and since there is no default value for your external variable $URIS, it throws an error.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • Thank you @Mads Hansen for your quick response, I tried using Manage but now I am getting another warning and the code is executing forever. Updated my question above. – DevNinja Sep 08 '21 at 00:32
  • It is hard to tell without seeing the code for the XSLT – Mads Hansen Sep 08 '21 at 00:35
  • The error mentioned above is gone by changing CoRB version but now I am getting some other exceptions. Updated description in question – DevNinja Sep 08 '21 at 06:41
  • Update: Issue is resolved by adding "|ADHOC" in PROCESS_MODULE and URIS_MODULE – DevNinja Sep 08 '21 at 06:56
1

Thank you Mads Hansen, If was impossible to fix this issue without your input,

Complete solution is,

Corb verions used

        <dependency>
            <groupId>com.marklogic</groupId>
            <artifactId>marklogic-corb</artifactId>
            <version>2.4.0</version>
        </dependency>

XCC verion used

        <dependency>
            <groupId>com.marklogic</groupId>
            <artifactId>marklogic-xcc</artifactId>
            <version>10.0.6</version>
        </dependency>

Properties and Manager configuration

        Properties properties = new Properties();
        properties.put(Options.PROCESS_MODULE, "src/test/resources/transform-docs.xqy|ADHOC");
        properties.put(Options.URIS_MODULE, "src/test/resources/get-uris.xqy|ADHOC");
        properties.put(Options.THREAD_COUNT, "20");
        properties.put(Options.MODULE_ROOT, "/");
        properties.put(Options.MODULES_DATABASE, "8067-test-modules");
        properties.put(Options.INSTALL, "1");
        properties.put(Options.XCC_DBNAME, "test");
        properties.put(Options.XCC_PORT, "8067");
        properties.put(Options.XCC_HOSTNAME, "localhost");
        properties.put(Options.XCC_USERNAME, "admin");
        properties.put(Options.XCC_PASSWORD, "admin");

        Manager manager = new Manager();
        manager.init(properties);
        manager.run();
DevNinja
  • 1,459
  • 7
  • 10