question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoClassDefFoundError: kotlin/time/MonoClock

See original GitHub issue

kotlin: 1.3.70-eap-184 kotest version: 4.0.0-BETA1

build.gradle.kts:

dependencies {
	testImplementation("ch.qos.logback:logback-classic")

	testImplementation("io.kotest:kotest-runner-junit5-jvm")
	testImplementation("io.kotest:kotest-extensions-spring-jvm")
	testImplementation("io.kotest:kotest-assertions-json-jvm")

	testImplementation("org.springframework.boot:spring-boot-starter-test") {
		exclude(group = "org.junit.vintage")
	}
}

sample code:

package demo

import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldNotBe
import io.kotest.spring.SpringListener

class DemoTest : FunSpec(
	{
		listener(SpringListener)

		beforeSpec {
			println("before_spec.SPRING_PROFILES_ACTIVE: ${System.getenv("SPRING_PROFILES_ACTIVE")}")
		}

		beforeTest {
			println("Starting test ${it.name}!")
		}

		afterTest {
			println("Finished test ${it.a.name}!")
		}

		test("test env") {
			println("execute test: ${testCase.name}")
			System.getenv("SPRING_PROFILES_ACTIVE").shouldNotBe("test")
		}
	}
)

report output:

13:50:38.664 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
13:50:38.688 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
13:50:38.740 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest] from class [org.springframework.test.context.support.DefaultTestContextBootstrapper]
13:50:38.764 [kotest-engine-0 @coroutine#1] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest], using DelegatingSmartContextLoader
13:50:38.770 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.AbstractDelegatingSmartContextLoader - Delegating to GenericXmlContextLoader to process context configuration [ContextConfigurationAttributes@1110e6f8 declaringClass = 'com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest', classes = '{}', locations = '{}', inheritLocations = false, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader'].
13:50:38.776 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest]: class path resource [com/apisafepay/external/providers/octocash/rest/interceptors/DemoTest-context.xml] does not exist
13:50:38.777 [kotest-engine-0 @coroutine#1] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest]: no resource found for suffixes {-context.xml}.
13:50:38.778 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.AbstractDelegatingSmartContextLoader - Delegating to AnnotationConfigContextLoader to process context configuration [ContextConfigurationAttributes@1110e6f8 declaringClass = 'com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest', classes = '{}', locations = '{}', inheritLocations = false, initializers = '{}', inheritInitializers = true, name = [null], contextLoaderClass = 'org.springframework.test.context.ContextLoader'].
13:50:38.779 [kotest-engine-0 @coroutine#1] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest]: DemoTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
13:50:38.862 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest]
13:50:38.864 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.DefaultTestContextBootstrapper - @TestExecutionListeners is not present for class [com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest]: using defaults.
13:50:38.865 [kotest-engine-0 @coroutine#1] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
13:50:38.876 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.DefaultTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [javax/servlet/ServletContext]
13:50:38.878 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.DefaultTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
13:50:38.879 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.DefaultTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
13:50:38.880 [kotest-engine-0 @coroutine#1] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@7601f00e, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@6d94b9af, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@3fd16e66, org.springframework.test.context.support.DirtiesContextTestExecutionListener@73b758a7, org.springframework.test.context.event.EventPublishingTestExecutionListener@acf475f, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@425ede68, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@76483a1b, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@3f732615, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@4ff66b1b, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@7b6f5113]
13:50:38.883 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@3479c0d3 testClass = DemoTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@4d3c9626 testClass = DemoTest, locations = '{}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6f4cd60e, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@315f4a14, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@466ed660, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]], attributes = map[[empty]]], class annotated with @DirtiesContext [false] with mode [null].
13:50:38.891 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@3479c0d3 testClass = DemoTest, testInstance = com.apisafepay.external.providers.octocash.rest.interceptors.DemoTest@4ccc65fc, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@4d3c9626 testClass = DemoTest, locations = '{}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6f4cd60e, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@315f4a14, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@466ed660, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]], attributes = map[[empty]]]].
13:50:38.892 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.AbstractDelegatingSmartContextLoader - Delegating to AnnotationConfigContextLoader to load context from [MergedContextConfiguration@4d3c9626 testClass = DemoTest, locations = '{}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6f4cd60e, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@315f4a14, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@466ed660, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]].
13:50:38.893 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.AbstractGenericContextLoader - Loading ApplicationContext for merged context configuration [[MergedContextConfiguration@4d3c9626 testClass = DemoTest, locations = '{}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6f4cd60e, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@315f4a14, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@466ed660, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]].
13:50:38.952 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.core.env.StandardEnvironment - Activating profiles []
13:50:38.953 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.support.AnnotationConfigContextLoader - Registering component classes: {}
13:50:38.986 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext@24720a3e
13:50:39.007 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
13:50:39.038 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.boot.test.mock.mockito.MockitoPostProcessor'
13:50:39.064 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerProcessor'
13:50:39.067 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
13:50:39.069 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
13:50:39.072 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
13:50:39.079 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.boot.test.mock.mockito.MockitoPostProcessor$SpyPostProcessor'
13:50:39.114 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate - Storing ApplicationContext [611453502] in cache under key [[MergedContextConfiguration@4d3c9626 testClass = DemoTest, locations = '{}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6f4cd60e, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@315f4a14, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@466ed660, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]
13:50:39.115 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.cache - Spring test ApplicationContext cache statistics: [DefaultContextCache@20b1fe66 size = 1, maxSize = 32, parentContextCount = 0, hitCount = 0, missCount = 1]
13:50:39.544 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate - Retrieved ApplicationContext [611453502] from cache with key [[MergedContextConfiguration@4d3c9626 testClass = DemoTest, locations = '{}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6f4cd60e, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@315f4a14, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@466ed660, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]]
13:50:39.545 [kotest-engine-0 @coroutine#1] DEBUG org.springframework.test.context.cache - Spring test ApplicationContext cache statistics: [DefaultContextCache@20b1fe66 size = 1, maxSize = 32, parentContextCount = 0, hitCount = 1, missCount = 1]
before_spec.SPRING_PROFILES_ACTIVE: test
java.lang.NoClassDefFoundError: kotlin/time/MonoClock
java.lang.NoClassDefFoundError: kotlin/time/MonoClock

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ilya-gcommented, Mar 3, 2020

Since it’s based on inline classes – not earlier than inline classes feature graduates to stable, and that doesn’t seem to happen soon.

1reaction
ilya-gcommented, Feb 21, 2020

The fact that the experimental stdlib API is used in kotest may impose serious compatibility problems with the next versions of stdlib. Please refer to the warning in @ExperimentalTime annotation docs: https://github.com/JetBrains/kotlin/blob/v1.3.60/libraries/stdlib/src/kotlin/time/ExperimentalTime.kt#L13-L15

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I solve "java.lang.NoClassDefFoundError"?
The NoClassDefFoundError indicates that the classloader (in this case java.net.URLClassLoader ), which is responsible for dynamically loading classes, cannot ...
Read more >
3 ways to solve java.lang.NoClassDefFoundError in Java J2EE
A simple example of NoClassDefFoundError is class belongs to a missing JAR file or JAR was not added into classpath or sometimes jar's...
Read more >
java.lang.NoClassDefFoundError - DigitalOcean
NoClassDefFoundError is runtime error thrown when a required class is not found in the classpath and hence JVM is unable to load it...
Read more >
NoClassDefFoundError (Java SE 14 & JDK 14)
Constructs a NoClassDefFoundError with the specified detail message. Method Summary. Methods declared in class java.lang.Throwable · addSuppressed, ...
Read more >
Why am I encountering java.lang.NoClassDefFoundError at ...
In workbench, adding projects directly to the java build path will allow code to compile, but it will not be able to resolve...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found