patrickfav / bcrypt

A Java standalone implementation of the bcrypt password hash function. Based on the Blowfish cipher it is the default password hash algorithm for OpenBSD and other systems including some Linux distributions. Includes a CLI Tool.
https://favr.dev/opensource/bcrypt
Apache License 2.0
467 stars 50 forks source link

Java 11 broken jar file #30

Open ipkpjersi opened 4 years ago

ipkpjersi commented 4 years ago

Whenever I use this library in Java 11 to build a jar with Intellij, it says my main class is not found:

When the main class clearly does exist, with the correct packaging:

When using JBCrypt 0.4 instead of this bcrypt library, my jar file works fine, but JBCrypt doesn't support the newer $2y BCrypt version, only $2a.

I worked around this issue by finding a newer JBCrypt fork with $2y support, and I built a jar of it and the jar worked perfectly: https://github.com/Oscil8/jBCrypt/tree/djm-2y-etc an

patrickfav commented 4 years ago

Hi @ipkpjersi

Thanks for the bug report.

I'm a little confused though, it seems the missing class is from your codebase, so I don't see how this library could influence that issue? The only hunch I have is if you use OSGi (I added a feature supporting it by a feature request - but it shouldn't influence non-OSGi)

ipkpjersi commented 4 years ago

I know, it confused me too. It does say the missing class is from my code-base, but, I did narrow it down to this BCrypt library or the Bytes library that this library depends on. If I remove BCrypt and Bytes and just use JBCrypt, it works fine as it did for months. Just thought I'd give a heads up and report this issue, and maybe see if anyone else was running into it. I'm not using OSGI, but I am using Java 11 which has been known to break some things. I also tried multiple versions of this BCrypt library and of Bytes, and it still did not work.

patrickfav commented 4 years ago

Thanks for telling me, appreciate it. TBF there are not a lot of tests using Java11 so maybe something is broken - I will leave this open and will test in the near future for possible issues.

Have a good one!

RohanNagar commented 3 years ago

For what it's worth I just replaced jbcrypt with this library in my Java 11 application and it's working great!

LionZXY commented 3 years ago

This problem too :(

patrickfav commented 3 years ago

So unfortunately with this much information I cant really investigate, if one of you have some pointer where to look, or a test case I might be able to fix that.

anc1llary commented 3 years ago

Hi Patrick,

What is happening to the individuals for this issue is they did not include your other library, 'Bytes', which is necessary for your Bcrypt library to work. I included the Bytes library with the necessary imports, and this worked successfully. There is no problem here.

Thanks for your work, it is much appreciated.

HorizonCode commented 3 years ago

Also having the same issue with Java8 in IntelliJ. added it via maven pom.xml. Luyten thows this exception if trying to decompile:

java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
    at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)
    at sun.security.util.SignatureFileVerifier.process(Unknown Source)
    at java.util.jar.JarVerifier.processEntry(Unknown Source)
    at java.util.jar.JarVerifier.update(Unknown Source)
    at java.util.jar.JarFile.initializeVerifier(Unknown Source)
    at java.util.jar.JarFile.getInputStream(Unknown Source)
    at com.strobel.assembler.metadata.JarTypeLoader.tryLoadType(JarTypeLoader.java:59)
    at us.deathmarine.luyten.LuytenTypeLoader.tryLoadType(LuytenTypeLoader.java:25)
    at com.strobel.assembler.metadata.MetadataSystem.resolveType(MetadataSystem.java:125)
    at com.strobel.assembler.metadata.MetadataSystem.lookupTypeCore(MetadataSystem.java:86)
    at com.strobel.assembler.metadata.MetadataResolver.lookupType(MetadataResolver.java:46)
    at us.deathmarine.luyten.Model.openEntryByTreePath(Model.java:338)
    at us.deathmarine.luyten.Model$TreeListener$1.run(Model.java:266)

Edit: This issue seems just to appear if the bytes.jar lib is added to the artifact. if i remove it from the export list, the file is fine. so as my conclusion: its a issue with the bytes lib dependency.

Edit 2: I think i found the issue, i just deleted the whole META-INF Folder and it works, seems like any of your Hashes are wrong, maybe you should check if there is any issues there.

NathanPB commented 3 years ago

Just to address, this issue was happening with the Firebase Admin library too. I still don't have any decent workaround

https://stackoverflow.com/questions/64440041/firebase-admin-sdk-causing-cannot-find-or-load-main-class

Edit: I downloaded the bytes.jar file and manually checked the hashes in the MANIFEST file and they don't match the .class files ones. Maybe a simple recompile of bytes can solve the entire problem