-
Notifications
You must be signed in to change notification settings - Fork 1
Description
I try to access XSB prolog from Java. Unfortunately, I cannot establish the connection betweeen XSB and Java when using the XSBSubprocessEngine using the following setup:
- Windows 10 x64
- Java 11
- XSB 3.8
- Interprolog 3.1.1 and master
I execute the code shown in the tutorial but the code is stuck in AbstractPrologEngine::loadInitialFiles in the execution of waitUntilAvailable(). I activated debugging and I see that the library is extracted to a temporary folder, the library path is added and the library is consulted. Afterwards, the process just exits without any notice. Consequently, the Java code starves because there is no reply.
I can reproduce the issue when running XSB on the command line:
PS D:\tmp\XSB.3.8.0> .\bin\xsb64.bat
[xsb_configuration loaded]
[sysinitrc loaded]
[xsbbrat loaded]
XSB Version 3.8.0 (Three-Buck Chuck) of October 28, 2017
[x64-pc-windows; mode: optimal; engine: slg-wam; scheduling: local]
[Build date: 2017-10-31]
| ?- consult:add_lib_dir('C:\\Users\\dev\\AppData\\Local\\Temp\\IP_2573780673931477837\\com\\declarativa\\interprolog').
yes
| ?- consult('C:\\Users\\dev\\AppData\\Local\\Temp\\IP_2573780673931477837\\com\\declarativa\\interprolog\\interprolog.xwam').
PS D:\tmp\XSB.3.8.0>
I gave older interprolog versions a try. With version 3.1.0, I could establish the connection and submit a simple query. The query from the tutorial did not work but that might be because of a different feature set:
PROLOG stdout:Exiting deterministicGoal - (ipPrologEngine(object(class(com.declarativa.interprolog.util.InvisibleObject,long(601494388,1762248238),classDescInfo([int(ID)],2,null)),[] + [0])),javaMessage(object(class(com.declarativa.interprolog.util.InvisibleObject,long(601494388,1762248238),classDescInfo([int(ID)],2,null)),[] + [0]),setEngineStarted)) / 2
PROLOG stdout:
yes
| ?-
PROLOG stdout:Entering deterministicGoal - 3
PROLOG stdout:ipSetSocketsAreBusy(true)
PROLOG stdout:grammar_analysing
PROLOG stdout:grammar_executed
PROLOG stdout:bad_goal_atom - gfj( ( javaMessage('java.lang.System'-out,println(string('Hello from Prolog, Java world!')) ), ( _ ), ([]) )
ipSetSocketsAreBusy(false)
PROLOG stdout:grammar_generating - [object(class(com.declarativa.interprolog.util.ResultFromProlog,long(1890847125,1280299383),classDescInfo([boolean(succeeded),int(timestamp),boolean(undefined),objectField(error,Ljava/lang/Object;),arrayField(rVars,[Ljava/lang/Object;)],2,null)),[] + [0,3,0,string(Syntax error in goal),arrayObject(class([Ljava.lang.Object;,long(-1865525089,275982700),classDescInfo([],2,null)),[])])]
PROLOG stdout:grammar_executed
ipSetSocketsAreBusy(true)
724ms: exiting receiveObject():ResultFromProlog: timestamp==3, error==Syntax error in goal ,undefined==false(Thread[Prolog handler,5,main])
724ms: Received object(Thread[Prolog handler,5,main]): ResultFromProlog: timestamp==3, error==Syntax error in goal ,undefined==false
724ms: Entering handleCallback(Thread[Prolog handler,5,main])
PROLOG stdout:ipSetSocketsAreBusy(false)
724ms: handling ResultFromProlog: timestamp==3, error==Syntax error in goal ,undefined==false(Thread[Prolog handler,5,main])
724ms: forgot goal GoalToExecute (true,true,false), called by Thread[main,5,main]: timestamp==3, goal==gfj( ( javaMessage('java.lang.System'-out,println(string('Hello from Prolog, Java world!')) ), ( _ ), ([]) )
timestamp:3
[]; isIdle()==true(Thread[Prolog handler,5,main])
724ms: About to leave handleCallback(Thread[Prolog handler,5,main])
724ms: firstGoal - Got result for (Thread[main,5,main]): GoalToExecute (true,true,true), called by Thread[main,5,main]: timestamp==3, goal==gfj( ( javaMessage('java.lang.System'-out,println(string('Hello from Prolog, Java world!')) ), ( _ ), ([]) )
timestamp:3
[]
724ms: Handled object and computed(Thread[Prolog handler,5,main]): null
724ms: Leaving firstGoal for (Thread[main,5,main]): javaMessage('java.lang.System'-out,println(string('Hello from Prolog, Java world!'))
724ms: Waiting to receive object(Thread[Prolog handler,5,main])
724ms: entering receiveObject()(Thread[Prolog handler,5,main])
Exception in thread "main" IPPrologError:Syntax error in goal
at com.declarativa.interprolog.SubprocessEngine.firstGoal(SubprocessEngine.java:793)
at com.declarativa.interprolog.SubprocessEngine.deterministicGoal(SubprocessEngine.java:712)
at com.declarativa.interprolog.AbstractPrologEngine.deterministicGoal(AbstractPrologEngine.java:984)
at interprologTest.Main.main(Main.java:31)
PROLOG stdout:Exiting deterministicGoal - _h2778 / 3
Do you have any idea on what causes XSB to terminate after consulting the library? I would be happy to provide more details but I do not know how to get more insight in what happens during the consultation.