#2901 Fantom Launcher Initialization Error in LXC Container - Need Assistance

arif Tue 12 Dec 2023

Hello,

I'm experiencing an issue with the Fantom Launcher (version 1.0.76.29) in a minimal Ubuntu LXC container (Linux-aarch64, Java 11.0.19, OpenJDK 64-Bit Server VM by Ubuntu). When running fan -version, I encounter a NullPointerException that prevents Sys.curEnv from initializing. The same setup works fine on my Ubuntu desktop, suggesting a possible missing component in the container environment.

Key Details:

  • Error encountered when executing fan -version.
  • Set FAN_ENV=util::PathEnv with no effect.
  • Suspect missing elements in the minimal LXC container environment (not evident in printenv).

Error Trace:

root@ubuntu-bionic-Container:~# fan -version Fantom Launcher Copyright (c) 2006-2021, Brian Frank and Andy Frank Licensed under the Academic Free License version 3.0

Java Runtime:
java.version:    11.0.19
java.vm.name:    OpenJDK 64-Bit Server VM
java.vm.vendor:  Ubuntu
java.vm.version: 11.0.19+7-post-Ubuntu-0ubuntu118.04.1
java.home:       /usr/lib/jvm/java-11-openjdk-arm64
WARN: cannot init Sys.curEnv
sys::NullErr: java.lang.NullPointerException
at fan.sys.Err.make(Err.java:36)
at fan.sys.Method.invoke(Method.java:584)
at fan.sys.Method$MethodFunc.call(Method.java:266)
at fan.sys.Method.call(Method.java:141)
at fan.sys.Sys.initEnv(Sys.java:475)
at fan.sys.Sys.<clinit>(Sys.java:236)
at fan.sys.Env.<clinit>(Env.java:20)
at fanx.tools.Fan.version(Fan.java:230)
at fanx.tools.Fan.run(Fan.java:291)
at fanx.tools.Fan.main(Fan.java:346)
fan.platform:    linux-aarch64
fan.version:     1.0.76.29
fan.env:         sys::BootEnv
fan.home:        /

Has anyone faced a similar issue or can offer insights into what might be missing or how to debug this further in a minimal LXC container setup?

Thanks in advance for any help!

SlimerDude Wed 13 Dec 2023

Hi @arfi193, what do you mean by minimal container?

That section of the stacktrace is trying to instantiate a PathEnv class in the util pod. Is the util pod available in your minimal setup?

See Sys.initEnv().

arif Wed 13 Dec 2023

Hi @SlimerDude

Thanks for your response. By "minimal container," I'm referring to a container setup using LXC/Docker that includes only essential packages like BusyBox, Linux-utils, net-tools, etc. My objective is to run a Fantom application in a lightweight container environment. I've successfully integrated OpenJDK into this container. However, when I add Fantom to the container, I encounter the error previously mentioned, despite the same Fantom setup running smoothly on my regular Ubuntu system.

Regarding the stack trace and the PathEnv class in the util pod: From what I understand, the system checks for the FAN_ENV variable in the environment. If it's not present, it defaults to using bootEnv, right? It seems like my container might be missing a critical file, possibly a props file? I'm not deeply familiar with the intricacies of Fantom, so this is a bit of guesswork on my part.

Any insights or suggestions on what specific file or setting might be missing in my minimal container setup would be greatly appreciated.

brian Wed 13 Dec 2023

It probably can't find lib/fan/util.pod. I would say likely its because it doesn't know where fan.home is because in your dump it thinks fan.home is "/". So it might have to do with the bin/fanlaunch bash script not being able to figure out where {home}/bin is (based on the script file itself) and then from there determining fan home.

arif Thu 14 Dec 2023

Interestingly, touch /ets/sys/log.props resolves my issue.

@Container-bbv3:~# touch /etc/sys/log.props 
@Container-bbv3:~# fan -version
Fantom Launcher
Copyright (c) 2006-2021, Brian Frank and Andy Frank
Licensed under the Academic Free License version 3.0

Java Runtime:
  java.version:    11.0.4
  java.vm.name:    OpenJDK 64-Bit Server VM
  java.vm.vendor:  Alpine
  java.vm.version: 11.0.4+4-alpine-r1
  java.home:       /usr/lib/jvm/java-11-openjdk
  fan.platform:    linux-aarch64
  fan.version:     1.0.76.29
  fan.env:         util::PathEnv
  fan.home:        /

Env Path:
  / (work) (home)

To clarify: The latest version does not experience this problem. This remains the case even though Fantom is active and functioning on an independent squashfs mount, whether it's an older or newer version. Moreover, all modifications are made in a separate overlayfs, mounted using an ext4 loop file. It's possible that this issue may be linked to certain file permission concerns.

SlimerDude Fri 15 Dec 2023

I can't say I fully understand why that works, but I'm pleased it does! :)

Jay Herron2 Sat 16 Dec 2023

@arif Not sure if this is relevant to you, but Fantom does vend base Docker images for each build, available here: https://github.com/fantom-lang/fantom/pkgs/container/fantom

You could use the repo's Dockerfile as a reference for your own setup if using a different environment.

arif Wed 20 Dec 2023

Thank you all initially my problem stemmed from file permissions. The Java binary was unable to access property files in the /etc directory, which were mounted on a squashfs partition. I resolved this during the container creation process with the following workaround: find /etc -type f -exec touch {} \;.

@Jay: Your suggestion was appreciated. My Fantom build is integrated into a third-party software, so updating it independently wasn't feasible. However, considering your approach for future updates is indeed a valuable idea. Thanks once more.

Login or Signup to reply.