尝试在 OS X 中使用 JPL 和 YAP Prolog 时抛出异常
我正在尝试使用 JPL 进行 Java 程序和 YAP Prolog 的交互。
在我的 java 文件中,此行引发异常:
Query query = new Query("consult", new Term[] { new Atom("test.pl") });
显示异常如下:
Exception in thread "main" jpl.JPLException: this Query's engine is not that which is attached to this thread
at jpl.Query.close(Query.java:511)
at jpl.Util.textToTerm(Util.java:165)
at jpl.Query.Query1(Query.java:183)
at jpl.Query.<init>(Query.java:176)
at Test.main(Test.java:12)
虽然我在 YAP 中没有发现有人报告相同的问题,但有些人在使用 SWI 时遇到了这个问题,并且建议他们验证 SWI 是否已编译为支持多线程。以防万一我编译了支持多线程的 YAP,但它没有帮助。
这个问题只发生在 OS X 中,我在 Ubuntu 中尝试过,一切正常。
有人知道 OS X 中此问题的解决方法吗?
I am trying to use JPL for the interaction of Java programs and YAP Prolog.
In my java file, this line is throwing an exception:
Query query = new Query("consult", new Term[] { new Atom("test.pl") });
The exception is shown below:
Exception in thread "main" jpl.JPLException: this Query's engine is not that which is attached to this thread
at jpl.Query.close(Query.java:511)
at jpl.Util.textToTerm(Util.java:165)
at jpl.Query.Query1(Query.java:183)
at jpl.Query.<init>(Query.java:176)
at Test.main(Test.java:12)
Although I did not find someone reporting the same problem in YAP, some people were having this problem with SWI, and they were advised to verify that SWI was compiled with multi-threading support. Just in case I compiled YAP with support for multithreading, but it did not help.
This problem is happening only in OS X, I tried in Ubuntu and everything works fine there.
Does someone know a workaround for this problem in OS X?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 Yap 更新到 6.2.2 后,JPL 可以正常工作。不幸的是,我不能完全确定该问题确实与我使用的先前 Yap 版本(6.2.0)有关,还是与其他内容有关。
After updating Yap to 6.2.2 JPL is working correctly. Unfortunately I cannot be completely sure that the problem was indeed linked to the previous Yap version I was using (6.2.0) or it was related to something else.
看起来你必须设置一个特殊的使用标志来支持 swi-prolog 中的线程。
查看此处了解更多详细信息:
http://comments.gmane.org/gmane .comp.ai.prolog.swi/5335
Looks like you have to set a special use-flag to support threading in swi-prolog.
Look here for more details:
http://comments.gmane.org/gmane.comp.ai.prolog.swi/5335