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

ClassNotFoundException after importing library #38

Open MaaxGr opened 3 years ago

MaaxGr commented 3 years ago

After i have added this library to gradle:

implementation group: 'at.favre.lib', name: 'bcrypt', version: '0.9.0'

build the Project into a JAR and run it

java -jar build/libs/example-0.0.1.jar

i get the following error:

Error: Could not find or load main class io.ktor.server.netty.EngineMain
Caused by: java.lang.ClassNotFoundException: io.ktor.server.netty.EngineMain

If i comment out only your dependency everything is fine. Seems to be connected to issue #30. If i manually delete everything out of the META-INF Folder (except MANIFEST.MF) everything works again.

sidneywidmer commented 3 years ago

I have the same problem :point_up:

MaaxGr commented 3 years ago

I have a workaround for this: Download the jars from mavencentral and delete the META-INF Folder. Than throw the library into a libs folder and add the jar from cradle via the local file. Hope it helps @sidneywidmer

sidneywidmer commented 3 years ago

@MaaxGr Thx for the hint, that worked :+1: But would be nice if there was a cleaner way.

MaaxGr commented 3 years ago

Yes of course. But just in case you need it know (as I did 😅)

LSafer commented 2 years ago

I think your problem is not from this library rather the usage of Gradle!

Adding implementation is not enough to make Gradle add the library to the output jar. You might use https://github.com/johnrengelman/shadow or search with the keyword fat jar

MaaxGr commented 2 years ago

Yeah. I assumed that everyone in this issue knows how to build a fat-jar :D Nevertheless it don't works for me. Have you tested your solution @LSafer?

LSafer commented 2 years ago

No, I didn't 😅

I thought you didn't knew about fat-jars but It seems that the issue isn't about it

About the issue, it might be because there is a dependency of 'bcrypt' itself missing at runtime.