Null pointer exception/reference error when trying to use clojurescript.test - emacs
I'm getting a NullPointerException when trying to use the clojurescript.test (https://github.com/cemerick/clojurescript.test) in a cider-REPL run with slimerJS.
cemerick.cljs.test.example> (ns cemerick.cljs.test.example
(:require-macros [cemerick.cljs.test
:refer (is deftest with-test run-tests testing test-var)])
(:require [cemerick.cljs.test :as t]))
java.lang.NullPointerException
nil
Alternatively, when I try to load part of the example test file (taken from https://github.com/cemerick/clojurescript.test) via emacs, cider, and austin, I get a "reference not found" error.
(ns cemerick.cljs.test.example
(:require-macros [cemerick.cljs.test
:refer (is deftest with-test run-tests testing test-var)])
(:require [cemerick.cljs.test :as t]))
(deftest javascript-allows-div0
(is (= js/Infinity (/ 1 0) (/ (int 1) (int 0)))))
Loading the above in with C-c, C-k yields the above:
"Error evaluating:" (deftest javascript-allows-div0 (is (= js/Infinity (/ 1 0) (/ (int 1) (int 0))))) :as "cemerick.cljs.test.example.javascript_allows_div0 = (function javascript_allows_div0(){\r\nreturn cemerick.cljs.test.test_function.call(null,cemerick.cljs.test.init_test_environment.call(null),cemerick.cljs.test.example.javascript_allows_div0);\r\n});\r\n\r\ncemerick.cljs.test.example.javascript_allows_div0 = cljs.core.with_meta.call(null,cemerick.cljs.test.example.javascript_allows_div0,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,\"end-column\",\"end-column\",1425389514),33,new cljs.core.Keyword(null,\"end-line\",\"end-line\",1837326455),9,new cljs.core.Keyword(null,\"column\",\"column\",2078222095),10,new cljs.core.Keyword(null,\"line\",\"line\",212345235),9,new cljs.core.Keyword(null,\"file\",\"file\",-1269645878),\"c:/Users/Vincent/hello-browser/test/hello_browser/example.cljs\"], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keywor
d(null,\"name\",\"name\",1843675177),cljs.core.with_meta.call(null,new cljs.core.Symbol(\"cemerick.cljs.test.example\",\"javascript-allows-div0\",\"cemerick.cljs.test.example/javascript-allows-div0\",254759648,null),new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,\"end-column\",\"end-column\",1425389514),33,new cljs.core.Keyword(null,\"end-line\",\"end-line\",1837326455),9,new cljs.core.Keyword(null,\"column\",\"column\",2078222095),10,new cljs.core.Keyword(null,\"line\",\"line\",212345235),9,new cljs.core.Keyword(null,\"file\",\"file\",-1269645878),\"c:/Users/Vincent/hello-browser/test/hello_browser/example.cljs\"], null)),new cljs.core.Keyword(null,\"test\",\"test\",577538877),(function javascript_allows_div0_test(test_ctx__15319__auto__){\r\nvar _test_ctx = test_ctx__15319__auto__;\r\nvar async_QMARK___15234__auto__ = new cljs.core.Keyword(null,\"async\",\"async\",1050769601).cljs$core$IFn$_invoke$arity$1(cljs.core.meta.call(null,new cljs.core.Keyword(null,\"test-name\",\"test-name\",
-675595913).cljs$core$IFn$_invoke$arity$1(_test_ctx)));\r\nvar _STAR_test_ctx_STAR_15568 = cemerick.cljs.test._STAR_test_ctx_STAR_;\r\ntry{cemerick.cljs.test._STAR_test_ctx_STAR_ = (cljs.core.truth_(async_QMARK___15234__auto__)?null:_test_ctx);\r\n\r\ntry{var _test_ctx__$1 = _test_ctx;\r\nvar async_QMARK___15234__auto____$1 = new cljs.core.Keyword(null,\"async\",\"async\",1050769601).cljs$core$IFn$_invoke$arity$1(cljs.core.meta.call(null,new cljs.core.Keyword(null,\"test-name\",\"test-name\",-675595913).cljs$core$IFn$_invoke$arity$1(_test_ctx__$1)));\r\nvar _STAR_test_ctx_STAR_15570 = cemerick.cljs.test._STAR_test_ctx_STAR_;\r\ntry{cemerick.cljs.test._STAR_test_ctx_STAR_ = (cljs.core.truth_(async_QMARK___15234__auto____$1)?null:_test_ctx__$1);\r\n\r\ntry{try{var values__15254__auto__ = cljs.core._conj.call(null,cljs.core._conj.call(null,cljs.core._conj.call(null,cljs.core.List.EMPTY,(((1) | (0)) / ((0) | (0)))),((1) / (0))),Infinity);\r\nvar result__15255__auto__ = cljs.core.apply.call(null,cljs.core._EQ_,val
ues__15254__auto__);\r\nif((result__15255__auto__ instanceof cemerick.cljs.test.TestContext)){\r\nthrow (new Error(\"TestContext provided as [form] in `is` assertion. If using `is` with an explicit test context, use the 3-arg arity.\"));\r\n} else {\r\n}\r\n\r\nif(cljs.core.truth_(result__15255__auto__)){\r\ncemerick.cljs.test.do_report.call(null,_test_ctx__$1,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,\"type\",\"type\",1174270348),new cljs.core.Keyword(null,\"pass\",\"pass\",1574159993),new cljs.core.Keyword(null,\"expected\",\"expected\",1583670997),cljs.core.list(new cljs.core.Symbol(null,\"=\",\"=\",-1501502141,null),new cljs.core.Symbol(\"js\",\"Infinity\",\"js/Infinity\",2039810812,null),cljs.core.list(new cljs.core.Symbol(null,\"/\",\"/\",-1371932971,null),(1),(0)),cljs.core.list(new cljs.core.Symbol(null,\"/\",\"/\",-1371932971,null),cljs.core.list(new cljs.core.Symbol(null,\"int\",\"int\",-100885395,null),(1)),cljs.core.list(new cljs.core.Symbol(null,\"int\",\"int\",-100885
395,null),(0)))),new cljs.core.Keyword(null,\"actual\",\"actual\",107306363),cljs.core.cons.call(null,cljs.core._EQ_,values__15254__auto__),new cljs.core.Keyword(null,\"message\",\"message\",-406056002),null], null));\r\n} else {\r\ncemerick.cljs.test.do_report.call(null,_test_ctx__$1,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,\"type\",\"type\",1174270348),new cljs.core.Keyword(null,\"fail\",\"fail\",1706214930),new cljs.core.Keyword(null,\"expected\",\"expected\",1583670997),cljs.core.list(new cljs.core.Symbol(null,\"=\",\"=\",-1501502141,null),new cljs.core.Symbol(\"js\",\"Infinity\",\"js/Infinity\",2039810812,null),cljs.core.list(new cljs.core.Symbol(null,\"/\",\"/\",-1371932971,null),(1),(0)),cljs.core.list(new cljs.core.Symbol(null,\"/\",\"/\",-1371932971,null),cljs.core.list(new cljs.core.Symbol(null,\"int\",\"int\",-100885395,null),(1)),cljs.core.list(new cljs.core.Symbol(null,\"int\",\"int\",-100885395,null),(0)))),new cljs.core.Keyword(null,\"actual\",\"actual\",107306363),
cljs.core._conj.call(null,cljs.core._conj.call(null,cljs.core.List.EMPTY,cljs.core.cons.call(null,new cljs.core.Symbol(null,\"=\",\"=\",-1501502141,null),values__15254__auto__)),new cljs.core.Symbol(null,\"not\",\"not\",1044554643,null)),new cljs.core.Keyword(null,\"message\",\"message\",-406056002),null], null));\r\n}\r\n\r\nreturn result__15255__auto__;\r\n}catch (e15572){if((e15572 instanceof Error)){\r\nvar t__15291__auto__ = e15572;\r\nreturn cemerick.cljs.test.do_report.call(null,_test_ctx__$1,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,\"type\",\"type\",1174270348),new cljs.core.Keyword(null,\"error\",\"error\",-978969032),new cljs.core.Keyword(null,\"expected\",\"expected\",1583670997),cljs.core.list(new cljs.core.Symbol(null,\"=\",\"=\",-1501502141,null),new cljs.core.Symbol(\"js\",\"Infinity\",\"js/Infinity\",2039810812,null),cljs.core.list(new cljs.core.Symbol(null,\"/\",\"/\",-1371932971,null),(1),(0)),cljs.core.list(new cljs.core.Symbol(null,\"/\",\"/\",-1371932971,null)
,cljs.core.list(new cljs.core.Symbol(null,\"int\",\"int\",-100885395,null),(1)),cljs.core.list(new cljs.core.Symbol(null,\"int\",\"int\",-100885395,null),(0)))),new cljs.core.Keyword(null,\"actual\",\"actual\",107306363),t__15291__auto__,new cljs.core.Keyword(null,\"message\",\"message\",-406056002),null], null));\r\n} else {\r\nthrow e15572;\r\n\r\n}\r\n}}catch (e15571){if((e15571 instanceof Error)){\r\nvar e__15235__auto__ = e15571;\r\nif(cljs.core.truth_(async_QMARK___15234__auto____$1)){\r\nreturn cemerick.cljs.test.done_STAR_.call(null,_test_ctx__$1,e__15235__auto__);\r\n} else {\r\nthrow e__15235__auto__;\r\n}\r\n} else {\r\nthrow e15571;\r\n\r\n}\r\n}}finally {cemerick.cljs.test._STAR_test_ctx_STAR_ = _STAR_test_ctx_STAR_15570;\r\n}}catch (e15569){if((e15569 instanceof Error)){\r\nvar e__15235__auto__ = e15569;\r\nif(cljs.core.truth_(async_QMARK___15234__auto__)){\r\nreturn cemerick.cljs.test.done_STAR_.call(null,_test_ctx,e__15235__auto__);\r\n} else {\r\nthrow e__15235__auto__;\r\n}\r\n} else {\r\nth
row e15569;\r\n\r\n}\r\n}}finally {cemerick.cljs.test._STAR_test_ctx_STAR_ = _STAR_test_ctx_STAR_15568;\r\n}})], null)));\r\n\r\ncemerick.cljs.test.register_test_BANG_.call(null,new cljs.core.Symbol(null,\"cemerick.cljs.test.example\",\"cemerick.cljs.test.example\",-1897716079,null),new cljs.core.Symbol(\"cemerick.cljs.test.example\",\"javascript-allows-div0\",\"cemerick.cljs.test.example/javascript-allows-div0\",254759648,null),cemerick.cljs.test.example.javascript_allows_div0);\r\n\r\n"
#<ReferenceError: cemerick is not defined>
#http://localhost:52963/2397/repl/start line 1944 > eval:1:1
clojure.browser.repl.evaluate_javascript/c<#http://localhost:52963/2397/repl/start:1944:313
clojure.browser.repl.evaluate_javascript#http://localhost:52963/2397/repl/start:1944:62
clojure.browser.repl.connect/<#http://localhost:52963/2397/repl/start:1953:1
goog.messaging.AbstractChannel.prototype.deliver#http://localhost:52963/2397/repl/start:1761:268
goog.net.xpc.CrossPageChannel.prototype.xpcDeliver#http://localhost:52963/2397/repl/start:1914:354
goog.net.xpc.NativeMessagingTransport.messageReceived_#http://localhost:52963/2397/repl/start:1870:396
goog.events.fireListener#http://localhost:52963/2397/repl/start:1454:124
goog.events.handleBrowserEvent_#http://localhost:52963/2397/repl/start:1457:174
goog.events.getProxy/b<#http://localhost:52963/2397/repl/start:1446:395
My project.clj file is as follows:
(defproject hello-browser "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2665"]]
:plugins [[lein-cljsbuild "1.0.4"]
[cider/cider-nrepl "0.9.0-SNAPSHOT" ]
[com.cemerick/clojurescript.test "0.3.3"]]
:source-paths ["src" "src/cljs"]
:test-paths ["test" "test/hello_browser"]
:cljsbuild { :builds [{:source-paths ["src/cljs"]
:compiler {:output-to "resources/public/core.js"}}]}
:profiles {:dev {:plugins [[com.cemerick/austin "0.1.6"]]}})
What am I doing incorrectly?
Updating the clojurescript version seemed to fix my issues. So after changing
[org.clojure/clojurescript "0.0-2665"]
to
[org.clojure/clojurescript "0.0-2740"]
After loading the test file above into the REPL with C-c, C-k,
(cemerick.cljs.test/test-ns 'cemerick.cljs.test.example)
produced the expected output of
{:test 1, :pass 1, :fail 0, :error 0}
Related
How to pass the variable name as a string to a function? (ClojureScript)
Description of the situation I want to make a form template for an element, but they must be dynamically created. The meta data involved in the Component should use the variable-name passed as it's meta-data. Code For example, In the view, (ns my.app (:require [my.app.templating :as template]) (defn view-component [nOperacaoExtrato] [:<> (template/temp-form nOperacaoExtrato)]) The templating function, (ns my.app.templating) (defn temp-form "Template input" [dado] #_(js/console.log (str "meta-data: " (meta #'dado))) (let [nome-var (:name (meta #'dado))] [:div.col [:label {:for (str "form1_" nome-var)} "Natureza do Dispendio"] [:p {:class "form-control", :id (str "form1_" nome-var) :name (str "form1" nome-var)} dado]])) The result should be, something like this (because the variable passed is nOperacaoExtrato): [:div.col [:label {:for "form1_re-fin-n-operacao-extrato-prop"} "Nº da Operação no Extrato"] [:p {:class "form-control", :id "form1_re-fin-n-operacao-extrato-prop", :name "form1_re-fin-n-operacao-extrato-prop"} (h/preencher-str nOperacaoExtrato)]] The issue: Both of these return null. (meta #'data) (meta data) ``
You should probably convert this function to a macro. Let me show you fellow Portuguese speaker: src/cljs/user.cljc (ns cljs.user) (defn temp-form-fn "Template input" [dado nome-var] [:div.col [:label {:for (str "form1_" nome-var)} "Natureza do Dispendio"] [:p {:class "form-control", :id (str "form1_" nome-var) :name (str "form1" nome-var)} dado]]) #? (:clj (defmacro temp-form [dado] `(temp-form-fn ~dado ~(name dado)))) Then in the repl: cljs.user> (require '[cljs.user :refer-macros [temp-form]]) nil cljs.user> (let [nOperacaoExtrato 1234] (temp-form nOperacaoExtrato)) [:div.col [:label {:for "form1_nOperacaoExtrato"} "Natureza do Dispendio"] [:p {:class "form-control", :id "form1_nOperacaoExtrato", :name "form1nOperacaoExtrato"} 1234]]
clojure.data.xml and parsing jdbc xml object
I'm attempting to read xml (actual xml type) from a postgres database in clojure, however i'm not sure how to cast the org.postgresql.jdbc4.Jdbc4SQLXML object to something clojure.data.xml can make sense of. When running (xml/parse ...) on this object i'm getting the following error: IllegalArgumentException No matching method found: createXMLStreamReader for class com.sun.xml.internal.stream.XMLInputFactoryImpl clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80) code below: (ns clj-xml-dbms.core-test (:require [clojure.test :refer :all] [clojure.java.jdbc :as j] [clojure.data.xml :as xml] [clj-xml-dbms.core :refer :all]) (:use [clojure.pprint ] )) (def db-spec { :classname "org.postgres.Driver" :subprotocol "postgres" :subname "//localhost:5432/mydb" :user "me" :password "secret" }) ;; get the results of a query (def results (let [ sql "select row_id, xml_col from stg.some_table limit 1 " db-connection (j/get-connection db-spec ) statement (j/prepare-statement db-connection sql) query-results (j/query db-connection [statement]) ] (first query-results))) (pprint results) ;; {:row_id 18627, ;; :xml_col #object[org.postgresql.jdbc4.Jdbc4SQLXML 0x6897f635 "org.postgresql.jdbc4.Jdbc4SQLXML#6897f635"]} ;; obviously clojure.data.xml/parse isn't going to work on that: (xml/parse (:xml_col results)) ;; IllegalArgumentException No matching method found: createXMLStreamReader for class com.sun.xml.internal.stream.XMLInputFactoryImpl clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80) I guess i could cast the xml type in the db to a string, but there has to be something cleaner that that i would think. Any tips appreciated, thanks.
Emacs: how to stop jedi?
I regularly use jedi.el, it works great. But I don't know how to stop it ! I manually call it with jedi:setup (which turns jedi-mode on) and try to stop it with jedi-mode but it has no effect. It is unconvenient and it gets in the way with yasnippet. Do you have a solution ? Thanks. config: emacs24 and latest jedi.el version from melpa. Result of jedi:show-setup-info: ;; Emacs Lisp version: (:emacs-version "24.3.1" :jedi-version "0.2.0alpha2" :python-environment-version "0.0.2alpha0") ;; Python version: ((:version "2.7.3 (default, Feb 27 2014, 19:58:35) \n[GCC 4.6.3]" :name "sys" :file nil) (:version "0.7.0" :name "jedi" :file "/usr/local/lib/python2.7/dist-packages/jedi/__init__.pyc") (:version "0.0.5" :name "epc" :file "/usr/local/lib/python2.7/dist-packages/epc/__init__.pyc") (:version "0.0.3" :name "sexpdata" :file "/usr/local/lib/python2.7/dist-packages/sexpdata.pyc")) ;; Command line: (:virtualenv "/usr/bin/virtualenv" :virtualenv-version "1.7.1.2\n") ;; Customization: ((jedi:complete-on-dot) (jedi:doc-display-buffer . display-buffer) (jedi:doc-hook view-mode) (jedi:doc-mode . rst-mode) (jedi:environment-root) (jedi:environment-virtualenv) (jedi:get-in-function-call-delay . 1000) (jedi:get-in-function-call-timeout . 3000) (jedi:goto-definition-config (nil nil nil) (t nil nil) (nil definition nil) (t definition nil) (nil nil t) (t nil t) (nil definition t) (t definition t)) (jedi:goto-definition-marker-ring-length . 16) (jedi:imenu-create-index-function . jedi:create-nested-imenu-index) (jedi:import-python-el-settings . t) (jedi:install-imenu) (jedi:install-python-jedi-dev-command "pip" "install" "--upgrade" "git+https://github.com/davidhalter/jedi.git#dev#egg=jedi") (jedi:key-complete . [C-tab]) (jedi:key-goto-definition . [67108910]) (jedi:key-goto-definition-pop-marker . [67108908]) (jedi:key-related-names . "r") (jedi:key-show-doc . "d") (jedi:server-args) (jedi:server-command "python" "/home/vdardelx/.emacs.d/elpa/jedi-20140321.1323/jediepcserver.py") (jedi:setup-keys) (jedi:tooltip-method pos-tip popup) (jedi:use-shortcuts) (python-environment-default-root-name . "default") (python-environment-directory . "~/.emacs.d/.python-environments") (python-environment-virtualenv "virtualenv" "--system-site-packages" "--quiet"))
What aspect is conflicting with yasnippet? Is it the use of autocomplete-mode? (which seems to be the other broad consequence of running jedi:setup, and which isn't turned off again when jedi-mode is disabled.) M-x autocomplete-mode will toggle that off again, or call (autocomplete-mode -1) in code. You could write a function to disable both modes together, and call that to turn jedi off. A more robust approach would remember the state of autocomplete-mode at the time jedi was enabled in order to restore it afterwards, but it sounds like that's not critical in your case.
Receiving data through LISP USOCKET
I'm trying to send data over USOCKET. When the data reaches the server, the server should reply back. However, stream-read (as defined below) only returns the data when it's echoed back with the original data it sent. For example, if I send hello and the server replies with the same data, hello, then stream-read returns, but if the server replies with hi, stream-read doesn't return until the server sends the exact buffer it received. Here's the code: (I've found most of it online.) ;; Load USocket (load #P"/usr/share/common-lisp/source/cl-asdf/asdf.lisp") (asdf:operate 'asdf:load-op :usocket) (defun stream-read (stream) (socket-listen (usocket:socket-stream stream))) (defun stream-print (string stream) (write-line string (usocket:socket-stream stream)) (force-output (usocket:socket-stream stream))) ;; Define a stream (defparameter my-stream (usocket:socket-connect "127.0.0.1" 6003)) ;; Use the stream (stream-print "random" my-stream) (print (stream-read my-stream)) As for the server, I'm using a slightly modified version of the boost blocking server example. (c++) The full code can be found here: http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/example/echo/blocking_tcp_echo_server.cpp ... void session(socket_ptr sock) { try { for (;;) { char data[max_length]; boost::system::error_code error; size_t length = sock->read_some(boost::asio::buffer(data), error); if (error == boost::asio::error::eof) break; // Connection closed cleanly by peer. else if (error) throw boost::system::system_error(error); // Some other error. std::vector<char> v(data,data+length); std::string theStr; for(unsigned int i=0;i<v.size();i++) { if(v[i]<32 || v[i]>=0x7f);//Remove non-ascii char else theStr.insert(theStr.end(),v[i]); } std::cout<<"|"<<theStr<<"|"<<std::endl; boost::asio::write(*sock, boost::asio::buffer(data, length)); //works boost::asio::write(*sock, boost::asio::buffer("some", 4)); //doesn't work } } catch (std::exception& e) { std::cerr << "Exception in thread: " << e.what() << "\n"; } } ...
Without seeing the code for your server it's hard to answer without a bit of speculation. But: You use the same socket for each call from the client to the server. If the server isn't expecting that, it won't behave as you want it to. Your definition of stream-read calls socket-listen. Did you mean usocket:socket-listen? This is a server-side function (and takes different arguments). I'm probably not looking at the exact code you were running. Advisory notes: (a) my-stream is actually a socket, not a stream; (b) I encourage you to manage external libraries using Quicklisp. Here's a full working example. This is on LispWorks; I've used LW internals for the server to make it utterly clear which is server and which is client. CL-USER 1 > (ql:quickload :usocket) To load "usocket": Load 1 ASDF system: usocket ; Loading "usocket" (:USOCKET) CL-USER 2 > (comm:start-up-server :service 6003 :function (lambda (handle) (let* ((stream (make-instance 'comm:socket-stream :socket handle :direction :io :element-type 'base-char)) (line (read-line stream))) (format stream "Hello: ~a~%" line) (force-output stream)))) #<MP:PROCESS Name "6003 server" Priority 85000000 State "Running"> CL-USER 3 > (defun socket-read (socket) (read-line (usocket:socket-stream socket))) SOCKET-READ CL-USER 4 > (defun socket-print (string socket) (write-line string (usocket:socket-stream socket)) (force-output (usocket:socket-stream socket))) SOCKET-PRINT CL-USER 5 > (defun test (thing) (let ((socket (usocket:socket-connect "127.0.0.1" 6003))) (socket-print thing socket) (socket-read socket))) TEST CL-USER 6 > (test "Buttered toast") "Hello: Buttered toast" NIL CL-USER 7 > (test "A nice cup of tea") "Hello: A nice cup of tea" NIL If you're still having difficulties, post again with source for your server and your actual stream-read.
Pass a vector/inputstream to a clojure function via java/scala
I need to call a clojure-function from java/scala which expects a vector or an inputstream as its first argument. Doing so always yields the following exception: Execution exception[[UnsupportedOperationException: pdf (clj-pdf.main/-pdf not defined?)]] I am using clj-pdf and need to call the pdf-function (defn pdf "usage: in can be either a vector containing the document or an input stream. If in is an input stream then the forms will be read sequentially from it. out can be either a string, in which case it's treated as a file name, or an output stream. NOTE: using the :pages option will cause the complete document to reside in memory as it will need to be post processed." [in out] (if (instance? InputStream in) (stream-doc in out) (write-doc in out))) I have modified the source, built a jar via leiningen uberjar The modifications to cjl-pdf's project.clj can be seen in the last 2 lines: (defproject clj-pdf "1.0.6" :description "PDF generation library" :url "https://github.com/yogthos/clj-pdf" :license {:name "GNU Lesser General Public License - v 3" :url "http://www.gnu.org/licenses/lgpl.html" :distribution :repo :comments "same as iText and JFreeChart"} :dependencies [[org.clojure/clojure "1.5.0"] [jfree/jfreechart "1.0.13"] [itext-min "0.2"]] :aot [clj-pdf.main] :main clj-pdf.main) and in my added main.clj: (ns clj-pdf.main (:gen-class ;; neither java.io.InputStream nor ArrayList work: :methods [#^{:static true} [pdf [java.util.ArrayList, java.io.OutputStream] void]]) (:use clj-pdf.core)) (defn -main [& args]) I am using the lib from my scala code as follows: val output = new ByteArrayOutputStream() val list = new java.util.ArrayList[String] list.add( """[:list {:roman true} [:chunk {:style :bold} "a bold item"] "another item" "yet another item"] [:phrase "some text"] [:paragraph "yet more text"]]""") clj_pdf.main.pdf(list, output) Is there any way to get around this?
It works from Java: java.util.ArrayList a = new java.util.ArrayList(); java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream(); clj_pdf.main.pdf (a, b); if I add to main.clj: (defn -pdf [in out] (pdf in out)) And use the lein uberjar to build the project. Another alternative is to use the clojure.lang.RT as per https://stackoverflow.com/a/6410926/151650