编写es自定义分词的时候,分词报这个错误
java.lang.ExceptionInInitializerError: null
at com.hankcs.hanlp.seg.common.Vertex.<clinit>(Vertex.java:56) ~[?:?]
at com.hankcs.hanlp.seg.common.WordNet.<init>(WordNet.java:71) ~[?:?]
at com.hankcs.hanlp.seg.Viterbi.ViterbiSegment.segSentence(ViterbiSegment.java:40) ~[?:?]
at com.hankcs.hanlp.seg.Segment.seg(Segment.java:422) ~[?:?]
at org.wltea.analyzer.core.HanlpSegmenter.analyze(HanlpSegmenter.java:61) ~[?:?]
at org.wltea.analyzer.core.Segmenter.next(Segmenter.java:115) ~[?:?]
at org.wltea.analyzer.lucene.HanlpTokenizer.incrementToken(HanlpTokenizer.java:86) ~[?:?]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.simpleAnalyze(TransportAnalyzeAction.java:222) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.analyze(TransportAnalyzeAction.java:200) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:148) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:75) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$ShardTransportHandler.messageReceived(TransportSingleShardAction.java:294) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$ShardTransportHandler.messageReceived(TransportSingleShardAction.java:287) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.transport.TransportService$6.doRun(TransportService.java:577) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:527) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.1.1.jar:5.1.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_112]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_112]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_112]
Caused by: java.lang.SecurityException: java.lang.System#exit(-1) calls are not allowed
at org.elasticsearch.SecureSM$2.run(SecureSM.java:243) ~[securesm-1.1.jar:5.1.1]
at org.elasticsearch.SecureSM$2.run(SecureSM.java:208) ~[securesm-1.1.jar:5.1.1]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_112]
at org.elasticsearch.SecureSM.innerCheckExit(SecureSM.java:208) ~[securesm-1.1.jar:5.1.1]
at org.elasticsearch.SecureSM.checkExit(SecureSM.java:201) ~[securesm-1.1.jar:5.1.1]
at java.lang.Runtime.exit(Runtime.java:107) ~[?:1.8.0_112]
at java.lang.System.exit(System.java:971) ~[?:1.8.0_112]
at com.hankcs.hanlp.dictionary.CoreDictionary.<clinit>(CoreDictionary.java:43) ~[?:?]
... 21 more
有大神遇到过么?
java.lang.ExceptionInInitializerError: null
at com.hankcs.hanlp.seg.common.Vertex.<clinit>(Vertex.java:56) ~[?:?]
at com.hankcs.hanlp.seg.common.WordNet.<init>(WordNet.java:71) ~[?:?]
at com.hankcs.hanlp.seg.Viterbi.ViterbiSegment.segSentence(ViterbiSegment.java:40) ~[?:?]
at com.hankcs.hanlp.seg.Segment.seg(Segment.java:422) ~[?:?]
at org.wltea.analyzer.core.HanlpSegmenter.analyze(HanlpSegmenter.java:61) ~[?:?]
at org.wltea.analyzer.core.Segmenter.next(Segmenter.java:115) ~[?:?]
at org.wltea.analyzer.lucene.HanlpTokenizer.incrementToken(HanlpTokenizer.java:86) ~[?:?]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.simpleAnalyze(TransportAnalyzeAction.java:222) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.analyze(TransportAnalyzeAction.java:200) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:148) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:75) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$ShardTransportHandler.messageReceived(TransportSingleShardAction.java:294) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$ShardTransportHandler.messageReceived(TransportSingleShardAction.java:287) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.transport.TransportService$6.doRun(TransportService.java:577) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:527) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.1.1.jar:5.1.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_112]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_112]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_112]
Caused by: java.lang.SecurityException: java.lang.System#exit(-1) calls are not allowed
at org.elasticsearch.SecureSM$2.run(SecureSM.java:243) ~[securesm-1.1.jar:5.1.1]
at org.elasticsearch.SecureSM$2.run(SecureSM.java:208) ~[securesm-1.1.jar:5.1.1]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_112]
at org.elasticsearch.SecureSM.innerCheckExit(SecureSM.java:208) ~[securesm-1.1.jar:5.1.1]
at org.elasticsearch.SecureSM.checkExit(SecureSM.java:201) ~[securesm-1.1.jar:5.1.1]
at java.lang.Runtime.exit(Runtime.java:107) ~[?:1.8.0_112]
at java.lang.System.exit(System.java:971) ~[?:1.8.0_112]
at com.hankcs.hanlp.dictionary.CoreDictionary.<clinit>(CoreDictionary.java:43) ~[?:?]
... 21 more
有大神遇到过么?
4 个回复
kennywu76 - Wood
赞同来自: kepmoving 、famoss 、Scs
解决方法一个是更改这个第三方库,在异常的时候不要掉用system.exit,或者为这个库加一个白名单(有安全隐患,不建议这么做)。
参考:
[url=https://www.elastic.co/guide/en/elasticsearch/reference/5.2/modules-scripting-security.html#java-security-manager]https://www.elastic.co/guide/e ... nager[/url]
[url=http://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html]http://docs.oracle.com/javase/ ... .html[/url]
Scs
赞同来自:
lx
赞同来自:
ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [Bh2_MZO] fatal error in thread [elasticsearch[Bh2_MZO][analyze][T#1]], exiting
java.lang.ExceptionInInitializerError: null
at com.hankcs.hanlp.seg.Segment.seg(Segment.java:338) ~[?:?]
at com.hankcs.lucene4.HanlpSegmenter.next(HanlpSegmenter.java:65) ~[?:?]
at com.hankcs.lucene4.HanLPTokenizer.incrementToken(HanLPTokenizer.java:46) ~[?:?]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.simpleAnalyze(TransportAnalyzeAction.java:275) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.analyze(TransportAnalyzeAction.java:252) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:170) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:81) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$1.doRun(TransportSingleShardAction.java:115) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-6.7.0.jar:6.7.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_201]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "*" "read,write")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) ~[?:1.8.0_201]
at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_201]
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) ~[?:1.8.0_201]
at java.lang.SecurityManager.checkPropertiesAccess(SecurityManager.java:1262) ~[?:1.8.0_201]
at java.lang.System.getProperties(System.java:630) ~[?:1.8.0_201]
at com.hankcs.hanlp.HanLP$Config.<clinit>(HanLP.java:240) ~[?:?]
... 13 more
hapjin
赞同来自: