Description
While this is an issue it's also a document on how to get it done if one really has to.
I have a "project" which has in excess of 150 jars (don't ask) that have to be in its classpath for it to run. Originally written as a standalone application for the command line it works well using -cp lib/*
however that cannot be used with nginx-clojure.
As a workaround I tried using jvm_var and jvm_options as follows:
jvm_var lib "/path/to/library";
jvm_var jar0 "#{lib}xstream-1.4.4.jar:#{lib}activemq-stomp.jar:#{lib}activemq-broker.jar:#{lib}jms.jar";
...
jvm_var jar17 "#{lib}gson.jar:#{lib}diffutils.jar:#{lib}jdom.jar:#{lib}batik-svggen.jar:#{lib}batik-dom.jar:#{lib}batik-script.jar:#{lib}batik-parser.jar:#{lib}batik-swing.jar";
jvm_options "-Djava.class.path=#{jar0}:#{jar1}:#{jar2}:#{jar3}:#{jar4}:#{jar5}:#{jar6}:#{jar7}:#{jar8}:#{jar9}:#{jar10}:#{jar11}:#{jar12}:#{jar13}:#{jar14}:#{jar15}:#{jar16}:#{jar17}:#{jar18}";
The reason for having to split jvm_var on several lines and using variable expansion is nginx's builtin parser which has a maximum line length which got exceeded quickly. It also turns out that -cp
and -Djava.class.path
are not the same thing at all. Magically some of the jars will silently not load for one or another reason and the errors were always related to missing classes.
The only way I could figure to get the whole thing to work was to create a jar which contains a META-INF/MANIFEST.MF
with the following contents:
Premain-Class: nginx.clojure.wave.JavaAgent
Main-Class: clojure.main
/path/to/1st.jar
/path/to/2nd.jar
/path/to/150th.jar