bcrypt icon indicating copy to clipboard operation
bcrypt copied to clipboard

ClassNotFoundException after importing library

Open MaaxGr opened this issue 3 years ago • 7 comments

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.

MaaxGr avatar Mar 23 '21 15:03 MaaxGr

I have the same problem :point_up:

sidneywidmer avatar May 21 '21 11:05 sidneywidmer

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

MaaxGr avatar May 21 '21 16:05 MaaxGr

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

sidneywidmer avatar May 21 '21 16:05 sidneywidmer

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

MaaxGr avatar May 21 '21 16:05 MaaxGr

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

LSafer avatar Jun 16 '22 19:06 LSafer

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?

MaaxGr avatar Jun 19 '22 16:06 MaaxGr

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.

LSafer avatar Jun 19 '22 19:06 LSafer