当前位置:   article > 正文

elasticsearch 热更新-mysql远程实现异常处理_access denied ("java.lang.runtimepermission" "setc

access denied ("java.lang.runtimepermission" "setcontextclassloader")

一.报错异常:

Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "setContextClassLoader")

二.开发环境:

elasticsearch 7.15.2 

java 1.8.0.291

mysql 8.0.26

具体异常如下:

  1. fatal error in thread [elasticsearch[ZBMac-C02ZQ3T41.local][clusterApplierService#updateTask][T#1]], exiting
  2. java.lang.ExceptionInInitializerError
  3. at java.base/java.lang.Class.forName0(Native Method)
  4. at java.base/java.lang.Class.forName(Class.java:375)
  5. at com.mysql.cj.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:98)
  6. at java.base/java.lang.Class.forName0(Native Method)
  7. at java.base/java.lang.Class.forName(Class.java:375)
  8. at org.wltea.analyzer.dic.Dictionary.<clinit>(Dictionary.java:106)
  9. at org.wltea.analyzer.cfg.Configuration.<init>(Configuration.java:40)
  10. at org.elasticsearch.index.analysis.IkTokenizerFactory.<init>(IkTokenizerFactory.java:15)
  11. at org.elasticsearch.index.analysis.IkTokenizerFactory.getIkSmartTokenizerFactory(IkTokenizerFactory.java:23)
  12. at org.elasticsearch.index.analysis.AnalysisRegistry.buildMapping(AnalysisRegistry.java:433)
  13. at org.elasticsearch.index.analysis.AnalysisRegistry.buildTokenizerFactories(AnalysisRegistry.java:275)
  14. at org.elasticsearch.index.analysis.AnalysisRegistry.build(AnalysisRegistry.java:203)
  15. at org.elasticsearch.index.IndexModule.newIndexService(IndexModule.java:429)
  16. at org.elasticsearch.indices.IndicesService.createIndexService(IndicesService.java:671)
  17. at org.elasticsearch.indices.IndicesService.createIndex(IndicesService.java:574)
  18. at org.elasticsearch.indices.IndicesService.createIndex(IndicesService.java:175)
  19. at org.elasticsearch.indices.cluster.IndicesClusterStateService.createIndices(IndicesClusterStateService.java:468)
  20. at org.elasticsearch.indices.cluster.IndicesClusterStateService.applyClusterState(IndicesClusterStateService.java:227)
  21. at org.elasticsearch.cluster.service.ClusterApplierService.callClusterStateAppliers(ClusterApplierService.java:500)
  22. at org.elasticsearch.cluster.service.ClusterApplierService.callClusterStateAppliers(ClusterApplierService.java:490)
  23. at org.elasticsearch.cluster.service.ClusterApplierService.applyChanges(ClusterApplierService.java:461)
  24. at org.elasticsearch.cluster.service.ClusterApplierService.runTask(ClusterApplierService.java:408)
  25. at org.elasticsearch.cluster.service.ClusterApplierService.access$000(ClusterApplierService.java:57)
  26. at org.elasticsearch.cluster.service.ClusterApplierService$UpdateTask.run(ClusterApplierService.java:152)
  27. at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:678)
  28. at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:259)
  29. at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:222)
  30. at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
  31. at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  32. at java.base/java.lang.Thread.run(Thread.java:833)
  33. Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "setContextClassLoader")
  34. at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485)
  35. at java.base/java.security.AccessController.checkPermission(AccessController.java:1068)
  36. at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:416)
  37. at java.base/java.lang.Thread.setContextClassLoader(Thread.java:1525)
  38. at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.lambda$static$0(AbandonedConnectionCleanupThread.java:77)
  39. at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:630)
  40. at java.base/java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:920)
  41. at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1353)
  42. at java.base/java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:721)
  43. at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.<clinit>(AbandonedConnectionCleanupThread.java:80)
  44. ... 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文件,在最下面增加

  1. permission java.net.SocketPermission "*:*","connect,resolve";
  2. permission java.lang.RuntimePermission "getClassLoader";
  3. permission java.lang.RuntimePermission "setContextClassLoader";

如果没有权限修改java.policy文件的话,需要赋权(右键文件-显示简介-给当前用户增加权限)

3. 重启es即可。 

方案二明细:

1. es安装目录 config 下新建 policy.policy文件,添加如下内容

  1. grant {
  2. permission java.net.SocketPermission "*:*","connect,resolve";
  3. permission java.lang.RuntimePermission "getClassLoader";
  4. permission java.lang.RuntimePermission "setContextClassLoader";
  5. };

2.修改jvm.option文件增加

-Djava.security.policy=你的es安装目录/config/policy.policy

3.重启es即可。

版权声明:本文为博主原创文章,转载请注明本页地址。https://mp.csdn.net/mp_blog/creation/editor/122866648

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/136340
推荐阅读
相关标签
  

闽ICP备14008679号