Oshi: java.lang.NoClassDefFoundError: oshi/SystemInfo

Created on 8 Oct 2020  路  7Comments  路  Source: oshi/oshi

Error :

java.lang.NoClassDefFoundError: oshi/SystemInfo
    at io.cloudslang.worker.monitor.CpuPerProcess.measure(CpuPerProcess.java:34)
    at io.cloudslang.worker.monitor.PerfMetricCollectorImpl.collectMetric(PerfMetricCollectorImpl.java:53)
    at io.cloudslang.worker.monitor.service.WorkerMetricCollectorServiceImpl.collectPerfMetrics(WorkerMetricCollectorServiceImpl.java:42)
    at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Dependency :

<dependencies>

        <dependency>
            <groupId>com.github.oshi</groupId>
            <artifactId>oshi-core</artifactId>
            <version>5.2.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>score-worker-monitor-api</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
        </dependency>

    </dependencies> 
maven dependencies question

All 7 comments

I checked in my java program it is working but when I included in maven project it is giving me this error ?

The error is not in OSHI but in whatever program you're running that does not include it. Where is the package io.cloudslang.worker.monitor and the class CpuPerProcess? Did you import oshi.SystemInfo in that class?

It appears the classes you are using are from CloudSlang score but I don't see oshi-core in their project. If you have forked that project, you may need to add oshi-core as a dependency in that pom.

In this package only I created CpuPerProcess class. And Yes I have import oshi.SystemInfo .

yeah I got your point

Were you able to solve this? If so, I can close it.

I also answered this same question on Stack Overflow. If it's answered there you could accept the answer to indicate it was resolved.

Thankyou so much, yeah it is resolved and I have marked resolved in stack overflow also. Once again thanks for the quick reply. OSHI api is the best api for getting operating system info.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sami32 picture Sami32  路  11Comments

dbwiddis picture dbwiddis  路  12Comments

jgueth picture jgueth  路  9Comments

dbwiddis picture dbwiddis  路  12Comments

GreatGarlic picture GreatGarlic  路  8Comments