# Error while running java unit tests: java.lang.NoClassDefFoundError: com/uber/m3/tally/Scope

**URL:** <https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171>\
**Category:** Server Deployment\
**Tags:** java-sdk, testing\
**Created:** [October 10, 2022, 5:08pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171 "2022-10-10T17:08:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![idelmas](https://avatars.discourse-cdn.com/v4/letter/i/dbc845/32.png) [@idelmas](https://community.temporal.io/u/idelmas)\
**Post date:** [October 10, 2022, 5:08pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171/1 "2022-10-10T17:08:31Z")

</div>

I am trying to run the unit test from the hello world application but get the following error when running them:

```auto
java.lang.NoClassDefFoundError: com/uber/m3/tally/Scope

```

I tried explicitly adding the dependency to my pom.xml tree with no success.

Here is the line that causes the error:

```auto
    @Rule
    public TestWorkflowRule testWorkflowRule =
            TestWorkflowRule.newBuilder()
                    .setWorkflowTypes(HelloWorldWorkflowImpl.class)
                    .setDoNotStart(true)
                    .build();

```

here are the dependencies form my pom.xml

```auto
    <dependencies>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-sdk</artifactId>
            <version>1.17.0-RC1</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-testing</artifactId>
            <version>1.17.0-RC1</version>
        </dependency>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-serviceclient</artifactId>
            <version>1.17.0-RC1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>com.uber.m3</groupId>
            <artifactId>tally-m3</artifactId>
            <version>0.2.0</version>
        </dependency>
    </dependencies>

```

here is the dependency tree:

```auto
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ helloworldapp ---
[INFO] org.example:helloworldapp:jar:1.0-SNAPSHOT
[INFO] +- io.temporal:temporal-sdk:jar:1.17.0-RC1:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] | +- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | +- commons-lang:commons-lang:jar:2.4:compile
[INFO] | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | +- commons-digester:commons-digester:jar:1.8:compile
[INFO] | | \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO] +- io.temporal:temporal-testing:jar:1.17.0-RC1:compile
[INFO] +- io.temporal:temporal-serviceclient:jar:1.17.0-RC1:compile
[INFO] +- junit:junit:jar:4.13.2:compile
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] +- org.mockito:mockito-core:jar:4.5.1:compile
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.12.9:compile
[INFO] | +- net.bytebuddy:byte-buddy-agent:jar:1.12.9:compile
[INFO] | \- org.objenesis:objenesis:jar:3.2:runtime
[INFO] \- com.uber.m3:tally-m3:jar:0.2.0:compile

```

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [October 10, 2022, 5:25pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171/2 "2022-10-10T17:25:45Z")

</div>

Do you get same error when not using release candidate sdk version but last official [v1.16.0](https://github.com/temporalio/sdk-java/releases/tag/v1.16.0)?

You should not have to explicitly add

```auto
<dependency>
    <groupId>com.uber.m3</groupId>
    <artifactId>tally-m3</artifactId>
    <version>0.2.0</version>
</dependency>

```

Try removing it as well.

---

<div class="post-metadata">

**Author:** ![idelmas](https://avatars.discourse-cdn.com/v4/letter/i/dbc845/32.png) [@idelmas](https://community.temporal.io/u/idelmas)\
**Post date:** [October 10, 2022, 5:36pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171/3 "2022-10-10T17:36:53Z")

</div>

I do still have the same problem.

New pom.xml:

```auto
    <dependencies>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-sdk</artifactId>
            <version>1.16.0</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-testing</artifactId>
            <version>1.16.0</version>
        </dependency>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-serviceclient</artifactId>
            <version>1.16.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>4.5.1</version>
        </dependency>
    </dependencies>

```

new dependency tree:

```auto
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ helloworldapp ---
[INFO] org.example:helloworldapp:jar:1.0-SNAPSHOT
[INFO] +- io.temporal:temporal-sdk:jar:1.16.0:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] | +- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | +- commons-lang:commons-lang:jar:2.4:compile
[INFO] | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | +- commons-digester:commons-digester:jar:1.8:compile
[INFO] | | \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO] +- io.temporal:temporal-testing:jar:1.16.0:compile
[INFO] +- io.temporal:temporal-serviceclient:jar:1.16.0:compile
[INFO] +- junit:junit:jar:4.13.2:compile
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] \- org.mockito:mockito-core:jar:4.5.1:compile
[INFO] +- net.bytebuddy:byte-buddy:jar:1.12.9:compile
[INFO] +- net.bytebuddy:byte-buddy-agent:jar:1.12.9:compile
[INFO] \- org.objenesis:objenesis:jar:3.2:runtime

```

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [October 10, 2022, 6:25pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171/4 "2022-10-10T18:25:41Z")

</div>

```auto
<dependency>
    <groupId>io.temporal</groupId>
    <artifactId>temporal-testing</artifactId>
    <version>1.16.0</version>
</dependency>

```

add

`<scope>test</scope>`

please and try again

---

<div class="post-metadata">

**Author:** ![idelmas](https://avatars.discourse-cdn.com/v4/letter/i/dbc845/32.png) [@idelmas](https://community.temporal.io/u/idelmas)\
**Post date:** [October 10, 2022, 6:36pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171/5 "2022-10-10T18:36:41Z")

</div>

still the same problem

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [October 10, 2022, 6:41pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171/6 "2022-10-10T18:41:12Z")

</div>

Weird, can you share your entire pom please?  
You should only need

```auto
<dependency>
    <groupId>io.temporal</groupId>
    <artifactId>temporal-sdk</artifactId>
    <version>${version.temporal}</version>
</dependency>

<dependency>
    <groupId>io.temporal</groupId>
    <artifactId>temporal-testing</artifactId>
    <scope>test</scope>
    <version>${version.temporal}</version>
</dependency>
 

```

temporal-sdk pulls in tally:

```auto
io.temporal:temporal-sdk:jar:1.16.0:compile
| +- io.temporal:temporal-serviceclient:jar:1.16.0:compile
| | +- com.uber.m3:tally-core:jar:0.11.1:compile

```

---

<div class="post-metadata">

**Author:** ![idelmas](https://avatars.discourse-cdn.com/v4/letter/i/dbc845/32.png) [@idelmas](https://community.temporal.io/u/idelmas)\
**Post date:** [October 10, 2022, 6:44pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171/7 "2022-10-10T18:44:27Z")

</div>

hmmm, it’s actually not in my dependency tree!

```auto
[INFO] org.example:helloworldapp:jar:1.0-SNAPSHOT
[INFO] +- io.temporal:temporal-sdk:jar:1.16.0:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] | +- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.6:compile

```

here is the entire pom:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>helloworldapp</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-sdk</artifactId>
            <version>1.16.0</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <scope>test</scope>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-testing</artifactId>
            <version>1.16.0</version>
        </dependency>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-serviceclient</artifactId>
            <version>1.16.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
        </dependency>
    </dependencies>
    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
</project>

```

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [October 10, 2022, 6:53pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171/8 "2022-10-10T18:53:16Z")

</div>

Thanks for info, took your pom, removed depends for service-client (not needed) so it looks like:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>helloworldapp</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-sdk</artifactId>
            <version>1.16.0</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>io.temporal</groupId>
            <artifactId>temporal-testing</artifactId>
            <version>1.16.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
        </dependency>
    </dependencies>
    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
</project>

```

And ran

```auto
mvn dependency:tree > depends.txt
vi depends.txt

```

I can see com.uber.m3:tally-core:jar:0.11.1:compile ☹

---

<div class="post-metadata">

**Author:** ![idelmas](https://avatars.discourse-cdn.com/v4/letter/i/dbc845/32.png) [@idelmas](https://community.temporal.io/u/idelmas)\
**Post date:** [October 10, 2022, 8:40pm UTC](https://community.temporal.io/t/error-while-running-java-unit-tests-java-lang-noclassdeffounderror-com-uber-m3-tally-scope/6171/9 "2022-10-10T20:40:41Z")

</div>

Thanks to you dependency tree I found my problem, hoping this might help someone else in the future.

I had to install the temporal sdk, serviceclient, testing dependencies manually into maven but did not install them specifying the pom. Once I did that the dependencies showed up and the code now works.

For anyone coming along, download the jar AND the pom, then run the following from the same directory:

```auto
mvn install:install-file -Dfile=temporal-sdk-1.16.0.jar -DgroupId=io.temporal -DartifactId=temporal-sdk -Dversion=1.16.0 -Dpackaging=jar -DpomFile=temporal-sdk-1.16.0.pom
mvn install:install-file -Dfile=temporal-testing-1.16.0.jar -DgroupId=io.temporal -DartifactId=temporal-testing -Dversion=1.16.0 -Dpackaging=jar -DpomFile=temporal-testing-1.16.0.pom
mvn install:install-file -Dfile=temporal-serviceclient-1.16.0.jar -DgroupId=io.temporal -DartifactId=temporal-serviceclient -Dversion=1.16.0 -Dpackaging=jar -DpomFile=temporal-serviceclient-1.16.0.pom

```

Thank you for you help @tihomir
