3

I'm building a Java app that loads Clojure files. I'm having trouble making a single executable jar. I'm using One-Jar, but I get an exception when I try to run the jar file:

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at com.simontuffs.onejar.Boot.run(Boot.java:340)
    at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.ExceptionInInitializerError
    at com.ziroby.clojure.App.main(App.java:14)
    ... 6 more
Caused by: java.lang.NullPointerException
    at clojure.lang.RT.lastModified(RT.java:374)
    at clojure.lang.RT.load(RT.java:408)
    at clojure.lang.RT.load(RT.java:398)
    at clojure.lang.RT.doInit(RT.java:434)
    at clojure.lang.RT.<clinit>(RT.java:316)
... 7 more

When I look at the line that's causing it, it seems to be trying to get jar information for the relative class files:

    return ((JarURLConnection) url.openConnection()).getJarFile()
           .getEntry(libfile).getTime();

I think this means that it's trying to get jar information for an embedded jar, which doesn't actually exist on the file system. It's looking at that to see if it needs to recompile a file (like common/core.clj).

Am I doing something wrong? Is there some other way to create an executable jar (with dependencies) without confusing Clojure?

1
  • Wow! I can see at least 5 things that might fail in that single code statement. Is it your code, or another API? BTW the usual solution (as opposed to one-jar) is to either deploy all the Jars using JWS, or add a manifest that refers to the dependent Jars by relative references, then package them up in an installer of some form. Commented Oct 14, 2011 at 5:59

1 Answer 1

2

I have come to the conclusion that this is a bug in Clojure. I am able to add a single null check (just before the .getTime() call), and it works correctly. I've entered a bug in Clojure's Jira: http://dev.clojure.org/jira/browse/CLJ-971

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.