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.
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.