diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/html.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/html.kt index 2674e6c5bd..87176ca7e4 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/html.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/html.kt @@ -77,7 +77,14 @@ internal val formatter = DataFrameFormatter( internal fun getResources(vararg resource: String) = resource.joinToString(separator = "\n") { getResourceText(it) } internal fun getResourceText(resource: String, vararg replacement: Pair): String { - val res = DataFrame::class.java.getResourceAsStream(resource) ?: error("Resource '$resource' not found") + /** + * The choice of loader is crucial here: it should always be a class loaded by the same class loader as the resource we load. + * I.e. [DataFrame] isn't a good fit because it might be loaded by Kotlin IDEA plugin (because Kotlin plugin + * loads DataFrame compiler plugin), and plugin's classloader knows nothing about the resources. + */ + val loader = HtmlContent::class.java + val res = loader.getResourceAsStream(resource) + ?: error("Resource '$resource' not found. Load was attempted by $loader, loaded by ${loader.classLoader}") var template = InputStreamReader(res).readText() replacement.forEach { template = template.replace(it.first, it.second.toString())