# metricsCallback: Callback class could not be loaded

**URL:** <https://forum.datomic.com/t/metricscallback-callback-class-could-not-be-loaded/900>\
**Category:** Troubleshooting\
**Created:** [March 26, 2019, 4:41pm UTC](https://forum.datomic.com/t/metricscallback-callback-class-could-not-be-loaded/900 "2019-03-26T16:41:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andywhite37](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/andywhite37/32/277_2.png) [@andywhite37](https://forum.datomic.com/u/andywhite37)\
**Post date:** [March 26, 2019, 4:41pm UTC](https://forum.datomic.com/t/metricscallback-callback-class-could-not-be-loaded/900/1 "2019-03-26T16:41:19Z")

</div>

Hi all,

We are using datomic pro 0.9.5350 (peer) in a Scala application, and I’m having trouble getting the `metricsCallback` to work with a Java-style callback.

I have this in my JVM startup options:

```auto
-Ddatomic.metricsCallback=util.datomic.DatomicCallback.metricsCallback

```

I’ve tried creating various different versions of Scala and Java classes to handle the callback, but I can’t seem to get datomic to load the class for the callback. Here is the simplest example I’ve tried:

```auto
package util.datomic;

public class DatomicCallback {
    public static void metricsCallback(Object obj) {
        System.out.println("metricsCallback");
        System.out.println(obj);
    }
}

```

At startup, I get this log message:

```auto
2019-03-26 16:07:16,340 [WARN] from datomic.callback - {:message "Callback class util.datomic.DatomicCallback could not be loaded", :pid 13256, :tid 101}

```

I verified there is a compiled `util/datomic/DatomicCallback.class` in the build artifacts directory tree.

Is there something obviously wrong with what I’m doing, or a way to troubleshoot this further?

---

<div class="post-metadata">

**Author:** ![marshall](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/marshall/32/48_2.png) [@marshall](https://forum.datomic.com/u/marshall)\
**Post date:** [April 2, 2019, 4:49pm UTC](https://forum.datomic.com/t/metricscallback-callback-class-could-not-be-loaded/900/2 "2019-04-02T16:49:36Z")

</div>

Hi Andy,

Have you ensured that the `util/datomic/DatomicCallback.class` is in the classpath of your JVM process?

---

<div class="post-metadata">

**Author:** ![andywhite37](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/andywhite37/32/277_2.png) [@andywhite37](https://forum.datomic.com/u/andywhite37)\
**Post date:** [April 17, 2019, 10:24pm UTC](https://forum.datomic.com/t/metricscallback-callback-class-could-not-be-loaded/900/3 "2019-04-17T22:24:40Z")

</div>

Hi Marshall,  
Thanks for your reply.

I believe the class is in the classpath, and to double check, I added some test code to the app to try to load the class at startup. I also added a check for a non-existing class to make sure I wasn’t getting a false positive. (This is a scala project).

```auto
try {
    println("Loading valid class...")
    val x = Class.forName("util.datomic.DatomicCallback").asInstanceOf[Class[util.datomic.DatomicCallback]]
    println("Loaded class:")
    println(x)

    println("Loading invalid class...")
    val y = Class.forName("util.datomic.DatomicCallbackx").asInstanceOf[Class[util.datomic.DatomicCallback]]
    println("Loaded class:")
    println(y)
  } catch {
    case e: Throwable =>
      println("Failed to load class:")
      println(e)
  }

```

This prints:

```auto
Loading valid class...
Loaded class:
class util.datomic.DatomicCallback
Loading invalid class...
Failed to load class:
java.lang.ClassNotFoundException: util.datomic.DatomicCallbackx

```

I still get this error from datomic from its attempt to load the callback class:

```auto
2019-04-17 22:23:14,326 [WARN] from datomic.callback - {:message "Callback class util.datomic.DatomicCallback could not be loaded", :pid 27537, :tid 1016}

```
