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

ClassNotFoundException after importing library #38

Open
MaaxGr opened this issue Mar 23, 2021 · 7 comments
Open

ClassNotFoundException after importing library #38

MaaxGr opened this issue Mar 23, 2021 · 7 comments

Comments

@MaaxGr
Copy link

MaaxGr commented Mar 23, 2021

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
Copy link

I have the same problem ☝️

sidneywidmer added a commit to sidneywidmer/nebula-recorder-server that referenced this issue May 21, 2021
@MaaxGr
Copy link
Author

MaaxGr commented May 21, 2021

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
Copy link

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

@MaaxGr
Copy link
Author

MaaxGr commented May 21, 2021

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

@LSafer
Copy link

LSafer commented Jun 16, 2022

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
Copy link
Author

MaaxGr commented Jun 19, 2022

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
Copy link

LSafer commented Jun 19, 2022

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.

jahrim added a commit to ldss-project/authentication-service that referenced this issue Aug 6, 2023
The previous bcrypt implementation was causing a ClassNotFoundException when executing the fat jar of the application.
For more information, see issue: patrickfav/bcrypt#38
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

3 participants