spring-bootintellij-ideathymeleafkotlintest

Intellij - thymeleaf freaking out on kotlintest


I'm developing a spring-boot appliction in kotlin with Intellij, using springMVC and thymeleaf. Simple enough, and everything workes fine until I try running some tests. And the tests are not even related. In fact, just instantiating a test seems to be enough to drive thymeleaf insane. It throws thousands of lines of exceptions.

I have made a git repository with a minimal project setup that reproduces the issue here: https://github.com/TheNewBob/kotlin-test-thymeleaf

here's my "test" in two versions:

Plain JUnit:

class ContentServiceTest {
    @Test
    fun test() {
    }
}

Works fine, Console output in Intellij:

Connected to the target VM, address: '127.0.0.1:45773', transport: 'socket'
Disconnected from the target VM, address: '127.0.0.1:45773', transport: 'socket'

Process finished with exit code 0

But when I switch to Kotlintest:

class ContentServiceTest :StringSpec()

Mayhem ensues:

13:24:24.904 [main] DEBUG org.reflections.Reflections - could not scan file org/thymeleaf/dtd/standard/xhtml1-strict.dtd in url file:/home/benedict/.gradle/caches/modules-2/files-2.1/org.thymeleaf/thymeleaf/2.1.6.RELEASE/c362b4ecbeddc86a0cb7e767a88ce27e9c8147e6/thymeleaf-2.1.6.RELEASE.jar with scanner TypeAnnotationsScanner
org.reflections.ReflectionsException: could not create class object from file org/thymeleaf/dtd/standard/xhtml1-strict.dtd
    at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:32)
    at org.reflections.Reflections.scan(Reflections.java:253)
    at org.reflections.Reflections.scan(Reflections.java:202)
    at org.reflections.Reflections.<init>(Reflections.java:123)
    at org.reflections.Reflections.<init>(Reflections.java:168)
    at io.kotlintest.Project.discoverProjectConfig(Project.kt:15)
    at io.kotlintest.Project.<init>(Project.kt:27)
    at io.kotlintest.Project.<clinit>(Project.kt:8)
    at io.kotlintest.KTestJUnitRunner.<init>(KTestJUnitRunner.kt:10)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.reflections.ReflectionsException: could not create class file from xhtml1-strict.dtd
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:102)
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:24)
    at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:30)
    ... 22 common frames omitted
Caused by: java.io.IOException: bad magic number: 3c212d2d
    at javassist.bytecode.ClassFile.read(ClassFile.java:825)
    at javassist.bytecode.ClassFile.<init>(ClassFile.java:154)
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:100)
    ... 24 common frames omitted

This error is thrown over and over again. I reconfigured my terminal buffer for 10'000 lines, and the output still doesn't fit.

The thing I noticed though is that gradlew test runs without issues, so Intellij IDEA seems to play a part in this as well.

This is then, essentially, my conundrum: spring-boot, thymeleaf, kotlintest and IDEA are all involved in this. Remove any of them, and there is no problem. I have no idea which is the main culprit, otherwise I might just file an issue report in the appropriate place.

Has anyone ever experienced this issue before, or has a hunch where the problem might be?


Solution

  • In case anyone encounters a similar issue upgrading to 3.1.0 or 3.0.0 will fix your issue. See https://github.com/kotlintest/kotlintest/issues/314