-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lein uberjar does not handle signed dependency jars correctly #31
Comments
diff --git a/src/leiningen/uberjar.clj b/src/leiningen/uberjar.clj index 67ebcc1..2e9b2cd 100644 --- a/src/leiningen/uberjar.clj +++ b/src/leiningen/uberjar.clj @@ -53,7 +53,7 @@ may wish to clean first." (filter #(.endsWith (.getName %) ".jar")) (cons (file (:root project) (str (:name project) ".jar")))) [_ components] (reduce (partial include-dep out) - [#{"META-INF/plexus/components.xml"} nil] + [#{"META-INF/plexus/components.xml" "META-INF/DUMMY.SF"} nil] deps)] (when-not (empty? components) (.putNextEntry out (ZipEntry. "META-INF/plexus/components.xml")) |
I'm planning to look into this soonish, though I won't promise to be particularly fast (since I'm not entirely sure what's involved). Should anyone plan on beating me to it, please let me know. :-) |
In the mean time it's good to have following command at hand: |
Thanks for the tip! |
Is removing META-INF/DUMMY.SF the correct solution for all signed jars, or just for janino? |
No idea. It was the first and only time I encountered the issue and found this file by binary search with trial and error (removing half remaining files at a time). |
According to an older thread on the mailing list sometimes it has another name. If there's a regex that can always catch it then we can make :jar-exclusions default to that regex. |
This issue occurred for me as well with the SQL Server jdbc driver. I used @ogrisel's It would be nice if this issue was re-opened and fixed |
Is it safe to always exclude META-INF/DUMMY.SF from uberjars? I can do this (in a way that's easy to override) if it's appropriate. |
I don't know about that. I actually had to remove zigbert.sf from the standalone.jar, so I believe it's specific to which .jars have the security signature file. So I ran |
So do you have a solution to propose? Right now it's already easy enough to just add :uberjar-exclusions [#"zigbert.sf"] to project.clj as the need arises. I don't see a general-purpose fix being possible if the name of the file at fault varies. |
I'm very sorry that I missed that in the conversation above. I just tried it and it worked great. Thanks! |
[gnu.getopt/java-getopt "1.0.13"] has the same problem, but with TESTKEY.SF. I think any SF is going to be a problem. |
Failing testcase:project.clj
src/clj/core.clj
ExplanationJars may be signed with multiple signature files, which take the form of #"^META-INF/[a-zA-Z0-9_-]*.SF$" and corresponding .DSA and .RSA key files. The main problem is that the signature file appears to sign the MANIFEST.MF, which Leiningen overwrites:
http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/jarsigner.html PatchForthcoming as pull request. |
… meta-inf. Also make case-insensitive and anchor the end.
I'm having problems with this too. |
sneilan: I've submitted a patch, but until a fix is released, I'm using this in my project.clj:
|
Patch for reopened #31 (third time's the charm)
Looks like this is taken care of. |
It works!! Thank you! |
I found one more issue. If I include mmemail as a dependency and run the standalone jar: Exception in thread "main" java.lang.SecurityException: no manifiest section for signature file entry javax/activation/MimeType.class This is because the lines that look like I add those lines in and it works just fine. This is with leiningen 1.6.2 |
Or, if I get rid of the SHA1-Digest lines from the MANIFEST.MF in the mmemail jar, it also works! (I also got rid of the two SUN....RSA whatever files.) This makes everything better again :) |
I'm not sure what this means. Is there more that uberjar should be doing? |
This issue still exists in Lein2, haven't tried yet with Master.
|
With what lein2 version? Lein2 Preview 4 was released less than 24 hours ago. |
Checked on preview4 just now. Issue is reproducible. |
I just made an uberjar containing Jetty with preview4, so if this is still happening I will need some more details to reproduce the problem. |
I will check out, maybe it was some other dependency. Will come back with small repro repo or good news. alex p Am 12.05.2012 um 23:06 schrieb Phil [email protected]:
|
Actually, it was jetty-server. Here's the repository where the bug reproduces: https://github.com/ifesdjeen/lein-manifest-bug-reproduce/blob/master/project.clj#L4 It may be actually not a Leningen bug, I understand that. If you could give me a hint what that could be, i'll dig & talk to Ring guys, maybe, as they're using it https://github.com/mmcgrana/ring/blob/master/project.clj#L7 On the side note, I tried also the forementioned java-getopt, and issue reproduced: [gnu.getopt/java-getopt "1.0.13"] That also causes the issue: [org.eclipse.jetty/jetty-server "7.6.1.v20120215"] Proof I have correct lein :)
And the command I run:
And output:
Thank you! |
Looks like the regex here just got goofed in 2.x. |
This problem occurs with Jetty (via ring) as well, because Jetty recently moved to the Eclipse Foundation and they are now signing the JAR files. Here is a minimal test-case to reproduce - ;; project.clj
(defproject leintest "0.1.0-SNAPSHOT"
:description "FIXME: write description"
;; this fixes the problem
;; :uberjar-exclusions [#"(?i)^META-INF/[^/]*\.(SF|RSA)$"]
:dependencies [[org.clojure/clojure "1.4.0"]
;; bringing in [ring/ring-jetty-adapter "1.1.0"] works as well
[org.eclipse.jetty/jetty-server "8.1.4.v20120524"]]
:main leintest.core)
;; src/leintest/core.clj
(ns leintest.core
(:gen-class)
(:import org.eclipse.jetty.server.Server))
(defn -main
[& args]
(println "Hello, world!")) I have issued a pull request that augments the previous regexp to exclude .RSA files as well. We might need to keep changing the regexp in the future as and when we discover more file-types. |
Here is my solution! The main idea is to put all dependecies into ./lib folder |
If one of the dependencies is signed, creating a standalone jar with "lein uberjar" yields the following exception when executing the main class of the project:
In my case the inclusion of a "META-INF/DUMMY.SF" file from one of the depedency (janino-2.5.15.jar) is the root of the problem. Patching leiningen as follows in the attahed patch fixes the problem (however this is probably not the right way to fix it).
The text was updated successfully, but these errors were encountered: