在MarkLogic中读取文档内容时出现异常

时间:2014-04-24 13:39:55

标签: marklogic

当我尝试使用它的URI从MarkLogic数据库中读取文本文档时,我得到了指定的异常:

[Fatal Error] :1:1: Content is not allowed in prolog.
Exception in thread "main" com.marklogic.client.FailedRequestException: Local message: read failed: Bad Request. Server Message: Request failed. Unable to parse server error details
    at com.marklogic.client.impl.JerseyServices.getDocumentImpl(JerseyServices.java:527)
    at com.marklogic.client.impl.JerseyServices.getDocument(JerseyServices.java:393)
    at com.marklogic.client.impl.DocumentManagerImpl.read(DocumentManagerImpl.java:210)
    at com.marklogic.client.impl.DocumentManagerImpl.read(DocumentManagerImpl.java:144)
    at com.marklogic.client.impl.DocumentManagerImpl.read(DocumentManagerImpl.java:114)
    at com.marklogic.client.example.tutorial.Example_07_ReadText.main(Example_07_ReadText.java:49)

2 个答案:

答案 0 :(得分:2)

User3569076:

听起来请求失败但Java API无法解析错误消息,因为错误消息不是XML。

创建数据库客户端时,是否指定了REST API服务器的主机名和端口?

如果没有,以下是为数据库创建REST API服务器的说明:

http://docs.marklogic.com/guide/rest-dev/service#id_12021

您可以尝试从Web浏览器中的主机和端口获取文档来测试REST API的可用性:

http://docs.marklogic.com/REST/GET/v1/documents

希望有帮助,

Erik Hennum

答案 1 :(得分:0)

我在MarkLogic数据库中加载JSON文件时遇到了同样的错误。 我发现错误是我的JSON文件无效。我的JSON文件中存在一些语法错误。 我建议你做的是检查你的XML文件是否有效。

希望这会有所帮助。