SWI-Prolog / packages-jpl

JPL: The Prolog <-> Java interface
BSD 2-Clause "Simplified" License
54 stars 33 forks source link

The specified module could not be found #93

Closed rzese closed 3 years ago

rzese commented 3 years ago

Dear all, I have a problem similar to #92, but from the other side. I am trying to load JPL from Prolog. I should have set properly all the environmental variables, I am using the daily binaries. If I call Prolog from Java, everything works fine. If I try to load JPL library from Prolog using the command [library(jpl)]. I get

ERROR: c:/program files/swipl/library/jpl.pl:5428:
ERROR:    '$open_shared_object'/3: The specified module could not be found.

ERROR: c:/program files/swipl/library/jpl.pl:5428: Initialization goal raised exception:
ERROR: Unknown procedure: jpl:jni_get_default_jvm_opts/1
ERROR: In:
ERROR:   [47] jpl:jni_get_default_jvm_opts(_60310)
ERROR:   [45] jpl:extend_java_library_path('c:\\program files\\swipl\\bin') at c:/program files/swipl/library/jpl.pl:4076
ERROR:   [44] jpl:add_jpl_to_ldpath(foreign(jpl)) at c:/program files/swipl/library/jpl.pl:4024
ERROR:   [43] jpl:setup_jvm at c:/program files/swipl/library/jpl.pl:4172
ERROR:   [42] '$run_init_goal'(jpl:setup_jvm) at c:/program files/swipl/boot/init.pl:796
ERROR:   [41] catch(system:'$run_init_goal'(...),error(existence_error(procedure,...),context(...,_60516)),system:'$initialization_error'(...,...,...)) at c:/program files/swipl/boot/init.pl:546
ERROR:   [40] catch_with_backtrace(system:'$run_init_goal'(...),error(existence_error(procedure,...),context(...,_60592)),system:'$initialization_error'(...,...,...)) at c:/program files/swipl/boot/init.pl:614
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
ERROR: Exported procedure jpl:jpl_c_lib_version/1 is not defined

I have also called win_process_modules/1, which returns: c:/program files/swipl/bin/swipl.exe, c:/windows/system32/ntdll.dll, c:/windows/system32/kernel32.dll, c:/windows/system32/kernelbase.dll, c:/windows/system32/msvcrt.dll, c:/program files/swipl/bin/libswipl.dll, c:/windows/system32/advapi32.dll, c:/windows/system32/sechost.dll, c:/windows/system32/rpcrt4.dll, c:/windows/system32/psapi.dll, c:/windows/system32/shell32.dll, c:/windows/system32/msvcp_win.dll, c:/windows/system32/ucrtbase.dll, c:/program files/swipl/bin/libgcc_s_seh-1.dll, c:/program files/swipl/bin/libwinpthread-1.dll, c:/windows/system32/user32.dll, c:/windows/system32/win32u.dll, c:/windows/system32/gdi32.dll, c:/windows/system32/gdi32full.dll, c:/windows/system32/ws2_32.dll, c:/windows/system32/winmm.dll, c:/program files/swipl/bin/libgmp-10.dll, c:/program files/swipl/bin/zlib1.dll, c:/windows/system32/imm32.dll, c:/windows/system32/windows.storage.dll, c:/windows/system32/combase.dll, c:/windows/system32/wldp.dll, c:/windows/system32/shcore.dll, c:/windows/system32/shlwapi.dll, c:/windows/system32/profapi.dll

Here I cannot see the jvm.dll, I don't know if this could be the problem. However, JAVA_HOME is set to C:\Program Files\AdoptOpenJDK\jre-8.0.292.10-hotspot and in PATH I have both %JAVA_HOME%\bin and %JAVA_HOME%\bin\server.

Any idea to solve the problem? Thank you

JanWielemaker commented 3 years ago

Hard to say. jpl and the jvm dlls are not in the process modules because it cannot load them. If it works the other way around, use win_process_modules/1 in that config and see whether you have missed some directory or you have a directory in %PATH% that should not be there and it gets a conflicting file from some other location.

rzese commented 3 years ago

I have cleaned up my JDKs and environment variables. Now, magically, it works :) Probably there were some conflicting files as you suggested.

Many thanks