I had this problem when trying to use luaJ and Jython within my minecraft mod. I found the answer in another thread and hope this solves your problem too.
https://stackoverflow.com/a/79173826
Instead of this:
dependencies {
...
implementation 'black.ninia:jep:4.2.2' // Your dependency instead
}
Do this:
dependencies {
...
minecraftLibrary fg.deobf("black.ninia:jep:4.2.2") // Your dependency instead
}
A brief explanation can also be found on the forge docs. https://docs.minecraftforge.net/en/fg-5.x/dependencies/