Java Tracker Failing with Jackson Error


#1

I am getting a weird error when trying to run the Java tracker

Please Help

HttpClientAdapter adapter = OkHttpClientAdapter.builder()
        .url("http://www.acme.com") // at this line this is locahost:8888 the default collector url
        .httpClient(client)
        .build();

Exception in thread “main” java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
at com.snowplowanalytics.snowplow.tracker.http.AbstractHttpClientAdapter.(AbstractHttpClientAdapter.java:63)
at com.snowplowanalytics.snowplow.tracker.http.OkHttpClientAdapter.(OkHttpClientAdapter.java:76)
at com.snowplowanalytics.snowplow.tracker.http.OkHttpClientAdapter$Builder.build(OkHttpClientAdapter.java:60)
at com.example.snowplow.App.main(App.java:36)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonProcessingException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)


#2

After Adding some more imports the previous error has gobe but not log 4j error has popped up can we know the exact versions.

Dependencies Added

junit junit 3.8.1 test com.snowplowanalytics snowplow-java-tracker 0.8.0 ${pom.basedir}/snowplow-java-tracker-0.8.0.jar system com.squareup.okhttp okhttp 2.2.0 org.slf4j slf4j-simple 1.7.7

Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.snowplowanalytics.snowplow.tracker.Utils.(Utils.java:35)
at com.snowplowanalytics.snowplow.tracker.http.AbstractHttpClientAdapter.(AbstractHttpClientAdapter.java:63)
at com.snowplowanalytics.snowplow.tracker.http.OkHttpClientAdapter.(OkHttpClientAdapter.java:76)
at com.snowplowanalytics.snowplow.tracker.http.OkHttpClientAdapter$Builder.build(OkHttpClientAdapter.java:60)
at com.example.snowplow.App.main(App.java:28)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
… 5 more


#3

Hi Rahul,

You will find the list of dependencies and their associated versions in build.gradle.


#4

Hi @BenFradet Added and fortunately the errors are resolved but the thing is that i have added the local collector url which is pushing it to kafka but no where i can see the data being pushed to kafka, even added callback logs but to no effect can you tell how we debug please .

Code so far

HttpClientAdapter adapter = OkHttpClientAdapter.builder()
.url(“http://localhost:8888”)
.httpClient(client)
.build();

Emitter emitter = SimpleEmitter.builder()
.httpClientAdapter(adapter) // Required
.threadCount(1) // Default is 50
.requestCallback(null) // Default is Null
.build();
Subject user1Subject = new Subject.SubjectBuilder()
.userId(“subject-1-uid”)
.build();

Tracker tracker = new Tracker.TrackerBuilder(emitter, “AF003”, “cf”)
.subject(user1Subject)
.base64(true)
.platform(DevicePlatform.Desktop)
.build();