Skip to content
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

jgit jar mystery NoClassDefFoundError #408

Closed
maxandersen opened this issue Oct 8, 2020 · 3 comments
Closed

jgit jar mystery NoClassDefFoundError #408

maxandersen opened this issue Oct 8, 2020 · 3 comments

Comments

@maxandersen
Copy link
Collaborator

I can't explain this one so recording it for posperity:

this fails:
jbang org.eclipse.jgit:org.eclipse.jgit.pgm:5.9.0.202009080501-r

but doing this works:

///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.eclipse.jgit:org.eclipse.jgit.pgm:5.9.0.202009080501-r

import static java.lang.System.*;

public class jgit {

    public static void main(String... args) throws Exception {

        try {
            org.eclipse.jgit.pgm.Main.main(args);
        } catch(Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
}
$ jbang jgit

that should technically work the exact same....

When run with verbose you see the only difference is that the first one launch via --jar where as second one is with main class specified.

but otherwise exact same classpath.

I tried removing the duplicate presence of pgm.jgit jar but gave same result.

@maxandersen
Copy link
Collaborator Author

The output from jbang incl. full command line:

 jbang --verbose org.eclipse.jgit:org.eclipse.jgit.pgm:5.9.0.202009080501-r
[jbang] Resolving dependencies...
[jbang]     Resolving org.eclipse.jgit:org.eclipse.jgit.pgm:5.9.0.202009080501-r...Done
[jbang] Dependencies resolved
[jbang] System Java version detected as 11
[jbang] System Java version matches requested version 11
[jbang] run: /Users/max/.sdkman/candidates/java/current/bin/java -classpath /Users/max/.m2/repository/args4j/args4j/2.33/args4j-2.33.jar:/Users/max/.m2/repository/org/apache/commons/commons-compress/1.19/commons-compress-1.19.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.archive/5.9.0.202009080501-r/org.eclipse.jgit.archive-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/osgi/org.osgi.core/4.3.1/org.osgi.core-4.3.1.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit/5.9.0.202009080501-r/org.eclipse.jgit-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/com/googlecode/javaewah/JavaEWAH/1.1.7/JavaEWAH-1.1.7.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.ui/5.9.0.202009080501-r/org.eclipse.jgit.ui-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.gpg.bc/5.9.0.202009080501-r/org.eclipse.jgit.gpg.bc-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/bouncycastle/bcpg-jdk15on/1.65/bcpg-jdk15on-1.65.jar:/Users/max/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.65.01/bcprov-jdk15on-1.65.01.jar:/Users/max/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.65/bcpkix-jdk15on-1.65.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.http.apache/5.9.0.202009080501-r/org.eclipse.jgit.http.apache-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/apache/httpcomponents/httpcore/4.4.12/httpcore-4.4.12.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.ssh.apache/5.9.0.202009080501-r/org.eclipse.jgit.ssh.apache-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/apache/sshd/sshd-osgi/2.4.0/sshd-osgi-2.4.0.jar:/Users/max/.m2/repository/org/apache/sshd/sshd-sftp/2.4.0/sshd-sftp-2.4.0.jar:/Users/max/.m2/repository/org/apache/sshd/sshd-core/2.4.0/sshd-core-2.4.0.jar:/Users/max/.m2/repository/org/apache/sshd/sshd-common/2.4.0/sshd-common-2.4.0.jar:/Users/max/.m2/repository/net/i2p/crypto/eddsa/0.3.0/eddsa-0.3.0.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.ssh.jsch/5.9.0.202009080501-r/org.eclipse.jgit.ssh.jsch-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/com/jcraft/jsch/0.1.55/jsch-0.1.55.jar:/Users/max/.m2/repository/com/jcraft/jzlib/1.1.1/jzlib-1.1.1.jar:/Users/max/.m2/repository/org/apache/httpcomponents/httpclient/4.5.10/httpclient-4.5.10.jar:/Users/max/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/max/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar:/Users/max/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar:/Users/max/.m2/repository/org/slf4j/slf4j-log4j12/1.7.2/slf4j-log4j12-1.7.2.jar:/Users/max/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.30.v20200611/jetty-servlet-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-security/9.4.30.v20200611/jetty-security-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-server/9.4.30.v20200611/jetty-server-9.4.30.v20200611.jar:/Users/max/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-http/9.4.30.v20200611/jetty-http-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-util/9.4.30.v20200611/jetty-util-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-io/9.4.30.v20200611/jetty-io-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.lfs/5.9.0.202009080501-r/org.eclipse.jgit.lfs-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/com/google/code/gson/gson/2.8.2/gson-2.8.2.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.lfs.server/5.9.0.202009080501-r/org.eclipse.jgit.lfs.server-5.9.0.202009080501-r.jar -jar /Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.pgm/5.9.0.202009080501-r/org.eclipse.jgit.pgm-5.9.0.202009080501-r.jar
Error: Unable to initialize main class org.eclipse.jgit.pgm.Main
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jgit/transport/http/HttpConnectionFactory
jbang --verbose jgit.java
[jbang] System Java version detected as 11
[jbang] System Java version matches requested version 11
[jbang] run: /Users/max/.sdkman/candidates/java/current/bin/java -classpath /Users/max/.jbang/cache/jars/jgit.java.061d3c9c950bc38a317143e90b806c87ac95de7e7c01fd0ff16633385698cd32.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.pgm/5.9.0.202009080501-r/org.eclipse.jgit.pgm-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/args4j/args4j/2.33/args4j-2.33.jar:/Users/max/.m2/repository/org/apache/commons/commons-compress/1.19/commons-compress-1.19.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.archive/5.9.0.202009080501-r/org.eclipse.jgit.archive-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/osgi/org.osgi.core/4.3.1/org.osgi.core-4.3.1.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit/5.9.0.202009080501-r/org.eclipse.jgit-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/com/googlecode/javaewah/JavaEWAH/1.1.7/JavaEWAH-1.1.7.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.ui/5.9.0.202009080501-r/org.eclipse.jgit.ui-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.gpg.bc/5.9.0.202009080501-r/org.eclipse.jgit.gpg.bc-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/bouncycastle/bcpg-jdk15on/1.65/bcpg-jdk15on-1.65.jar:/Users/max/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.65.01/bcprov-jdk15on-1.65.01.jar:/Users/max/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.65/bcpkix-jdk15on-1.65.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.http.apache/5.9.0.202009080501-r/org.eclipse.jgit.http.apache-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/apache/httpcomponents/httpcore/4.4.12/httpcore-4.4.12.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.ssh.apache/5.9.0.202009080501-r/org.eclipse.jgit.ssh.apache-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/org/apache/sshd/sshd-osgi/2.4.0/sshd-osgi-2.4.0.jar:/Users/max/.m2/repository/org/apache/sshd/sshd-sftp/2.4.0/sshd-sftp-2.4.0.jar:/Users/max/.m2/repository/org/apache/sshd/sshd-core/2.4.0/sshd-core-2.4.0.jar:/Users/max/.m2/repository/org/apache/sshd/sshd-common/2.4.0/sshd-common-2.4.0.jar:/Users/max/.m2/repository/net/i2p/crypto/eddsa/0.3.0/eddsa-0.3.0.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.ssh.jsch/5.9.0.202009080501-r/org.eclipse.jgit.ssh.jsch-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/com/jcraft/jsch/0.1.55/jsch-0.1.55.jar:/Users/max/.m2/repository/com/jcraft/jzlib/1.1.1/jzlib-1.1.1.jar:/Users/max/.m2/repository/org/apache/httpcomponents/httpclient/4.5.10/httpclient-4.5.10.jar:/Users/max/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/max/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar:/Users/max/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar:/Users/max/.m2/repository/org/slf4j/slf4j-log4j12/1.7.2/slf4j-log4j12-1.7.2.jar:/Users/max/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-servlet/9.4.30.v20200611/jetty-servlet-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-security/9.4.30.v20200611/jetty-security-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-server/9.4.30.v20200611/jetty-server-9.4.30.v20200611.jar:/Users/max/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-http/9.4.30.v20200611/jetty-http-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-util/9.4.30.v20200611/jetty-util-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jetty/jetty-io/9.4.30.v20200611/jetty-io-9.4.30.v20200611.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.lfs/5.9.0.202009080501-r/org.eclipse.jgit.lfs-5.9.0.202009080501-r.jar:/Users/max/.m2/repository/com/google/code/gson/gson/2.8.2/gson-2.8.2.jar:/Users/max/.m2/repository/org/eclipse/jgit/org.eclipse.jgit.lfs.server/5.9.0.202009080501-r/org.eclipse.jgit.lfs.server-5.9.0.202009080501-r.jar jgit
jgit --git-dir GIT_DIR --help (-h) --show-stack-trace --version command [ARG ...]

The most commonly used commands are:
 add                  Add file contents to the index
 archive              Zip up files from the named tree
...
...

@maxandersen
Copy link
Collaborator Author

https://twitter.com/alblue/status/1314350114736148480 reminded me of why this fails -jar and -cp are mutual exclusive. java prints no warning or error but when using -jar then -cp are ignored - no matter what.

@maxandersen
Copy link
Collaborator Author

this was fixed in recent releases. no longer uses -jar as it behaves as an island not extendable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant