Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ClassNotFoundException: org.jetbrains.annotations.NotNull during JTE template compilation #423

Open
dajulia3 opened this issue Jan 21, 2025 · 0 comments

Comments

@dajulia3
Copy link

Issue: ClassNotFoundException: org.jetbrains.annotations.NotNull during JTE template compilation

When trying to compile kotlin JTE templates (.kte) with gradle, I'm getting a ClassNotFoundException for org.jetbrains.annotations.NotNull. This appears to be a dependency issue where JTE's Kotlin compiler can't find the annotations it needs.

Environment

  • JTE version: 3.1.16
  • Kotlin version: 1.9.10 (I also tried with 2.1.0 but downgraded thinking it might be an issue)
  • Gradle version: - tried both 8.8 and 8.12; same issue
  • JDK version: 21.0.5

Configuration

build.gradle.kts:

plugins {
    id("com.siv.app-conventions")
    id("gg.jte.gradle") version("3.1.16")
}

dependencies {
    val jteVersion = "3.1.16"
    
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("gg.jte:jte-kotlin:$jteVersion")
    implementation("gg.jte:jte-spring-boot-starter-3:$jteVersion")
    implementation("org.jetbrains:annotations:24.0.0")  // Already have annotations dependency
}

sourceSets {
    main {
        java.srcDir("jte-classes")
    }
}

tasks.precompileJte {
    dependsOn(tasks.classes)
}

jte {
    precompile()
    contentType.set(ContentType.Html)
}

Template File

@import com.siv.monolith.jte_utils.Page
@param page: Page

@template.admin.layout.admin-layout(page = page, content =@`
    <h1> This is the admin page content!!!</h1>
`)

Error

Caused by: java.lang.ClassNotFoundException: org.jetbrains.annotations.NotNull

Full stack trace shows the error occurs during Kotlin IR compilation of the generated template classes:

Backend Internal error: Exception during IR lowering
File being compiled: .../jte-classes/gg/jte/generated/precompiled/JteexampleGenerated.kt
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)

Expected Behavior

The templates should compile successfully since we have the required dependencies (org.jetbrains:annotations) in the classpath.

Actual Behavior

The Kotlin compiler used by JTE cannot find the annotations classes, despite them being available in the project dependencies.

Question

Is there a way to ensure the annotations dependency is properly passed to JTE's internal Kotlin compiler? Or is there a different way we should be configuring the dependencies for JTE template compilation? I've tried including the jetbrains annotation dependency as an implementation dependency and a buildscript classpath dependency. I'm at a loss for how to solve this and would really appreciate any help :)

Full stack trace for reference:

stacktrace.txt

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant