CORB:未定义的外部变量 fn:QName("","URI")
CORB: Undefined external variable fn:QName("","URI")
我是 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就是get-uri.xql
xquery version "1.0-ml";
let $uris := cts:uris()
return (count($uris), $uris)
PROCESS-MODULE 是 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
class。
ModuleExecutor
class用于执行单个主模块
CoRB 管理器和 ModuleExecutor 都以相似的方式配置,具有相同的属性,因此 ModuleExecutor 试图执行您配置的 PROCESS-MODULE 并且因为没有默认值外部变量 $URIS 的值,它会引发错误。
谢谢 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();
我是 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就是get-uri.xql
xquery version "1.0-ml";
let $uris := cts:uris()
return (count($uris), $uris)
PROCESS-MODULE 是 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
class。
ModuleExecutor
class用于执行单个主模块
CoRB 管理器和 ModuleExecutor 都以相似的方式配置,具有相同的属性,因此 ModuleExecutor 试图执行您配置的 PROCESS-MODULE 并且因为没有默认值外部变量 $URIS 的值,它会引发错误。
谢谢 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();