尝试让Elasticsearch运行并为PDF编制索引。我不熟悉Java。它抱怨的窗口服务器是什么,我该如何解决?
Jun 13 15:57:23 server.mydomain.com java[22345] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Exception in thread "elasticsearch[index]-pool-2-thread-1" java.lang.InternalError: Can't connect to window server - not enough permissions.
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1827)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1724)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1605)
at java.awt.Toolkit.<clinit>(Toolkit.java:1627)
at java.awt.Color.<clinit>(Color.java:263)
at org.apache.pdfbox.pdmodel.PDPage.<clinit>(PDPage.java:80)
at org.apache.pdfbox.pdmodel.PDPageNode.getAllKids(PDPageNode.java:212)
at org.apache.pdfbox.pdmodel.PDPageNode.getAllKids(PDPageNode.java:218)
at org.apache.pdfbox.pdmodel.PDPageNode.getAllKids(PDPageNode.java:184)
at org.apache.pdfbox.pdmodel.PDDocumentCatalog.getAllPages(PDDocumentCatalog.java:211)
at org.apache.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:322)
at org.apache.tika.parser.pdf.PDF2XHTML.process(PDF2XHTML.java:63)
at org.apache.tika.parser.pdf.PDFParser.parse(PDFParser.java:140)
at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:242)
at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:242)
at org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:120)
at org.elasticsearch.plugin.mapper.attachments.tika.TikaExtended.parseToString(TikaExtended.java:48)
at org.elasticsearch.index.mapper.attachment.AttachmentMapper.parse(AttachmentMapper.java:309)
at org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:585)
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:449)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:493)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:437)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:290)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:210)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
答案 0 :(得分:7)
为了能够正确索引PDF,ElasticSearch要求Apache Tika提取文本。反过来,Apache Tika要求Apache PDFBox解析文件以进行处理。由于PDF的工作方式,PDFBox需要使用Java AWT调用来处理字体,颜色等问题
您的计算机当前未正确设置为Java以执行图形操作,因此当PDFBox尝试使用AWT处理PDF时,它会爆炸。
你有两个选择。一种是完成图形设置,另一种是告诉Java以无头模式运行。
如果你谷歌搜索你的错误信息,那么你会发现很多有用的答案,关于如何为任一选项执行适当的OSX设置。 This one看起来是一个很好的例子。与Java的大多数unix变量一样,如果您使用
运行Javajava -Djava.awt.headless=true
然后它将使用无头模式,并且不会遇到真实图形系统的权限问题。
答案 1 :(得分:2)
这是您的应用程序尝试在无头环境中使用AWT的结果。
要修复它,请使用选项告诉AWT使用无头模式启动应用程序。
-Djava.awt.headless=true