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

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

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:

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

here are the dependencies form my pom.xml

    <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:

[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

Do you get same error when not using release candidate sdk version but last official v1.16.0?

You should not have to explicitly add

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

Try removing it as well.

I do still have the same problem.

New pom.xml:

    <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:

[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
<dependency>
    <groupId>io.temporal</groupId>
    <artifactId>temporal-testing</artifactId>
    <version>1.16.0</version>
</dependency>

add

<scope>test</scope>

please and try again

still the same problem

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

<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:

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

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

[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:

<?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>

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

<?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

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

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

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:

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