Hi, i am struggling to get pact libs to behave in ...
# pact-jvm
i
Hi, i am struggling to get pact libs to behave in my project, I have a java 11 app. I have tried using the deps
Copy code
testImplementation("au.com.dius.pact.core:model:4.4.9")
testImplementation("au.com.dius.pact.consumer:junit5:4.4.9")
I manage to write some sort of PACT test (doesnt work); The problem is this kills debugging (adding these deps). It kills debugging for the entire project. I try to run any test in debug mode (intellij) and i get the following error:
Copy code
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/Result
	at kotlinx.coroutines.debug.AgentPremain.<clinit>(AgentPremain.kt:24)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
Disconnected from the target VM, address: '127.0.0.1:58784', transport: 'socket'
Something to do with kotlin. • What is the issue here, and how do i fix ? šŸ˜› • Do i actually need both of those deps ? Thanks!!
lo and behold...adding this gradle plugin seems to have fixed debugging... "id 'org.jetbrains.kotlin.jvm' version '1.5.31'" 🤷 .
is this the actual way i am supposed to fix this hmmm
u
There is something wrong with your project, as your classpath is not correct. Do you use Kotlin in your project?
i
Nope we dont use kotlin in this project
u
That stacktrace is in native code, not Pact-JVM. But the
java.lang.NoClassDefFoundError: kotlin/Result
means the Kotlin stdlib is missing
You can try adding
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
to your project.
i
hmm, i added the plugin and it worked. Before adding the plugin i had a problem
if these are transitive dependencies, shouldn't they be added in by gradle automagically ?
u
Yes, they should
i
stdlib still seems to be there, but i still need the plugin
my other question, am i supposed to need both deps "au.com.dius.pact.coremodel4.4.9"" and "au.com.dius.pact.consumerjunit54.4.9" or just the latter ?
So i am concluding, that in order to use pact-jvm, in a pure java11 app, i must add 'id 'org.jetbrains.kotlin.jvm' version '1.5.31'' plugin that is if i want to be able to continue to debug the app, because the library, pact-jvm, is written in kotlin. Is that a fair conclusion ? I find this surprising.
u
No, this problem is unique to your app. Pact-JVM works just fine in lots of other pure Java apps.
i
okies cool, thanks šŸ™‚
Yep, just created a shell java 11 app + pact-jvm, and adding debugger works fine.
//me enters dependency hell
😭 1
cccccctbbnvfejrrjtnfelldbfvfdlffuhhvvrfinvrl