#2704 Program works in F4 but fails in console

jhughes Wed 20 Jun

I am currently utilizing the java logging system and have stumbled on a very weird behavior when run via fantom.

I put a stack dump in the constructor of a custom FileHandler to help track the issue. Also, both stack traces below are truncated for readability but are identical up until the parts shown.

Scenario 1: I run the program from F4 IDE

Stack trace showing success of my constructor from the stack dump

java.lang.Exception: Stack trace
 at java.lang.Thread.dumpStack(Unknown Source)
 at com.kodaro.log.KodaroFileHandler.<init>(KodaroFileHandler.java:48)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at java.lang.Class.newInstance(Unknown Source)
 at java.util.logging.LogManager$5.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.util.logging.LogManager.loadLoggerHandlers(Unknown Source)

Scenario 2: I run the program from the command line:

Fails to load the FileHandler at the same point in the code and this is the error being thrown.

java.lang.ClassNotFoundException: com.kodaro.log.KodaroFileHandler
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.util.logging.LogManager$5.run(LogManager.java:965)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.util.logging.LogManager.loadLoggerHandlers(LogManager.java:958)

SlimerDude Wed 20 Jun

Hmm... it's going to be something environmental, so I'd check what your FAN_HOME is in each, and then check what Java libs are being loaded.

F4 doesn't do any magic when running Fantom programs, it just launches a Java process via the standard eclipse runtime configurations. It does, however, ensure that pods of any open Fantom projects are included in the Env. But it seems your problem is more Java based than Fantom.

jhughes Wed 20 Jun

From the console:

C:\Fantom\fantom-1.0.69\bin>fan -version Fantom Launcher Copyright (c) 2006-2013, Brian Frank and Andy Frank Licensed under the Academic Free License version 3.0

Java Runtime:

java.version:    1.8.0_45
java.vm.name:    Java HotSpot(TM) 64-Bit Server VM
java.vm.vendor:  Oracle Corporation
java.vm.version: 25.45-b02
java.home:       C:\Program Files\Java\jdk1.8.0_45\jre
fan.platform:    win32-x86_64
fan.version:     1.0.69
fan.env:         sys::BootEnv
fan.home:        C:\Fantom\fantom-1.0.69

Not sure where I check similar information from the IDE. Also not sure how I would tell fantom to change how it loads the java libraries. Everything is in the same /lib/java/ext directory when running from F4 or the console.

Login or Signup to reply.