Lỗi no jbl in java.library.path giữa netbean và prolog năm 2024

1. I re-installed [following a blog here] swi-prolog using macports, found the place where jpl.jar is [on my installation it is on /opt/local/lib/swipl-7.2.3/]

2. Then I redefined in my bashrc the variable $SWI_HOME_DIR=/opt/local/lib/swipl-7.2.3

3. I defined in my bashrc $LD_LIBRARY_PATH [***AND***] set in $CLASSPATH the path $SWI_HOME_DIR/lib as additional path

4. I added as Tomcat launch configuration argument -Djava.library.path=/opt/local/lib/swipl-7.2.3/lib/ in the hope jpl.jar be found

5. I added in eclipse to a SERVLET [in /WebContent/WEB-INF/lib] a copy of the library jpl.jar from the same installation [thanks]

6. I compiled in eclipse a sample code creating and executing a prolog query

Code:

Variable X \= new Variable["X"];

Term arg[] = { X };

org.jpl7.Query q \= new org.jpl7.Query["p",arg];

while [q.hasMoreElements[]]

{

Term bound_to_x \= [Term] [[Map] q.nextElement[]].get["X"];

System.out.println["prolog solution: "+bound_to_x];

}

7. Running the code I get:

javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52] root cause

java.lang.UnsatisfiedLinkError: no jpl in java.library.path java.lang.ClassLoader.loadLibrary[ClassLoader.java:1857] java.lang.Runtime.loadLibrary0[Runtime.java:870] java.lang.System.loadLibrary[System.java:1119] org.jpl7.JPL.loadNativeLibrary[JPL.java:79] org.jpl7.fli.Prolog.[Prolog.java:41] org.jpl7.Query.open[Query.java:260] org.jpl7.Util.textToTerm[Util.java:102] org.jpl7.Query.Query1[Query.java:129] org.jpl7.Query.[Query.java:120] org.semweb.lodz.search.ZHARTSearchUtilities.swiprolog_test[ZHARTSearchUtilities.java:1736] org.semweb.lodz.search.Actions.doGet[Actions.java:716] javax.servlet.http.HttpServlet.service[HttpServlet.java:618] javax.servlet.http.HttpServlet.service[HttpServlet.java:725] org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52]

This happens ONCE [as init code inside org.jpl7.Query] - on reload for the same servlet the exception is:

java.lang.NoClassDefFoundError: Could not initialize class org.jpl7.fli.Prolog org.jpl7.Query.open[Query.java:260] org.jpl7.Util.textToTerm[Util.java:102] org.jpl7.Query.Query1[Query.java:129] org.jpl7.Query.[Query.java:120] org.semweb.lodz.search.ZHARTSearchUtilities.swiprolog_test[ZHARTSearchUtilities.java:1736] org.semweb.lodz.search.Actions.doGet[Actions.java:716] javax.servlet.http.HttpServlet.service[HttpServlet.java:618] javax.servlet.http.HttpServlet.service[HttpServlet.java:725] org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52]

What else is "wrong" in my configuration?

java.lang.UnsatisfiedLinkError: no jpl in java.library.path java.lang.ClassLoader.loadLibrary[ClassLoader.java:1857] java.lang.Runtime.loadLibrary0[Runtime.java:870] java.lang.System.loadLibrary[System.java:1119] org.jpl7.JPL.loadNativeLibrary[JPL.java:79] org.jpl7.fli.Prolog.[Prolog.java:41] org.jpl7.Query.open[Query.java:260] org.jpl7.Util.textToTerm[Util.java:102] org.jpl7.Query.Query1[Query.java:129] org.jpl7.Query.[Query.java:120] org.semweb.lodz.search.ZHARTSearchUtilities.swiprolog_test[ZHARTSearchUtilities.java:1736] org.semweb.lodz.search.Actions.doGet[Actions.java:716] javax.servlet.http.HttpServlet.service[HttpServlet.java:618] javax.servlet.http.HttpServlet.service[HttpServlet.java:725] org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52] 1

java.lang.UnsatisfiedLinkError: no jpl in java.library.path java.lang.ClassLoader.loadLibrary[ClassLoader.java:1857] java.lang.Runtime.loadLibrary0[Runtime.java:870] java.lang.System.loadLibrary[System.java:1119] org.jpl7.JPL.loadNativeLibrary[JPL.java:79] org.jpl7.fli.Prolog.[Prolog.java:41] org.jpl7.Query.open[Query.java:260] org.jpl7.Util.textToTerm[Util.java:102] org.jpl7.Query.Query1[Query.java:129] org.jpl7.Query.[Query.java:120] org.semweb.lodz.search.ZHARTSearchUtilities.swiprolog_test[ZHARTSearchUtilities.java:1736] org.semweb.lodz.search.Actions.doGet[Actions.java:716] javax.servlet.http.HttpServlet.service[HttpServlet.java:618] javax.servlet.http.HttpServlet.service[HttpServlet.java:725] org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52] 3

java.lang.UnsatisfiedLinkError: no jpl in java.library.path java.lang.ClassLoader.loadLibrary[ClassLoader.java:1857] java.lang.Runtime.loadLibrary0[Runtime.java:870] java.lang.System.loadLibrary[System.java:1119] org.jpl7.JPL.loadNativeLibrary[JPL.java:79] org.jpl7.fli.Prolog.[Prolog.java:41] org.jpl7.Query.open[Query.java:260] org.jpl7.Util.textToTerm[Util.java:102] org.jpl7.Query.Query1[Query.java:129] org.jpl7.Query.[Query.java:120] org.semweb.lodz.search.ZHARTSearchUtilities.swiprolog_test[ZHARTSearchUtilities.java:1736] org.semweb.lodz.search.Actions.doGet[Actions.java:716] javax.servlet.http.HttpServlet.service[HttpServlet.java:618] javax.servlet.http.HttpServlet.service[HttpServlet.java:725] org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52] 5

Carlo Capelli

unread,

Nov 18, 2015, 1:56:33 AM11/18/15

to Fabio Ricci, SWI-Prolog

Hi Fabio

this seems an error to me

$SWI_HOME_DIR=/opt/local/lib/swipl-7.2.3

should be

SWI_HOME_DIR=/opt/local/lib/swipl-7.2.3

HTH Carlo

Jan Wielemaker

unread,

Nov 18, 2015, 2:01:11 AM11/18/15

to Fabio Ricci, SWI-Prolog

On 11/17/2015 03:48 PM, Fabio Ricci wrote: \> Dear community :] \> \> I could not figure out how to add this post to other [similar] posts \> concerning this same issue. \> \> I need to have Prolog called from inside a Java Tomcat Servlet.

Most likely you'll regret it ... Just let Prolog run independently and add a reverse proxy to your Tomcat or nginx/apache frontend. No installation issues and quite likely better performance. As Prolog and Java both like to control the process, their interaction in one process is a bit problematic :[

\> My ENV: iMac with Yosemite and Eclipse, Tomcat 8 on Java 8. \> \> 0. Prolog and ClioPatria start well, when called from the terminal \> 1. I re-installed [following a blog here] swi-prolog using macports, \> found the place where jpl.jar is [on my installation it is on \> /opt/local/lib/swipl-7.2.3/] \> 2. Then I redefined in my bashrc the variable \> $SWI_HOME_DIR=/opt/local/lib/swipl-7.2.3 \> 3. I defined in my bashrc $LD_LIBRARY_PATH [***AND***] set in $CLASSPATH \> the path $SWI_HOME_DIR/lib as additional path

The MacOS variable for the dynamic libraries is DYLD_LIBRARY_PATH. The rest is Java stuff about which I know little. MacOS probably has a tool that prints system calls issued by a process. That is what I normally use to find out whether a process is looking at the right files.

Cheers --- Jan

\> 4. I added as Tomcat launch configuration argument \> -Djava.library.path=/opt/local/lib/swipl-7.2.3/lib/ in the hope jpl.jar \> be found \> 5. I added in eclipse to a SERVLET [in /WebContent/WEB-INF/lib] a copy \> of the library jpl.jar from the same installation [thanks] \> 6. I compiled in eclipse a sample code creating and executing a prolog \> query \> \> Code: \> Variable X = new Variable["X"]; \> \> Term arg[] = { X }; \> \> org.jpl7.Query q = new org.jpl7.Query["p",arg]; \> \> while [q.hasMoreElements[]] \> \> { \> \> Term bound_to_x = [Term] [[Map] q.nextElement[]].get["X"]; \> \> System.out.println["prolog solution: "+bound_to_x]; \> \> } \> \> \> 7. Running the code I get: \> \> \> javax.servlet.ServletException: Servlet execution threw an exception \> org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52] \>

\> *root cause*

\> \> java.lang.UnsatisfiedLinkError: no jpl in java.library.path \> java.lang.ClassLoader.loadLibrary[ClassLoader.java:1857] \> java.lang.Runtime.loadLibrary0[Runtime.java:870] \> java.lang.System.loadLibrary[System.java:1119] \> org.jpl7.JPL.loadNativeLibrary[JPL.java:79] \> org.jpl7.fli.Prolog.[Prolog.java:41] \> org.jpl7.Query.open[Query.java:260] \> org.jpl7.Util.textToTerm[Util.java:102] \> org.jpl7.Query.Query1[Query.java:129] \> org.jpl7.Query.[Query.java:120] \> org.semweb.lodz.search.ZHARTSearchUtilities.swiprolog_test[ZHARTSearchUtilities.java:1736] \> org.semweb.lodz.search.Actions.doGet[Actions.java:716] \> javax.servlet.http.HttpServlet.service[HttpServlet.java:618] \> javax.servlet.http.HttpServlet.service[HttpServlet.java:725] \> org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52] \> \>

\> This happens ONCE [as init code insideorg.jpl7.Query] - on reload for the same servlet the exception is:

\> \> \> java.lang.NoClassDefFoundError: Could not initialize class org.jpl7.fli.Prolog \> org.jpl7.Query.open[Query.java:260] \> org.jpl7.Util.textToTerm[Util.java:102] \> org.jpl7.Query.Query1[Query.java:129] \> org.jpl7.Query.[Query.java:120] \> org.semweb.lodz.search.ZHARTSearchUtilities.swiprolog_test[ZHARTSearchUtilities.java:1736] \> org.semweb.lodz.search.Actions.doGet[Actions.java:716] \> javax.servlet.http.HttpServlet.service[HttpServlet.java:618] \> javax.servlet.http.HttpServlet.service[HttpServlet.java:725] \> org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52] \> \> \> \> \> What else is "wrong" in my configuration? \> \> \> Mr. Singleton, what about fixing this [maybe] or adding more verbosity so we spend more time on Prolog than on java paths ;] ? \> \> \> Thank you very much in advance \> \> \> Regards \> \>

\> -- \> You received this message because you are subscribed to the Google \> Groups "SWI-Prolog" group. \> To unsubscribe from this group and stop receiving emails from it, send \> an email to swi-prolog+...@googlegroups.com

\> .

Fabio Ricci

unread,

Nov 18, 2015, 2:30:48 AM11/18/15

to SWI-Prolog

Hi Carlo and Jan - thank you very much for answering

@Carlo: the variable was set without $ - but thank you !!!

@Jan: this sound interesting - anyone of the same idea? I could try to setup a reverse proxy [from TERMINAL to TOMCAT ????] I'm afraid I need here some more deep instruction, Jan. Could you please instruct me a little how to do that or a link wich leads me further? Do I understand you well: You mean there is a SYNC-ISSUE between a Java and a Prolog process???

Thank you in advance

Cheers

Fabio

Jan Wielemaker

unread,

Nov 18, 2015, 2:39:26 AM11/18/15

to Fabio Ricci, SWI-Prolog

On 11/17/2015 04:30 PM, Fabio Ricci wrote: \> \> @Carlo: the variable was set without $ - but thank you !!! \> @Jan: this sound interesting - anyone of the same idea? I could try to \> setup a reverse proxy [from TERMINAL to TOMCAT ????] I'm afraid I need

What do you mean by from TERMINAL?

\> here some more deep instruction, Jan. Could you please instruct me a \> little how to do that or a link wich leads me further? Do I understand \> you well: You mean there is a SYNC-ISSUE between a Java and a Prolog \> process???

Synchronization between the two systems in one process is difficult, in particular on Unix systems where both use signals to communicate between threads. This easily leads to clashes. Even without this nightmare, getting both systems to find each other and all their resources is a pain as you discovered. If anything goes wrong and the process crashes, it is pretty hard to find the culprit. Especially in this case, it is most likely much easier to use the network to make them talk.

Before going into details, please describe how you want to deploy Tomcat and ClioPatria. What must be visible from the web? In what sense does the Tomcat servlet need to talk to ClioPatria or the other way around?

Cheers --- Jan

Fabio Ricci

unread,

Nov 18, 2015, 2:50:18 AM11/18/15

to swi-p...@googlegroups.com

Hi Jan

Thank you for that.

Unix based systems have an application called terminal.

Prolog runs inside a process like a terminals, having a stdout, stderr, stdin - I guess.

I am starting ClioPatria inside its directory with ./run.pl - this calls prolog on a terminal and loads ClioPatria stuff [I have a million RDF triples inside]. So a Prolog Terminal with ClioPatria is started. I do not deploy any ClioPatria web server for the moment. I have my own Tomcat 8 based application bound to an RDF Store, this must remain this way for a while. So what I need now is Prolog attached to my Java servlet in order to pass some queries and to get - one after the other - the Prolog result terms. Again: Tomcat 8 with Java 8.

If I do not use an interface like JPL [provided it runs on my env] I have to parse the terms, well if this is worth - gaining in execution time and in synch freedom, welcome.

Do you think there is a way to efficiently grasp the content of the Prolog terminal process to pass it to Java?

Thank you

Fabio

On Tuesday, November 17, 2015 at 3:48:42 PM UTC+1, Fabio Ricci wrote:

Jan Wielemaker

unread,

Nov 18, 2015, 3:10:20 AM11/18/15

to Fabio Ricci, SWI-Prolog

On 11/17/2015 04:50 PM, Fabio Ricci wrote: \> Unix based systems have an application called terminal. Prolog runs \> inside a process like a terminals, having a stdout, stderr, stdin - I \> guess. I am starting ClioPatria inside its directory with ./run.pl - \> this calls prolog on a terminal and loads ClioPatria stuff [I have a \> million RDF triples inside]. So a Prolog Terminal with ClioPatria is \> started. I do not deploy any ClioPatria web server for the moment. I \> have my own Tomcat 8 based application bound to an RDF Store, this \> must remain this way for a while. So what I need now is Prolog \> attached to my Java servlet in order to pass some queries and to get \> - one after the other - the Prolog result terms. Again: Tomcat 8 \> with Java 8.

Roughly, there are three ways to query ClioPatria:

- Using SPARQL. I'm sure Java has client libraries for that [don't ask me details, I never use Java]. - By adding a dedicated HTTP API for the operation you like, returning the data in whatever format you like.

Both of these do not make it easy to ask for `a result at a time', but ...

- Using the SWISH/Pengines API. That is a generic HTTP interface to create a Prolog engine [Pengine] on the ClioPatria server, give it [optionally] a program and run queries against this program, returning the results as [normally] JavaScript objects in chunks of a size you define [result-by-result, or in chunks of 10, 100, ...].

There is, AFAIK, no ready to use client for the Pengines API for Java. It shouldn't be more than one or two pages, formulating an HTTP POST request to create the pengine, and process the JSON reply. It would be the route I would choose. The pengine idea is described in [1]. A JavaScript client is in pengines.js somewhere in your installed Prolog system. You even find a simple minded Unix shell client in //github.com/SWI-Prolog/swish/tree/master/client.

You activate all this stuff in the ClioPatria server using

?- cpack_install[swish].

Not sure whether that still runs on 7.2.3. Surely works on 7.3.11.

Cheers --- Jan

[1] //journals.cambridge.org/action/displayAbstract?fromPage=online&aid=9303101&fileId=S1471068414000192

\> If I do not use an interface like KPL [provided it runs on my env] I

Fabio Ricci

unread,

Nov 18, 2015, 6:50:29 AM11/18/15

to swi-p...@googlegroups.com

Hi and thank you again.

it sounds a bit complicated in the first shot. I need to scan the result prolog terms to use them in java. Is this way suitable? Anyway, I will think about it :]

Regarding the original problem [and I guess here I will address Mr. Singleton] - Unsatisfied Link - I went into the deepness of the JPL code. It happens that the problem appears inside the class JPL. The Query[] constructor calls JPL which wants to load the jpl library using nativeLibraryPath. But the latter is null at the time of the constructor. So the JPL class passes then a ***null*** or an invalid filename to Runtime.getRuntime[].load0[Reflection.getCallerClass[], filename] - pure java, which crashes.

This behaviour is changed if ***before*** calling the first time the constructor Query[] this nativeLibraryPath be set. This can be accomplished by using JPL.setNativeLibraryPath["pathtolibrary"].

Now - so far so good - we have half the way. What path exactely should be given here???

I thought to give the path of the original prolog installation, hence JPL.setNativeLibraryPath["/Applications/SWI-Prolog.app/Contents/swipl/lib/jpl.jar"]; After doing this, a new exception is thrown:

Nov 17, 2015 8:36:39 PM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Servlet.service[] for servlet [org.semweb.lodz.search.Actions] in context with path [/LODZSearch] threw exception [Servlet execution threw an exception] with root cause

java.lang.UnsatisfiedLinkError: /Applications/SWI-Prolog.app/Contents/swipl/lib/jpl.jar: dlopen[/Applications/SWI-Prolog.app/Contents/swipl/lib/jpl.jar, 1]: no suitable image found. Did find:

/Applications/SWI-Prolog.app/Contents/swipl/lib/jpl.jar: unknown file type, first eight bytes: 0x50 0x4B 0x03 0x04 0x14 0x00 0x08 0x08

So my NEXT QUESTION is: What ist here the path to be given in order to load???

Thanks in advance

Regards

Fabio

On Tuesday, November 17, 2015 at 3:48:42 PM UTC+1, Fabio Ricci wrote:

Fabio Ricci

unread,

Nov 18, 2015, 8:01:37 AM11/18/15

to swi-p...@googlegroups.com

Addendum: I changed to version 7.3.11.

It seems that java's dlopen[] accepts as input dynamic lib files, so the ones and only files with a filename pattern like libswipl.dylib are under $SWI_HOME_DIR/lib.

There, the following directories are found:

Using JPL.setNativeLibraryDir instead of JPL.setNativeLibraryPath,

each of the following initialisation commands ...

JPL.setNativeLibraryDir["/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin14.3.0/"];

JPL.setNativeLibraryDir["/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin14.5.0/"];

JPL.setNativeLibraryDir["/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin15.0.0/"];

leads to an [-other] exception:

java.lang.UnsatisfiedLinkError: no jpl in java.library.path java.lang.ClassLoader.loadLibrary[ClassLoader.java:1857] java.lang.Runtime.loadLibrary0[Runtime.java:870] java.lang.System.loadLibrary[System.java:1119] org.jpl7.JPL.loadNativeLibrary[JPL.java:79] org.jpl7.fli.Prolog.[Prolog.java:41] org.jpl7.Query.open[Query.java:260] org.jpl7.Util.textToTerm[Util.java:102] org.jpl7.Query.Query1[Query.java:129] org.jpl7.Query.[Query.java:120] org.semweb.lodz.search.ZHARTSearchUtilities.swiprolog_test[ZHARTSearchUtilities.java:1736] org.semweb.lodz.search.Actions.doGet[Actions.java:716] javax.servlet.http.HttpServlet.service[HttpServlet.java:618] javax.servlet.http.HttpServlet.service[HttpServlet.java:725] org.apache.tomcat.websocket.server.WsFilter.doFilter[WsFilter.java:52] 7

and of course the paths are correct:

file /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin14.3.0/libjpl.dylib

/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin14.3.0/libjpl.dylib: Mach-O 64-bit bundle x86_64

file /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin14.5.0/libjpl.dylib

/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin14.5.0/libjpl.dylib: Mach-O 64-bit bundle x86_64

file /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin15.0.0/libjpl.dylib

/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin15.0.0/libjpl.dylib: Mach-O 64-bit bundle x86_64

My question is still open ... but maybe I am closer ...

But this might be more information for you

Regards

Fabio

On Tuesday, November 17, 2015 at 3:48:42 PM UTC+1, Fabio Ricci wrote:

Fabio Ricci

unread,

Nov 18, 2015, 8:56:23 AM11/18/15

to SWI-Prolog

Hi again :]

I hope we get here to a solution for all ;]

Cheers

Fabio

On Tuesday, November 17, 2015 at 3:48:42 PM UTC+1, Fabio Ricci wrote:

Fabio Ricci

unread,

Nov 18, 2015, 8:12:54 PM11/18/15

to SWI-Prolog

On Tuesday, November 17, 2015 at 3:48:42 PM UTC+1, Fabio Ricci wrote:

Jan Wielemaker

unread,

Nov 18, 2015, 8:16:36 PM11/18/15

to Fabio Ricci, SWI-Prolog

Roughly, make sure all directories that hold relevant .dylib files are either known system directories or are in DYLD_LIBRARY_PATH. Use otool -L to find dependencies between the libraries. AFAIK, otool doesn't work recursively as Linux ldd does, so you need to do a lot of work or write a script [you might be able to find one].

You've chosen the hardest platform for JPL. It works quite reasonably on Windows, where DLL searching is relatively simple and there is no fight about signal handling. It is a little harder on Linux and hard under MacOSX. There are just too many operating systems and too many Java installations installed in too many different ways to make this an easy job. On most systems you need to study how shared objects or dynamic libraries are resolved and you need tools to find the dependencies. Then you need to set variables and/or use tools to change the search for dependencies in executables or shared objects :[

That is one reasone why I claim it is way easier to run them side-by-side ...

Success --- Jan

Jan Wielemaker

unread,

Nov 18, 2015, 8:17:55 PM11/18/15

to Fabio Ricci, SWI-Prolog

On 11/18/2015 10:12 AM, Fabio Ricci wrote: \> I have to use the native library 14.5.0 - for Yosemite.

Prolog uses the subdir that you find using

?- current_prolog_flag[arch, Arch].

Cheers --- Jan

Fabio Ricci

unread,

Nov 18, 2015, 11:42:39 PM11/18/15

to SWI-Prolog

Hi Jan

Thank you for that. It seems that this JPL or the prolog system be realised for a microsoft machine or a linux system. Posix is indeed a unix system. Now I understand why this all is not running properly on OSX. One solution to ***save*** time [I am not sure whether I am prepared to search for dependences in one library one-by-one, I would prefer to start working now with a great SWI PROLOG integrated with my OSX-TOMCAT! But this does not exist yet [even if the swiprolog portal page suggests the contrary] - this seems to be the current situation.

Pity, I was putting much interest in prolog again. I have ***ONLY*** macs. Anyway on Parallels I could install a virtual windows machine to have prolog running there, but ... does it make really sense?

So having Prolog and Java "Side-by-side" as you say could be a [solution by exclusion].

What does it really means? No connection at all? How are result terms used by the legacy system?

Prolog should not be "per se" but tightly integrated with legacy systems [at least this is my opinion], this could make the real strength of it, otherwise one builds isles of logic programming ... no integration means no use, don't you think so?

I still hope in happy end :]

Thank you

Regards

Fabio

On Tuesday, November 17, 2015 at 3:48:42 PM UTC+1, Fabio Ricci wrote:

Jan Wielemaker

unread,

Nov 19, 2015, 12:06:49 AM11/19/15

to Fabio Ricci, SWI-Prolog

On 11/18/2015 01:42 PM, Fabio Ricci wrote: \> \> So having Prolog and Java "Side-by-side" as you say could be a \> [solution by exclusion]. What does it really means? No connection at \> all? How are result terms used by the legacy system?

It means using the network to communicate. That eliminates all these dependency issues [which has nothing to do with Prolog] and also nicely exposes the interactive development environment of Prolog instead of hiding it in Java.

There are zillions of ways to make them communicate over the network. Considering Pengines over HTTP would be my first option, being both simple and powerful. That means you send an HTTP POST request and you get a JSON document with the results. Surely that shouldn't be too hard in Java.

\> Prolog should not be "per se" but tightly integrated with legacy \> systems [at least this is my opinion], this could make the real \> strength of it, otherwise one builds isles of logic programming ... \> no integration means no use, don't you think so?

In my view, embedding Prolog is in most cases a poor men's solution.

Cheers --- Jan

Fabio Ricci

unread,

Nov 19, 2015, 2:47:02 AM11/19/15

to SWI-Prolog

Hi Jan

thank you for this. Poor man's solution. OK. Probably is a solution in Javascript where a Prolog engine returns json object the best one - this solution bypasses possible synch trouble having Prolog "inside" Java. Not so poor since my tomcat is ssl and digest secured, this is important for the project.

I will evaluate pengine. I expect there to load all the RDF Library and to work with a pengine with 1 million rdf facts + prolog DB over http.

I hope this will *easily* allow

  1. using https and digest [or basic] auth.
  1. using RDF library with all the loaded graphs like ClioPatria

Thank you very much for your hints

Cheers

Fabio

PS: Maybe all this trouble with JPS should ends in a JPL documentation with a DETAILED WARNING, instead of nothing ;]]

On Tuesday, November 17, 2015 at 3:48:42 PM UTC+1, Fabio Ricci wrote:

Jan Wielemaker

unread,

Nov 19, 2015, 3:03:27 AM11/19/15

to Fabio Ricci, SWI-Prolog

On 11/18/2015 04:47 PM, Fabio Ricci wrote: \> \> thank you for this. Poor man's solution. OK. Probably is a solution in \> Javascript where a Prolog engine returns json object the best one - this \> solution bypasses possible synch trouble having Prolog "inside" Java. \> Not so poor since my tomcat is ssl and digest secured, this is important \> for the project. \> \> I will evaluate pengine. I expect there to load all the RDF Library and \> to work with a pengine with 1 million rdf facts + prolog DB over http.

1 million triples will fit easily on your Raspberry pi :]

\> I hope this will *easily* allow \> 1] using https and digest [or basic] auth.

Setting up HTTPS is provided by the SWI-Prolog HTTP server. The ClioPatria wrapper doesn't pass this on AFAIK. I can change that for you. Standard ClioPatria user management uses its own login and cookies. Not sure whether it does basic auth, but again the HTTP server has libs for this, so that is added easily enough.

If you can test the rest of the setup using plain HTTP, I can promise to get these things fixed.

\> 2] using RDF library with all the loaded graphs like ClioPatria

Not sure what you mean by that.

\> Thank you very much for your hints \> Cheers \> Fabio \> \> PS: Maybe all this trouble with JPS should ends in a JPL documentation \> with a DETAILED WARNING, instead of nothing ;]]

I'm unsure where JPL should go. It is a continuous source of trouble, but under some conditions it works well according to some. The linking problems are probably there to stay, I'm afraid. The syncing problems might go as I'm working on a replacement for Prolog's internal synchronisation that eliminates the most dangerous use of signals inside Prolog on POSIX machines.

Cheers --- Jan

Fabio Ricci

unread,

Nov 19, 2015, 3:28:32 AM11/19/15

to SWI-Prolog

Hello Jan

Thank you for that. Can you help me start it up?

1. I have here a prolog process started with ClioPatria's run.pl 2. In this ClioPatra workspace I have loaded about 1 Million RDF triples - Since I only do this for RDF processing. 3. The ClioPatria server is reachable over http through the URL //localhost:3020/home

What I understood to be now achieved is

  1. setting up a prolog server [pengine] which has an identifier and a URL
  2. querying this prolog server using javascript, receiving the results and printing the results somehow.
  3. the prolog code in the prolog engine should "remember" dynamic facts or asserted clauses [learning function], it should be possible to reload the same engine after - say - a power failure.

The javascript code should access the pengine using https and digest [or basic] auth. Not today but say ... in 2 months ;]

Do you think this be affordable? Could help me out depicting a couple of steps fot achieving this?

Of course I looked at //www.swi-prolog.org/pldoc/doc_for?object=section%28%27packages/pengines.html%27%29 and - my compliments! Nevertheless I am not able to start and use the own pengine.

Chủ Đề