Could not load JNR C Library in Unit Testing

849 views
Skip to first unread message

ayush....@knoldus.in

unread,
Feb 13, 2018, 7:16:09 AM2/13/18
to Lagom Framework Users

I am try to use Embedded Cassandra during my unit test cases for my lagom service impl.
But everytime I get this error

17:23:52.275 [pool-1-thread-1] DEBUG com.datastax.driver.core.Native - Could not load JNR C Library, native system calls through this library will not be available
java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.ClassVisitor, but class was expected
    at jnr.ffi.provider.jffi.AsmLibraryLoader.generateInterfaceImpl(AsmLibraryLoader.java:74)
    at jnr.ffi.provider.jffi.AsmLibraryLoader.loadLibrary(AsmLibraryLoader.java:59)
    at jnr.ffi.provider.jffi.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:43)
    at jnr.ffi.LibraryLoader.load(LibraryLoader.java:290)
    at jnr.ffi.LibraryLoader.load(LibraryLoader.java:269)
    at com.datastax.driver.core.Native$LibCLoader.<clinit>(Native.java:108)
    at com.datastax.driver.core.Native.isGettimeofdayAvailable(Native.java:190)
    at com.datastax.driver.core.ClockFactory.newInstance(Clock.java:51)
    at com.datastax.driver.core.AbstractMonotonicTimestampGenerator.<init>(AbstractMonotonicTimestampGenerator.java:43)
    at com.datastax.driver.core.LoggingMonotonicTimestampGenerator.<init>(LoggingMonotonicTimestampGenerator.java:49)
    at com.datastax.driver.core.AtomicMonotonicTimestampGenerator.<init>(AtomicMonotonicTimestampGenerator.java:50)
    at com.datastax.driver.core.AtomicMonotonicTimestampGenerator.<init>(AtomicMonotonicTimestampGenerator.java:37)
    at com.datastax.driver.core.policies.Policies.defaultTimestampGenerator(Policies.java:121)
    at com.datastax.driver.core.policies.Policies$Builder.build(Policies.java:286)
    at com.datastax.driver.core.Cluster$Builder.getConfiguration(Cluster.java:1317)
    at com.datastax.driver.core.Cluster.<init>(Cluster.java:113)
    at com.datastax.driver.core.Cluster.buildFrom(Cluster.java:178)
    at com.datastax.driver.core.Cluster$Builder.build(Cluster.java:1335)


Because of this, I uanble to start my embedded cassandra
7:23:52.517 [pool-1-thread-1] DEBUG com.datastax.driver.core.ControlConnection - [Control connection] error on localhost/127.0.0.1:9042 connection, no more host to try
com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1:9042] Cannot connect

Even when I used external cassandra for the same test cases. It will work perfectly fine.

Ignasi Marimon-Clos i Sunyol

unread,
Feb 13, 2018, 8:41:17 AM2/13/18
to ayush....@knoldus.in, Lagom Framework Users
Hi Ayush,

any chance you can share some code (sources for the tests, build.sbt or pom.xml, etc...) or even push into GitHub a sample project demonstrating the error?

Thanks,


--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/4e7a7a67-a15a-4a83-9b32-442a7a57efb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Ignasi Marimon-Clos
Software Developer @ Lagom


Message has been deleted

ayush....@knoldus.in

unread,
Feb 13, 2018, 9:45:31 AM2/13/18
to Lagom Framework Users
Yes, I can
This is the body of my test case
{
val pointSource = Source.fromIterator(() => Seq(jsonGenerator).toIterator)
val stream = pointSource.via(eventServiceSubscriber.subscriberFlow).runWith(Sink.ignore)

val futureResponse = for{
res <- stream
}yield res

futureResponse.map(res => assert(res === Done & stream.isCompleted))
}
Before that, I said simply create the server
lazy val server: ServiceTest.TestServer[EventServiceApplication with LocalServiceLocator] =
ServiceTest.startServer{ServiceTest.defaultSetup}{ ctx => new EventServiceApplication(ctx) with LocalServiceLocator}

& my build.sbt looks like
)
.enablePlugins(LagomScala)
.settings(
scalaVersion := scalaVer,
excludeDependencies += "org.slf4j" % "slf4j-log4j12",
excludeDependencies += "org.slf4j" % "log4j-over-slf4j",
dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-core" % "2.8.7",
dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.8.7",
dependencyOverrides += "com.fasterxml.jackson.module" % "jackson-module-scala_2.11" % "2.8.7",
scalastyleConfig in Compile := file("sample-scalastyle-config-v0.1.xml"),
libraryDependencies ++= Seq(
lagomScaladslPersistenceCassandra,
lagomScaladslKafkaClient,
lagomScaladslTestKit,
macwire,
scalaTest
)
)
.settings(lagomForkedTestSettings: _*)
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framewo...@googlegroups.com.
To post to this group, send email to lagom-f...@googlegroups.com.

Tim Moore

unread,
Mar 6, 2018, 1:37:44 AM3/6/18
to ayush....@knoldus.in, Lagom Framework Users
Ayush, are you still having this problem?

I would suspect the dependencyOverrides in your build.sbt, since it's reporting an IncompatibleClassChangeError. This could happen if you have the wrong version of a library on your classpath.

Can you remove the dependencyOverrides? Does that help?

What eviction warnings do you see? Run "sbt evicted" to print them. Some amount are normal and expected, but in some cases they can signal problems. Look for any involving JNR or ASM.

Best,
Tim

To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/7ca7e77c-1eb7-409e-9c94-512b1f0a6e56%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Tim Moore
Lagom Tech Lead, Lightbend, Inc.

Reply all
Reply to author
Forward
0 new messages