#2821 A newbie question about errors in 'demo.fan'

woody Mon 15 Feb 2021

Hello,

I hope everyone stay safe and well in the unprecedented Pandemic.

Recently I stumbled upon Fantom, and very exited about it.

I installed the F4 IDE in my Linux box, together with Zulu OpenJDK8 (https://cdn.azul.com/zulu/bin/zulu8.52.0.23-ca-jdk8.0.282-linux_x64.zip)

Now trying to run a few examples from the fantom official release. While others are working as expected, but I got some errors with demo.fan (fantom-1.0.75/examples/fwt/demo.fan)

F4 IDE->Console tab <terminated> demo.fan [Fantom Script] /app/zulu8/bin/java (Feb, 15..

sys::NullErr: Coerce to non-null

fan.sys.NullErr.makeCoerce (NullErr.java:38)
examples::FwtDemo.instance$init$examples$FwtDemo (demo.fan:638)
examples::FwtDemo.make$ (demo.fan:16)
examples::FwtDemo.make (demo.fan:16)
java.lang.reflect.Method.invoke (Method.java:498)
fan.sys.Method.invoke (Method.java:573)
fan.sys.Method$MethodFunc.callList (Method.java:212)
fan.sys.Type.make (Type.java:246)
fan.sys.ClassType.make (ClassType.java:110)
fan.sys.Type.make (Type.java:236)
fanx.tools.Fan.callMain (Fan.java:185)
fanx.tools.Fan.executeType (Fan.java:147)
fanx.tools.Fan.execute (Fan.java:41)
fanx.tools.Fan.run (Fan.java:308)
fanx.tools.Fan.main (Fan.java:346)

I appended some libs in the build.fan

depends = [
	"sys 1.0",
	"gfx 1.0",
	"fwt 1.0",
	"concurrent 1.0"
]

Java is also an alien language to me(mostly C, HDL like Verilog/VHDL :-), I'm trying to get a clue what I'm missing here.

It would be much appreciated if someone in this forum helps me out.

BTW, Is there any plan to bundle swt.jar to the next official release for the fan.platform: linux-x86_64? (F4 IDE has it by default: f4/plugins/com.xored.f4.fantom_1.0.74.202005161116/fantom/lib/java/ext/linux-x86_64/swt.jar)

Best, woody

SlimerDude Mon 15 Feb 2021

Hi Woody,

The offending line in demo.fan is:

File scriptDir  := File.make(this.typeof->sourceFile.toStr.toUri).parent

Which tells me demo.fan it is expecting to be run as a Fantom script (from from the cmd line), not as a proper pod project which F4 runs Fantom as.

That variable scriptDir does not seem to be used anywhere, so just try commenting out that line (demo.fan:638) and try again.

As for SWT for linux 64, probably not any time soon... here's a post from 12 years ago asking the same!

A couple of (slightly) more recent download links are available from the article FWT on 64-Bit Platforms - but it sounds like you've already got that sorted.

Have fun, Steve.

woody Wed 17 Feb 2021

Hello Steve,

Thanks for the tip!

However, I met another error: sys::Err: org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]

org.eclipse.swt.SWT.error (Unknown)
org.eclipse.swt.browser.Mozilla.initMozilla (Unknown)
org.eclipse.swt.browser.Mozilla.create (Unknown)
org.eclipse.swt.browser.Browser.<init> (Unknown)

I'm not the only one, https://stackoverflow.com/questions/7130980/swt-browser-no-more-handles-error

I think this is an environmental issue, the shipped version of SWT/XULrunner might be a culprit.

I'll be hanging around a bit more on this.

By the way, I've enjoyed your short video clips/articles about the awesome language, Fantom/ F4 IDE. All is really helpful and fun!

Thank you so much.

Best, woody

woody Wed 17 Feb 2021

Further testing ended up with core dump:

# # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x0000000000000000, pid=848239, tid=0x00007fa93d4bc640 # # JRE version: Java(TM) SE Runtime Environment (8.0_172-b11) (build 1.8.0_172-b11) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.172-b11 mixed mode linux-amd64 compressed oops) # Problematic frame: # C 0x0000000000000000 # # Core dump written. Default location: /home/woody/f4workspace/Examples/core or core.848239 # # An error report file with more information is saved as: # /home/woody/f4workspace/Examples/hs_err_pid848239.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug.

--

Just for record, I'd gone through the following steps:

  1. A similar issue that I found

https://www.ibm.com/support/pages/help-application-fails-start-red-hat-enterprise-linux

Symptom

In addition to the blank dialog, one of the following errors may appear in the log (<user home>/rcphelp/workspace/.metadata/.log):

org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]
org.eclipse.swt.SWTError: No more handles [MOZILLA_FIVE_HOME='/usr/lib/mozilla'] (java.lang.UnsatisfiedLinkError: no swt-mozilla-gtk-3452 or swt-mozilla-gtk in swt.library.path, java.library.path or the jar file)
  1. As a WA, I installed XULrunner(the latest one is xulrunner-41.0.2, but it lacks a few shared objects(libxpcom, libxul), so I checked every versions backwardly, then xulrunner-20.0.1 is the one ;-)

ldd /home/woody/.swt/lib/linux/x86_64/libswt-mozilla-gtk-4236.so

linux-vdso.so.1 (0x00007ffc19bb0000)
libxpcom.so => not found

http://ftp.mozilla.org/pub/xulrunner/releases/20.0.1/sdk/xulrunner-20.0.1.en-US.linux-x86_64.sdk.tar.bz2

  1. but still some shared object missing, like /usr/lib64/firefox/libmozsqlite3.so from Firefox 78.7.0esr (64-bit)

ok all library-missing-errors gone,

but finally core dumped regardless of JDK used; with Oracle JDK1.8.0/JRE1.8.0(hotspot), and with Azul Zulu8 JDK, too.

  1. my setup

$ tree -L 1 /app /app ├── _f4 ├── f4ide # F4 IDE ├── f4.sh ├── _fan ├── fantom # not used, but copied the examples of fwt demo ├── hotspot8 # Oracle hotspot JRE ├── lost+found ├── xulrunner └── zulu8 # Azul zulu8 JDK

The environment variables I set:

$ $ cat /app/_f4 #!/bin/sh

#JAVA_HOME=/app/zulu8 JAVA_HOME=/app/hotspot8 F4_HOME=/app/f4ide

# stop flickering ; or env SWT_GTK3=0 F4 & SWT_GTK3=0 unset GTK_IM_MODULE MOZILLA_FIVE_HOME=/app/xulrunner

PATH=$JAVA_HOME/bin:$F4_HOME:$PATH LD_LIBRARY_PATH=$MOZILLA_FIVE_HOME/lib:/lib64/firefox

export JAVA_HOME F4_HOME SWT_GTK3 MOZILLA_FIVE_HOME PATH LD_LIBRARY_PATH

Run:

$ cat /app/f4.sh #!/bin/sh

. /app/_f4 env SWT_GTK3=0 F4 -clean &

-- The end of the story today.

The bottom line is that the Eclipse seemed to have hard-coded Web libs(XULrunner), which is not available from the latest offering of 78ESR version in 2021 Simply version got incompatible.

Linux box used is Mageia 8.0rc Plasma.

The end of story, but I can try it again in a Windows box later.

Best woody

SlimerDude Wed 17 Feb 2021

Hi Woody,

That sounds like quite the rabbit hole you went down there! I develop on Windows so I'm afraid I'm not much help here.

But are you trying to use the bundled fwt::WebBrowser or still just running demo.fan?

If using WebBrowser, that did have some issues, even on Windows, but I fixed them in my own Browser widget in the Reflux library. I believe you should be able to use afReflux::Browser widget as a drop in replacement for fwt::WebBrowser (without actually using Reflux) - but it's been a whilte since I tried it.

woody Thu 18 Feb 2021

Hello Steve,

Yes, I'm trying out the bundled demo.fan. It's just for sanitiy check. I would like make sure the basic function should work in my Linux box.

While it's still failing on F4 IDE, I'm happy to report that it's working now with commandline of the official latest fantom release.

I'm writing this inside the demo after logging into this forum.

the title of window : 'FWT Demo' -> 'WebBrowser' tab -> address: 'http://fantom.org' Enter to Go!

It's pretty amazing!

I start to think that I should introduce this SUPER COOL Fantom language to my kids as their first programming language.

Interesting read:

https://fantom.org/forum/topic/355

Thank you all for making this masterpiece All kudo goes to Brian, Andy, Steve and all other contributors!

I feel I'm a bit late to the party ;-)

Best, woody

I'm learning a bit about Pandoc :-)

Login or Signup to reply.