JCEF: Cannot find startup() method in JBR IDE

Answered

I'm trying to add a WebView (JCEF) as part of a plugin project I'm making. I'm having quite a few issues with it, but I will probably solve most of them. This one I've been working on for hours and still haven't found a fix, so I'm hoping someone here will have some idea.

I have added this to my gradle .kts build file (I think this is the latest JBR IDE version):

runIde {
    setJbrVersion("jbr_jcef-11_0_9_1b1244.2")
}

The IDE launches fine, but when I click the button that should open the WebView, I get the following error:

ERROR - .wm.impl.ToolWindowManagerImpl - Cannot init toolwindow com.example.project.toolWindows.JavaLearnHomeToolWindow@3f9c460e java.lang.NoSuchMethodError: 'boolean org.cef.CefApp.startup()'

(The tool window is completely empty)

When I manually install the plugin via. the settings on my main IDE (2020.3.1), the browser opens fine. So, I'm presuming that the JBR version does not have the correct version of JCEF. I cannot find how to fix this issue. Here is the code for my window, if needed (please note that I have tried with and without my custom scheme handler (which doesn't work either)):

class JavaLearnHomeToolWindowPanel() : SimpleToolWindowPanel(true, false) {

    val browser: JBCefBrowser = JBCefBrowser()
    val browserComponent = browser.component

    init {
        registerAppSchemeHandler()
        browser.loadURL("http://javalearn/index.html")
        browser.openDevtools()
    }

    private fun registerAppSchemeHandler() {
        CefApp.getInstance().registerSchemeHandlerFactory("http", "javalearn", CustomSchemeHandlerFactory())
    }

}

Thanks in advance!

5 comments
Comment actions Permalink

Please share your full build.gradle. Why do you set jbrVersion explicitly?

0
Comment actions Permalink

Here is my full `build.gradle.kts`:

import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.changelog.closure
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.4.21"
// gradle-intellij-plugin - read more:
id("org.jetbrains.intellij") version "0.6.5"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "0.6.2"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
id("io.gitlab.arturbosch.detekt") version "1.15.0"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "9.4.1"
}

// Import variables from gradle.properties file
val pluginGroup: String by project
// `pluginName_` variable ends with `_` because of the collision with Kotlin magic getter in the `intellij` closure.
// Read more about the issue: https://github.com/JetBrains/intellij-platform-plugin-template/issues/29
val pluginName_: String by project
val pluginVersion: String by project
val pluginSinceBuild: String by project
val pluginUntilBuild: String by project
val pluginVerifierIdeVersions: String by project

val platformType: String by project
val platformVersion: String by project
val platformPlugins: String by project
val platformDownloadSources: String by project

group = pluginGroup
version = pluginVersion

// Configure project's dependencies
repositories {
mavenCentral()
jcenter()
}
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.15.0")
}

// Configure gradle-intellij-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName = pluginName_
version = platformVersion
type = platformType
downloadSources = platformDownloadSources.toBoolean()
updateSinceUntilBuild = true

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
setPlugins(*platformPlugins.split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray())
}

// Configure detekt plugin.
// Read more: https://detekt.github.io/detekt/kotlindsl.html
detekt {
config = files("./detekt-config.yml")
buildUponDefaultConfig = true

reports {
html.enabled = false
xml.enabled = false
txt.enabled = false
}
}

tasks {
// Set the compatibility versions to 1.8
withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}

withType<Detekt> {
jvmTarget = "1.8"
}

patchPluginXml {
version(pluginVersion)
sinceBuild(pluginSinceBuild)
untilBuild(pluginUntilBuild)

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription(
closure {
File("./README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").run { markdownToHTML(this) }
}
)

// Get the latest available change notes from the changelog file
changeNotes(
closure {
changelog.getLatest().toHTML()
}
)
}

runPluginVerifier {
ideVersions(pluginVerifierIdeVersions)
}

publishPlugin {
dependsOn("patchChangelog")
token(System.getenv("PUBLISH_TOKEN"))
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html#specifying-a-release-channel
channels(pluginVersion.split('-').getOrElse(1) { "default" }.split('.').first())
}

runIde {
setJbrVersion("jbr_jcef-11_0_9_1b1244.2")
}
}

I am setting it explicitly because the inbuilt version was not working. Both the version that is implicitly run without an explicit version and this explicit version produce the same effect.

Thanks in advance!

0
Comment actions Permalink

Please specify what is

- platformVersion

- platformType

and please copy/paste complete "About" dialog text with info about bundled JBR from the target platform when you run sandbox instance without setting setJbrVersion attribute explicitly.

0
Comment actions Permalink

I'm not sure what `platformVersion` and `platformType` are, but I'm running IntelliJ IDEA Ultimate 2020.3.1 (build #IU-203.6682.168). Here is the "About" dialog text from the bundled version:

IntelliJ IDEA 2020.1 (Community Edition)
Build #IC-201.6668.121, built on April 8, 2020
Runtime version: 11.0.6+8-b765.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 512M
Cores: 4
Registry: ide.browser.jcef.enabled=true
Non-Bundled Plugins: com.github.mcsulphate.javalearn

Important Note: With this bundled version, I get another error:

2021-01-07 18:47:21,632 [ 98414] ERROR - .wm.impl.ToolWindowManagerImpl - Cannot init toolwindow com.github.mcsulphate.javalearn.toolWindows.JavaLearnHomeToolWindow@1b464c67 
java.lang.UnsatisfiedLinkError: no chrome_elf in java.library.path: [C:\Users\Matthew Lester\.gradle\caches\modules-2\files-2.1\com.jetbrains\jbre\jbr-11_0_6-windows-x64-b765.25\jbr\bin (etc, just my path variable)
0
Comment actions Permalink

Please see gradle.properties files for the values of platformVersion and platformType. Please note the exact requirements of enabling/bundling JCEF here https://jetbrains.org/intellij/sdk/docs/reference_guide/jcef.html depending on IDE platform version and chosen JBR.

0

Please sign in to leave a comment.