Hello,
In order for CFFI to load, I need to load jna-4.2.2.jar.
Right now, I have to do something like this: (let ((jar-pathname #P"c:/Users/977315/.m2/repository/net/java/dev/jna/jna/4.2.2/jna-4.2.2.jar")) (java:add-to-classpath (namestring jar-pathname)))
To automate loading of ASDFs that require CFFI I tried to automate the process by adding a before method to 'load-op:
(eval-when (:compile-toplevel :execute :load-toplevel) (defmethod operate :before ((operation (eql 'asdf/lisp-action:load-op)) (component (eql :cffi))) (let ((jar-pathname #P"c:/Users/977315/.m2/repository/net/java/dev/jna/jna/4.2.2/jna-4.2.2.jar")) (java:add-to-classpath (namestring jar-pathname)))))
That did not work. I did read the ASDF manual, but could not figure out how to do it.
I suspect someone has figured out the right way. What is it?
Thanks,
Mirko
In case this helps, I launch ABCL using this script, which I call abcl.sh:
#!/bin/bash exec rlwrap java -classpath $HOME/sw/jna-4.1.0.jar:/usr/local/abcl-bin-1.4.0/abcl.jar:/usr/local/asm-5.2/lib/all/asm-all-5.2.jar org.armedbear.lisp.Main "$@"
jna lets me use CFFI (if I remember correctly), asm lets me use #'disassemble, rlwrap gives me readline support
However, I suspect that you're trying to get your ASDF system to load in other people's installations, without requiring them to use a script like the above. In that case, the above is useless.
---- What if you just place your first snippet into its own file, say "load-jna.lisp". List that as the first file in your ASDF system. When subsequent files load, they will find JNA already in place. Might that work?
Vibhu
On 5/10/17 22:24, Mirko Vukovic wrote:
Hello,
In order for CFFI to load, I need to load jna-4.2.2.jar.
Right now, I have to do something like this: (let ((jar-pathname #P"c:/Users/977315/.m2/repository/net/java/dev/jna/jna/4.2.2/jna-4.2.2.jar")) (java:add-to-classpath (namestring jar-pathname)))
To automate loading of ASDFs that require CFFI I tried to automate the process by adding a before method to 'load-op:
(eval-when (:compile-toplevel :execute :load-toplevel) (defmethod operate :before ((operation (eql 'asdf/lisp-action:load-op)) (component (eql :cffi))) (let ((jar-pathname #P"c:/Users/977315/.m2/repository/net/java/dev/jna/jna/4.2.2/jna-4.2.2.jar")) (java:add-to-classpath (namestring jar-pathname)))))
That did not work. I did read the ASDF manual, but could not figure out how to do it.
I suspect someone has figured out the right way. What is it?
Such "manual" loading of the JNA should be not be necessary in the default case of using ABCL-ASDF's Maven integration to download from the network, which is what [the ABCL specific portion of][cffi] does.
[cffi]: https://github.com/cffi/cffi/blob/master/src/cffi-abcl.lisp#L37
The
(require :jna)
refers to the [jna.asd][] definition, which is then passed to ABCL-ASDF for resolution.
[jna.asd]: https://gitlab.common-lisp.net/abcl/abcl/blob/master/contrib/mvn/jna.asd
"All" that you need to do to get this to work is to have a version of Maven installed. The [ABCL-ASDF][1] code should find the Maven executable in the JVM process path with which it will introspect the necessary operations needed to use the Mavane Aether infrastructure.
[1]: https://gitlab.common-lisp.net/abcl/abcl/blob/master/contrib/abcl-asdf/maven...
To go forward with your problems:
1. Do you have Maven installed or is there some reason in your deployment scenario that you do not wish to use it?
2. Without trying to load CFFI, does the following form load JNA from a fresh REPL?
(require :abcl-contrib) (require :jna)
Hi Mark,
Thanks for responding. See below for my replies
On Thu, May 11, 2017 at 2:23 AM Mark Evenson evenson@panix.com wrote:
On 5/10/17 22:24, Mirko Vukovic wrote:
Hello,
In order for CFFI to load, I need to load jna-4.2.2.jar.
Right now, I have to do something like this:
stuff deleted
Such "manual" loading of the JNA should be not be necessary in the default case of using ABCL-ASDF's Maven integration to download from the network, which is what [the ABCL specific portion of][cffi] does.
The
(require :jna)
refers to the [jna.asd][] definition, which is then passed to ABCL-ASDF for resolution.
I don't have jna.asd anywhere on my computer
"All" that you need to do to get this to work is to have a version of Maven installed. The [ABCL-ASDF][1] code should find the Maven executable in the JVM process path with which it will introspect the necessary operations needed to use the Mavane Aether infrastructure.
[1]:
https://gitlab.common-lisp.net/abcl/abcl/blob/master/contrib/abcl-asdf/maven...
To go forward with your problems:
- Do you have Maven installed or is there some reason in your
deployment scenario that you do not wish to use it?
I do have Maven installed and in path, as given by mvn.bat -v .
I looked at abcl-asdf in the provided link and did some checking from within ABCL. The outputs of abcl-asdf::find-mvn, abcl-asdf::mvn-version were OK. Interestingly, I don't have abcl-asdf:mvn-home defined. Is my asdf 3.1.7.27 obsolete?
- Without trying to load CFFI, does the following form load JNA from a
fresh REPL?
(require :abcl-contrib)
returns NIL
(require :jna)
Triggers error: Java exception 'java.lang.ClassNotFoundException: com.sun.jna.Native'.
My jna is under my home directory in "c:/Users/977315/.m2/repository/net/java/dev/jna/jna/4.2.2/jna-4.2.2.jar"
That directory is non in CLASSPATH
Thanks,
Mirko
On 5/12/17 15:36, Mirko Vukovic wrote: […]
I don't have jna.asd anywhere on my computer
It is packaged as part of `abcl-contrib.jar`.
[…]
I looked at abcl-asdf in the provided link and did some checking from within ABCL. The outputs of abcl-asdf::find-mvn, abcl-asdf::mvn-version were OK. Interestingly, I don't have abcl-asdf:mvn-home defined. Is my asdf 3.1.7.27 obsolete?
It shouldn't be obsolete, as it is packaged as part of `abcl.jar`.
- Without trying to load CFFI, does the following form load JNA from a
fresh REPL?
(require :abcl-contrib)
returns NIL
This indicates that for some reason your installation cannot locate abcl-contrib.jar.
For an ABCL installed via MacPorts, one can show the following details of the setup that may give a bit of insight into what a "healthy" version might look like:
--
illin:~$ which abcl /opt/local/bin/abcl illin:~$ cat /opt/local/bin/abcl #!/bin/sh
# abcl.in
# Copyright (C) 2004 Peter Graves # Copyright (C) 2009 Erik Huelsmann
# This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
exec /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/bin/java \ -cp /opt/local/share/java/abcl/abcl.jar:"$CLASSPATH" \ \ org.armedbear.lisp.Main \ "$@"
illin:~$ ls -l /opt/local/share/java/abcl/ total 20688 drwxr-xr-x 5 root admin 170 Oct 9 2016 ./ drwxr-xr-x 11 root admin 374 May 7 08:10 ../ -rwxr-xr-x 1 root admin 978 Oct 9 2016 abcl* -rw-r--r-- 1 root admin 53291 Oct 9 2016 abcl-contrib.jar -rw-r--r-- 1 root admin 10530809 Oct 9 2016 abcl.jar illin:~$ abcl --noinit Armed Bear Common Lisp 1.4.0 Java 1.8.0_102 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM Low-level initialization completed in 0.251 seconds. Startup completed in 1.171 seconds. Type ":help" for a list of available commands. CL-USER(1): (require :abcl-contrib) Using probed value of abcl-contrib: '/opt/local/share/java/abcl/abcl-contrib.jar'. Added jar:file:/opt/local/share/java/abcl/abcl-contrib.jar!/quicklisp/ to ASDF. Added jar:file:/opt/local/share/java/abcl/abcl-contrib.jar!/mvn/ to ASDF. Added jar:file:/opt/local/share/java/abcl/abcl-contrib.jar!/jss/ to ASDF. Added jar:file:/opt/local/share/java/abcl/abcl-contrib.jar!/jfli/ to ASDF. Added jar:file:/opt/local/share/java/abcl/abcl-contrib.jar!/asdf-jar/ to ASDF. Added jar:file:/opt/local/share/java/abcl/abcl-contrib.jar!/abcl-asdf/ to ASDF. ("uiop" "UIOP" "LOOP" "asdf" "ASDF" "ABCL-CONTRIB") Cl-USER(2):
--
How did you install ABCL? There should be two jar files, 'abcl.jar' and 'abcl-contrib.jar' which should both be located in the same directory. At runtime, when satisfying the "(require :abcl-contrib)", ABCL introspects the classpath on which it is launched to probe for 'abcl-contrib.jar'
Maybe you are using a custom invocation script?
A few more details on how you have installed ABCL locally and how you are invoking it would be helpful (i.e. "I downloaded abcl-1.4.0-bin.zip; unzipped in a directory, and I invoke it with this command").
On Sat, May 13, 2017 at 4:21 PM Mark Evenson evenson@panix.com wrote:
On 5/12/17 15:36, Mirko Vukovic wrote: […]
I don't have jna.asd anywhere on my computer
It is packaged as part of `abcl-contrib.jar`.
[…]
snip ...
This indicates that for some reason your installation cannot locate abcl-contrib.jar.
Summary: abcl-contrib is fine, but there is an issue with Maven (even though mvn.bat is in path). Details below:
* Loading ABCL- CONTRIB:
Below is the output of my --no-init startup. I compared my output with yours, and I don't see anything substantially different. Loading abcl-contrib works fine. The ASDF version is 3.1.7.27.
c:\Users\977315\Documents\projects\software-development\workbooks\gswsql+abcl+cl-dbi>"C:\Windows\sysWOW64\java.exe" -cp "c:\mv-program-files\abcl-bin-1.4.0";"c:\mv-program-files\abcl-bin-1.4.0\abcl.jar" org.armedbear.lisp.Main --noinit Armed Bear Common Lisp 1.4.0 Java 1.7.0_51 Oracle Corporation Java HotSpot(TM) Client VM Low-level initialization completed in 0.279 seconds. Startup completed in 3.79 seconds. Type ":help" for a list of available commands. CL-USER(1): ; Loading C:/Users/977315/.emacs.d/elisp/slime/swank-loader.lisp ... ; Loaded C:/Users/977315/.emacs.d/elisp/slime/swank-loader.lisp (3.379 seconds) ;; Swank started at port: 60222. 60222 CL-USER(2): CL-USER(2): (require :abcl-contrib)
Using probed value of abcl-contrib: 'C:/mv-program-files/abcl-bin-1.4.0/abcl-contrib.jar'. Added jar:file:C:/mv-program-files/abcl-bin-1.4.0/abcl-contrib.jar!/quicklisp/ to ASDF. Added jar:file:C:/mv-program-files/abcl-bin-1.4.0/abcl-contrib.jar!/mvn/ to ASDF. Added jar:file:C:/mv-program-files/abcl-bin-1.4.0/abcl-contrib.jar!/jss/ to ASDF. Added jar:file:C:/mv-program-files/abcl-bin-1.4.0/abcl-contrib.jar!/jfli/ to ASDF. Added jar:file:C:/mv-program-files/abcl-bin-1.4.0/abcl-contrib.jar!/asdf-jar/ to ASDF. Added jar:file:C:/mv-program-files/abcl-bin-1.4.0/abcl-contrib.jar!/abcl-asdf/ to ASDF. ("uiop" "UIOP" "asdf" "ASDF" "ABCL-CONTRIB") CL-USER(3):
* Loading QUICKLISP, CFFI, leading to Maven error
Once I load quicklisp, I try loading CFFI, where I get
; Caught SIMPLE-WARNING: ; Unable to locate Maven executable to find Maven Aether adaptors.
mvn.bat is in my path. I can execute it from the Command shell. I really poorly understand Java setup, and its environment.
Also from within ABCL: (uiop/run-program:run-program '("where" "mvn.bat") :output :string) "C:\Program Files\apache-maven-3.3.9\bin\mvn.bat " NIL 0
A few more details on how you have installed ABCL locally and how you
are invoking it would be helpful (i.e. "I downloaded abcl-1.4.0-bin.zip; unzipped in a directory, and I invoke it with this command").
I don't recall how I installed it, although it was not straightforward. For example, I extracted the startup bat file from the online repository and formatted it so it would work.
-- "A screaming comes across the sky. It has happened before, but there is nothing to compare to it now."
On Wed, May 24, 2017 at 3:51 PM Mirko Vukovic mirko.vukovic@gmail.com wrote:
On Sat, May 13, 2017 at 4:21 PM Mark Evenson evenson@panix.com wrote:
On 5/12/17 15:36, Mirko Vukovic wrote: […]
I don't have jna.asd anywhere on my computer
It is packaged as part of `abcl-contrib.jar`.
[…]
snip ...
This indicates that for some reason your installation cannot locate abcl-contrib.jar.
Summary: abcl-contrib is fine, but there is an issue with Maven (even though mvn.bat is in path). Details below:
After (require :abcl-asdf), I invoke (abcl-asdf:find-mvn) TWICE. - First time, I get error about missing Maven executable - Second time, it finds Maven executable.
After that second time, CFFI loads cleanly.
Summary of steps to load CFFI from abcl --no-init: (require :abcl-contrib) (require :abcl-asdf) (abcl-asdf:find-mvn) ; issues warning about non-existant executable (abcl-asdf:find-mvn) ; returns mvn.bat path (load "~/quicklisp/setup.lisp") (ql:quickload :cffi) ; works
Mirko
On 5/24/17 22:19, Mirko Vukovic wrote:
On Wed, May 24, 2017 at 3:51 PM Mirko Vukovic mirko.vukovic@gmail.com wrote:
[…]
After (require :abcl-asdf), I invoke (abcl-asdf:find-mvn) TWICE.
- First time, I get error about missing Maven executable
- Second time, it finds Maven executable.
After that second time, CFFI loads cleanly.
Summary of steps to load CFFI from abcl --no-init: (require :abcl-contrib) (require :abcl-asdf) (abcl-asdf:find-mvn) ; issues warning about non-existant executable (abcl-asdf:find-mvn) ; returns mvn.bat path (load "~/quicklisp/setup.lisp") (ql:quickload :cffi) ; works
I'm not entirely sure why that works, but congratulations on getting something working! I don't develop under Windows, mainly from a lack of free licensing terms that don't have to be renewed every 90 days, so sometimes the state of functionality running ABCL under MSFT gets a little more divergent than I would like.
[The mechanism by which ABCL finds and executes Maven Aether][1] is being re-worked for abcl-1.5.0 to be more intelligent in providing restarts and diagnostics.
I will endeavor to test abcl-1.5.0-dev to make sure these new changes work better for finding Maven under Windows than is the current state with abcl-1.4.0.
[1]: https://gitlab.common-lisp.net/abcl/abcl/blob/master/contrib/abcl-build/buil...
On Thu, May 25, 2017 at 1:45 AM Mark Evenson evenson@panix.com wrote:
On 5/24/17 22:19, Mirko Vukovic wrote:
On Wed, May 24, 2017 at 3:51 PM Mirko Vukovic mirko.vukovic@gmail.com wrote:
[…]
After (require :abcl-asdf), I invoke (abcl-asdf:find-mvn) TWICE.
- First time, I get error about missing Maven executable
- Second time, it finds Maven executable.
After that second time, CFFI loads cleanly.
Summary of steps to load CFFI from abcl --no-init: (require :abcl-contrib) (require :abcl-asdf) (abcl-asdf:find-mvn) ; issues warning about non-existant executable (abcl-asdf:find-mvn) ; returns mvn.bat path (load "~/quicklisp/setup.lisp") (ql:quickload :cffi) ; works
I'm not entirely sure why that works, but congratulations on getting something working! I don't develop under Windows, mainly from a lack of free licensing terms that don't have to be renewed every 90 days, so sometimes the state of functionality running ABCL under MSFT gets a little more divergent than I would like.
[The mechanism by which ABCL finds and executes Maven Aether][1] is being re-worked for abcl-1.5.0 to be more intelligent in providing restarts and diagnostics.
I will endeavor to test abcl-1.5.0-dev to make sure these new changes work better for finding Maven under Windows than is the current state with abcl-1.4.0.
[1]:
https://gitlab.common-lisp.net/abcl/abcl/blob/master/contrib/abcl-build/buil...
Thanks for your work on this.
Mirko
armedbear-devel@common-lisp.net