我是CORB的新手,试图使用Java代码删除文档,但我得到com.marklogic.xcc.exceptions.XQueryException: XDMP-EXTVAR: (err:XPDY0002) declare variable $URI as xs:string* external; -- Undefined external variable fn:QName("","URI")
例外。
我在我的java项目中使用CORB 2.5.0
作为maven依赖项。
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)
这里是执行模块的Java代码,
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();
执行上述代码后,我得到这个警告,代码永远执行,
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
这个错误是通过更改CoRB版本来实现的,但现在我得到了这个异常,
最新代码为
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();
上面提到的错误通过更改CoRB版本而消失,但现在我得到
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
任何帮助都是感激的。
如果您想运行CoRB作业,那么您希望使用Manager
类。
参考以下集成测试示例:https://github.com/marklogic-community/corb2/blob/master/src/test/java/com/marklogic/developer/corb/ManagerIT.java L100
ModuleExecutor
类用于执行单个主模块。
CoRB管理器和ModuleExecutor都以类似的方式配置,具有相同的属性,因此ModuleExecutor试图执行您配置的PROCESS-MODULE并且由于外部变量$ uri没有默认值,因此会抛出错误。
谢谢你Mads Hansen,如果没有你的输入,我们不可能解决这个问题,
完整解是,
使用的Corb版本
<dependency>
<groupId>com.marklogic</groupId>
<artifactId>marklogic-corb</artifactId>
<version>2.4.0</version>
</dependency>
使用的XCC版本
<dependency>
<groupId>com.marklogic</groupId>
<artifactId>marklogic-xcc</artifactId>
<version>10.0.6</version>
</dependency>
属性和管理器配置
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();