Problems running dokka-cli-1.7.10.jar from the command line

I have used javadoc without problems since Java version 1.2, but I constantly have problems with dokka. I submitted a similar topic for dokka-cli-1.4.0-rc.jar, but this time I am having problems again with the latest version. I would certainly appreciate any help on this.

Here is my command (running in Windows 10).

java -jar dokka-cli-1.7.10.jar -outputDir %OUTPUT_DIR% ^
          -pluginsClasspath "dokka-base-1.7.10.jar;dokka-analysis-1.7.10.jar;kotlin-analysis-compiler-1.7.10.jar;kotlin-analysis-intellij-1.7.10.jar;kotlinx-html-jvm-0.8.0.jar" ^
          -moduleName edu.citadel.compiler -sourceSet "-src %PROJECTS_HOME%\edu.citadel.compiler\src"

And here is the error I am getting when I try to run this command (some lines deleted). Note the exception java.lang.NoSuchFieldError: ALL_DIRECTORIES. Nothing that I wrote mentions ALL_DIRECTORIES, so this comes from somewhere within the dokka implementation.

I am concerned that the command-line implementation of dokka was not tested thoroughly on Windows.

PROGRESS: Initializing plugins
Loaded plugins: [org.jetbrains.dokka.base.DokkaBase]
Loaded: [
        ExtensionPoint: org.jetbrains.dokka.base.DokkaBase/externalClasslikesTranslator,
        ExtensionPoint: org.jetbrains.dokka.base.DokkaBase/externalDocumentablesProvider,
        ExtensionPoint: org.jetbrains.dokka.base.DokkaBase/immediateHtmlCommandConsumer,
        ExtensionPoint: org.jetbrains.dokka.CoreExtensions/pageTransformer,
        ...
        Extension: org.jetbrains.dokka.base.DokkaBase/psiToDocumentableTranslator,
        Extension: org.jetbrains.dokka.base.DokkaBase/descriptorToDocumentableTranslator,
        Extension: org.jetbrains.dokka.base.DokkaBase/singleGeneration
]
Suppressed: [

]
PROGRESS: Dokka is performing: documentation for edu.citadel.compiler
PROGRESS: Validity check
PROGRESS: Creating documentation models
PROGRESS:
Exception in thread "main" java.lang.NoSuchFieldError: ALL_DIRECTORIES
        at org.jetbrains.jps.model.java.impl.JavaSdkUtil.getJdkClassesRoots(JavaSdkUtil.java:81)
        at org.jetbrains.kotlin.utils.PathUtil.getJdkClassesRootsFromJre(PathUtil.kt:183)
        at org.jetbrains.kotlin.utils.PathUtil.getJdkClassesRootsFromCurrentJre(PathUtil.kt:179)
        at org.jetbrains.kotlin.cli.jvm.config.JvmContentRootsKt.configureJdkClasspathRoots(JvmContentRoots.kt:99)
        at org.jetbrains.dokka.analysis.AnalysisEnvironment.configureJdkClasspathRoots(AnalysisEnvironment.kt:546)
        at org.jetbrains.dokka.analysis.EnvironmentAndFacadeKt.createEnvironmentAndFacade(EnvironmentAndFacade.kt:20)
        at org.jetbrains.dokka.analysis.KotlinAnalysisKt.KotlinAnalysis(KotlinAnalysis.kt:13)
        at org.jetbrains.dokka.base.DokkaBase$defaultKotlinAnalysis$2$1.invoke(DokkaBase.kt:189)
        ...
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

TLDR: in pluginsClasspath, first specify kotlin-analysis-intellij jar and only then kotlin-analysis-compiler jar (you now have it the other way around). This ought to fix the problem.

It turns out, there are two implementations for JavaSdkUtil - one comes from kotlin-analysis-intellij, and one comes from kotlin-analysis-compiler. The one that comes from intellij is the correct one that does not throw errors, and the one that comes from compiler causes the exception.

It seems like by first putting intellij dependency on plugins classpath you’re making it use the correct implementation, whereas if the compiler dependency is first it picks up the wrong one and thus throws the error.

It’s best to submit such bugs to Dokka’s GitHub issues so that this gets noticed sooner, thanks :slight_smile:

1 Like

Thank you for the reply. I will try your suggestion, but you should know that the order of the jar files in my script was copied from https://kotlin.github.io/dokka/1.7.20/user_guide/applying/cli/, so the documentation for using the command-line version of dokka is incorrect.

I tried your suggestion, and now I have a new problem. I tried several variations including the following:

  1. including kotlin-stdlib.jar on the class path using 1.7.10 jar files
  2. including kotlin-stdlib.jar on the class path using 1.7.20 jar files
  3. including kotlin-stdlib.jar on the module path using 1.7.10 jar files
  4. including kotlin-stdlib.jar on the module path using 1.7.10 jar files

No joy yet. My output is shown below. Note the error message that says “module kotlin.stdlib cannot be found in the module graph” followed by what looks like progress and finally a NoClassDefFoundError exception for freemarker/template/Configuration. Any additional suggestions would be appreciated.

PROGRESS: Initializing plugins
Loaded plugins: [org.jetbrains.dokka.base.DokkaBase]
Loaded: [
        ExtensionPoint: org.jetbrains.dokka.base.DokkaBase/externalClasslikesTranslator,
        ExtensionPoint: org.jetbrains.dokka.base.DokkaBase/externalDocumentablesProvider,
        ExtensionPoint: org.jetbrains.dokka.base.DokkaBase/immediateHtmlCommandConsumer,
        ExtensionPoint: org.jetbrains.dokka.CoreExtensions/pageTransformer,
        ...
        Extension: org.jetbrains.dokka.base.DokkaBase/documentableMerger,
        Extension: org.jetbrains.dokka.base.DokkaBase/psiToDocumentableTranslator,
        Extension: org.jetbrains.dokka.base.DokkaBase/descriptorToDocumentableTranslator,
        Extension: org.jetbrains.dokka.base.DokkaBase/singleGeneration
]
Suppressed: [

]
PROGRESS: Dokka is performing: documentation for edu.citadel.compiler
PROGRESS: Validity check
PROGRESS: Creating documentation models
logging: loading modules: [edu.citadel.compiler, java.base, kotlin.stdlib]
error: module kotlin.stdlib cannot be found in the module graph
PROGRESS: Transforming documentation model before merging
PROGRESS: Merging documentation models
PROGRESS: Transforming documentation model after merging
PROGRESS: Creating pages
PROGRESS: Transforming pages
PROGRESS: Rendering
PROGRESS:
Exception in thread "main" java.lang.NoClassDefFoundError: freemarker/template/Configuration
        at org.jetbrains.dokka.base.renderers.html.innerTemplating.HtmlTemplater.<init>(HtmlTemplater.kt:37)
        at org.jetbrains.dokka.base.renderers.html.HtmlRenderer.<init>(HtmlRenderer.kt:42)
        at org.jetbrains.dokka.base.DokkaBase$htmlRenderer$2$1.invoke(DokkaBase.kt:185)
        at org.jetbrains.dokka.base.DokkaBase$htmlRenderer$2$1.invoke(DokkaBase.kt:42)
        at org.jetbrains.dokka.plugability.LazyEvaluated.get$core(LazyEvaluated.kt:8)
        ...
        at org.jetbrains.dokka.DokkaGeneratorKt.access$timed(DokkaGenerator.kt:1)
        at org.jetbrains.dokka.DokkaGenerator.generate(DokkaGenerator.kt:22)
        at org.jetbrains.dokka.MainKt.main(main.kt:427)
Caused by: java.lang.ClassNotFoundException: freemarker.template.Configuration
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 14 more

you should know that the order of the jar files in my script was copied

Yep, we’re actually in the middle of re-writing documentation, that’s how I accidentally found this discussion :sweat_smile: It will be corrected

As for your new problem, since there is no build tool to manage dependencies, you need to provide Dokka’s dependencies yourself. A few versions ago Dokka started using freemarker template engine, and we didn’t realize it affected the CLI runner, somehow integration tests did not catch that.

Download the jar from https://mvnrepository.com/artifact/org.freemarker/freemarker/2.3.31 and pass it in -pluginsClasspath as the last argument in the list. It should work.

Thank you IgnatBeresnev. I was (finally!) able to get dokka working from the command line. But I spent several hours on my own trying to get it to work before my first post, and I spent several more hours trying to get it to work before my second post. And I am an experienced programmer. I repeat my concern from the original post.