春季-具有SWI-Prolog的Docker容器因致命错误而终止

前端之家收集整理的这篇文章主要介绍了春季-具有SWI-Prolog的Docker容器因致命错误而终止 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在开发一个Spring Boot Web应用程序,它使用SWI-Prolog的JPL接口从Java调用Prolog.在开发模式下,一切正常.
当我将其部署到Docker时,通过API对JPL的首次调用运行良好.当我尝试再次调用JPL时,JVM崩溃.

我使用LD_PRELOAD指向libswipl.so

SWI_HOME_DIR也被设置.

LD_LIBRARY_PATH设置为指向libjvm.so

我的控制器功能

  1. @PostMapping("/rules/testAPI/")
  2. @Timed
  3. public List<String> insertRule() {
  4. String use_module_http = "use_module(library(http/http_open)).";
  5. JPL.init();
  6. Query q1 = new Query(use_module_http);
  7. if (!q1.hasNext()) {
  8. System.out.println("Failed to load HTTP Module");
  9. } else {
  10. System.out.println("Succeeded to load HTTP Module");
  11. }
  12. return null;
  13. }

控制台输出

第一次通话

  1. Succeeded to load HTTP Module

第二次通话

  1. #
  2. # A fatal error has been detected by the Java Runtime Environment:
  3. #
  4. # SIGSEGV (0xb) at pc=0x00007f31705294b2,pid=16,tid=0x00007f30d2eee700
  5. #
  6. # JRE version: OpenJDK Runtime Environment (8.0_191-b12) (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
  7. # Java VM: OpenJDK 64-Bit Server VM (25.191-b12 mixed mode linux-amd64 compressed oops)
  8. # Problematic frame:
  9. # C [libswipl.so+0xb34b2] PL_thread_attach_engine+0xe2
  10. #
  11. # Core dump written. Default location: //core or core.16
  12. #
  13. # If you would like to submit a bug report,please visit:
  14. # http://bugreport.java.com/bugreport/crash.jsp
  15. # The crash happened outside the Java Virtual Machine in native code.
  16. # See problematic frame for where to report the bug.
  17. #

我将错误日志文件上传到pastebin中. click here

有没有人遇到过同样的问题?有解决办法吗?

请注意,我也使用oracle-java-8进行了检查,但是发生相同的错误.

更新:

@CapelliC答案无效.

最佳答案
我想我会尝试“使用”该术语.例如

  1. Query q1 = new Query(use_module_http);
  2. if (!q1.hasNext()) {
  3. System.out.println("Failed to load HTTP Module");
  4. } else {
  5. System.out.println("Succeeded to load HTTP Module:"+q1.next().toString());
  6. // remember q1.close() if there could be multiple soultions
  7. }

或更好

  1. if ((new Query(use_module_http)).oneSolution() == null) ...

还是更好

  1. if ((new Query(use_module_http)).hasSolution() == false) ...

猜你在找的Spring相关文章