标签:swi-prolog docker spring-boot jpl spring
我正在开发一个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
我的控制器功能:
@PostMapping("/rules/testAPI/")
@Timed
public List<String> insertRule() {
String use_module_http = "use_module(library(http/http_open)).";
JPL.init();
Query q1 = new Query(use_module_http);
if (!q1.hasNext()) {
System.out.println("Failed to load HTTP Module");
} else {
System.out.println("Succeeded to load HTTP Module");
}
return null;
}
控制台输出
第一次通话
Succeeded to load HTTP Module
第二次通话
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f31705294b2, pid=16, tid=0x00007f30d2eee700
#
# JRE version: OpenJDK Runtime Environment (8.0_191-b12) (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
# Java VM: OpenJDK 64-Bit Server VM (25.191-b12 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libswipl.so+0xb34b2] PL_thread_attach_engine+0xe2
#
# Core dump written. Default location: //core or core.16
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
我将错误日志文件上传到pastebin中. click here
有没有人遇到过同样的问题?有解决办法吗?
请注意,我也使用oracle-java-8进行了检查,但是发生相同的错误.
更新:
@CapelliC答案无效.
解决方法:
我想我会尝试“使用”该术语.例如
Query q1 = new Query(use_module_http);
if (!q1.hasNext()) {
System.out.println("Failed to load HTTP Module");
} else {
System.out.println("Succeeded to load HTTP Module:"+q1.next().toString());
// remember q1.close() if there could be multiple soultions
}
或更好
if ((new Query(use_module_http)).oneSolution() == null) ...
还是更好
if ((new Query(use_module_http)).hasSolution() == false) ...
标签:swi-prolog,docker,spring-boot,jpl,spring 来源: https://codeday.me/bug/20191211/2106485.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。