赞
踩
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "setContextClassLoader")
elasticsearch 7.15.2
java 1.8.0.291
mysql 8.0.26
具体异常如下:
- fatal error in thread [elasticsearch[ZBMac-C02ZQ3T41.local][clusterApplierService#updateTask][T#1]], exiting
- java.lang.ExceptionInInitializerError
- at java.base/java.lang.Class.forName0(Native Method)
- at java.base/java.lang.Class.forName(Class.java:375)
- at com.mysql.cj.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:98)
- at java.base/java.lang.Class.forName0(Native Method)
- at java.base/java.lang.Class.forName(Class.java:375)
- at org.wltea.analyzer.dic.Dictionary.<clinit>(Dictionary.java:106)
- at org.wltea.analyzer.cfg.Configuration.<init>(Configuration.java:40)
- at org.elasticsearch.index.analysis.IkTokenizerFactory.<init>(IkTokenizerFactory.java:15)
- at org.elasticsearch.index.analysis.IkTokenizerFactory.getIkSmartTokenizerFactory(IkTokenizerFactory.java:23)
- at org.elasticsearch.index.analysis.AnalysisRegistry.buildMapping(AnalysisRegistry.java:433)
- at org.elasticsearch.index.analysis.AnalysisRegistry.buildTokenizerFactories(AnalysisRegistry.java:275)
- at org.elasticsearch.index.analysis.AnalysisRegistry.build(AnalysisRegistry.java:203)
- at org.elasticsearch.index.IndexModule.newIndexService(IndexModule.java:429)
- at org.elasticsearch.indices.IndicesService.createIndexService(IndicesService.java:671)
- at org.elasticsearch.indices.IndicesService.createIndex(IndicesService.java:574)
- at org.elasticsearch.indices.IndicesService.createIndex(IndicesService.java:175)
- at org.elasticsearch.indices.cluster.IndicesClusterStateService.createIndices(IndicesClusterStateService.java:468)
- at org.elasticsearch.indices.cluster.IndicesClusterStateService.applyClusterState(IndicesClusterStateService.java:227)
- at org.elasticsearch.cluster.service.ClusterApplierService.callClusterStateAppliers(ClusterApplierService.java:500)
- at org.elasticsearch.cluster.service.ClusterApplierService.callClusterStateAppliers(ClusterApplierService.java:490)
- at org.elasticsearch.cluster.service.ClusterApplierService.applyChanges(ClusterApplierService.java:461)
- at org.elasticsearch.cluster.service.ClusterApplierService.runTask(ClusterApplierService.java:408)
- at org.elasticsearch.cluster.service.ClusterApplierService.access$000(ClusterApplierService.java:57)
- at org.elasticsearch.cluster.service.ClusterApplierService$UpdateTask.run(ClusterApplierService.java:152)
- at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:678)
- at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:259)
- at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:222)
- at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
- at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
- at java.base/java.lang.Thread.run(Thread.java:833)
- Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "setContextClassLoader")
- at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485)
- at java.base/java.security.AccessController.checkPermission(AccessController.java:1068)
- at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:416)
- at java.base/java.lang.Thread.setContextClassLoader(Thread.java:1525)
- at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.lambda$static$0(AbandonedConnectionCleanupThread.java:77)
- at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:630)
- at java.base/java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:920)
- at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1353)
- at java.base/java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:721)
- at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.<clinit>(AbandonedConnectionCleanupThread.java:80)
- ... 30 more
方案一:修改jdk 安全策略,即修改 java.policy文件。部分版本不支持,会修改无效,因此建议第二种。
方案二:修改es下的安全策略,进入es目录 config下新建 policy.policy文件
1.进入jdk安装目录(mac 环境)
/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre/lib/security
不知道自己mac 的jdk安装在哪的,使用下面命令
/usr/libexec/java_home -V
2.找到java.policy文件,在最下面增加
- permission java.net.SocketPermission "*:*","connect,resolve";
- permission java.lang.RuntimePermission "getClassLoader";
- permission java.lang.RuntimePermission "setContextClassLoader";
如果没有权限修改java.policy文件的话,需要赋权(右键文件-显示简介-给当前用户增加权限)
3. 重启es即可。
1. es安装目录 config 下新建 policy.policy文件,添加如下内容
- grant {
- permission java.net.SocketPermission "*:*","connect,resolve";
- permission java.lang.RuntimePermission "getClassLoader";
- permission java.lang.RuntimePermission "setContextClassLoader";
- };
2.修改jvm.option文件增加
-Djava.security.policy=你的es安装目录/config/policy.policy
3.重启es即可。
版权声明:本文为博主原创文章,转载请注明本页地址。https://mp.csdn.net/mp_blog/creation/editor/122866648
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。