Updated Tutorial For Eclipse JCEF
Posted: Tue Apr 12, 2016 5:24 pm
I am trying to run JCEF in Eclipse with Scala for continuity with other programs using network, ETL; etc. My goal is to be able to obtain data over a network that is causing other tools to break while avoiding a memory leak I have been experiencing in Selenium. I was able to get the tool working outside of eclipse. However, before I even get to run the code, a check fails. I tried printing messages in main and my class and they never appear. Is there a way to resolve the following issue with my below listed system specs?
I should also note that I have looked at other posts on this site and Googled, attempting solutions to no avail.
Setup
Also all symlink were made as requested by JCEF's Quick Start Guide and the build tool. I checked and there is data in this files.
Sample Code
class Browser(startUrl : String,commandLineArgs :List[String] = null, useOSR : Boolean = OS.isLinux(), isTransparent : Boolean = false,sleepTimeMillis : Long = 10,ignoreCertificateErrors : Boolean = false) extends JFrame{
println("Generating Handlers")
CefApp.addAppHandler(Handlers.getHandlerAdapter)
private var settings = new CefSettings
settings.windowless_rendering_enabled = useOSR
println("Starting App")
private final val cefApp : CefApp = if(commandLineArgs != null && commandLineArgs.size > 0) CefApp.getInstance(ChromeCommandLineParser.parse(commandLineArgs)) else CefApp.getInstance(settings)
private final val client : CefClient = cefApp.createClient()
private final val browser : CefBrowser = client.createBrowser(startUrl,useOSR, isTransparent)
private final val browserUI = browser.getUIComponent
println("Making Visible")
pack()
setSize(800,600)
setVisible(true)
addWindowListener(Handlers.getDefaultWindowListener(this))
......
OTHER CODE HERE
......
}
object Driver{
def main(args : Array[String]):Unit={
println("Starting")
val br = new Browser("https://www.google.com")
println("Quiting")
br.quit()
}
}
I get the same error with MinFrame.java, written by the JCEF folks.
Error
initialize on Thread[AWT-EventQueue-0,6,main] with library path /path/to/jcef/src/binary_distrib/linux64/bin/lib/linux64
[0412/153531:FATAL:content_main_runner.cc(662)] Check failed: base::allocator::IsAllocatorInitialized().
#0 0x7fb1af87262e base::debug::StackTrace::StackTrace()
#1 0x7fb1af88788b logging::LogMessage::~LogMessage()
#2 0x7fb1b2680860 content::ContentMainRunnerImpl::Initialize()
#3 0x7fb1af77f962 CefContext::Initialize()
#4 0x7fb1af77f75b CefInitialize()
#5 0x7fb1af7329b8 cef_initialize
#6 0x7fb1aa22b914 CefInitialize()
#7 0x7fb1aa1e700f Java_org_cef_CefApp_N_1Initialize
#8 0x7fb1fd015994 <unknown>
System
I should also note that I have looked at other posts on this site and Googled, attempting solutions to no avail.
Setup
- IDE: Eclipse Mars
Jars: Placed in a library known as chromiu. All jars requested by README.txt were added (jogl-all,jogl-all-natives-linux-amd64,jcef,gluegen-rt-natives-linux-amd64,gluegen-rt)
DLL: Placed in jcef.jar
JDK: 1.8.0_77
Scala : 2.11.7
Also all symlink were made as requested by JCEF's Quick Start Guide and the build tool. I checked and there is data in this files.
Sample Code
class Browser(startUrl : String,commandLineArgs :List[String] = null, useOSR : Boolean = OS.isLinux(), isTransparent : Boolean = false,sleepTimeMillis : Long = 10,ignoreCertificateErrors : Boolean = false) extends JFrame{
println("Generating Handlers")
CefApp.addAppHandler(Handlers.getHandlerAdapter)
private var settings = new CefSettings
settings.windowless_rendering_enabled = useOSR
println("Starting App")
private final val cefApp : CefApp = if(commandLineArgs != null && commandLineArgs.size > 0) CefApp.getInstance(ChromeCommandLineParser.parse(commandLineArgs)) else CefApp.getInstance(settings)
private final val client : CefClient = cefApp.createClient()
private final val browser : CefBrowser = client.createBrowser(startUrl,useOSR, isTransparent)
private final val browserUI = browser.getUIComponent
println("Making Visible")
pack()
setSize(800,600)
setVisible(true)
addWindowListener(Handlers.getDefaultWindowListener(this))
......
OTHER CODE HERE
......
}
object Driver{
def main(args : Array[String]):Unit={
println("Starting")
val br = new Browser("https://www.google.com")
println("Quiting")
br.quit()
}
}
I get the same error with MinFrame.java, written by the JCEF folks.
Error
initialize on Thread[AWT-EventQueue-0,6,main] with library path /path/to/jcef/src/binary_distrib/linux64/bin/lib/linux64
[0412/153531:FATAL:content_main_runner.cc(662)] Check failed: base::allocator::IsAllocatorInitialized().
#0 0x7fb1af87262e base::debug::StackTrace::StackTrace()
#1 0x7fb1af88788b logging::LogMessage::~LogMessage()
#2 0x7fb1b2680860 content::ContentMainRunnerImpl::Initialize()
#3 0x7fb1af77f962 CefContext::Initialize()
#4 0x7fb1af77f75b CefInitialize()
#5 0x7fb1af7329b8 cef_initialize
#6 0x7fb1aa22b914 CefInitialize()
#7 0x7fb1aa1e700f Java_org_cef_CefApp_N_1Initialize
#8 0x7fb1fd015994 <unknown>
System
- OS: Ubuntu 16.04 Xenial
JCEF : Latest from bitbucket
CEF Binary Branch : 2623 (just under the development branch)
Java: java 8 oracle at /usr/lib/jvm/java-8-oracle