#2003 error on linux upon running fantom

kobi Wed 15 Aug 2012

Hi, I am using linux on this computer and try to run fantom, but I get this error:

Error: Could not find or load main class fanx.tools.Fan

I get the same error whether working from a cloned repository or the binaries.

Did I miss a step? Is there a document explaining how to install?

Thanks! kobi

andy Wed 15 Aug 2012

You work thru Setup yet?

kobi Wed 15 Aug 2012

yes

brian Fri 17 Aug 2012

@kobi, did you get it working? It just sounds like sys.jar wasn't in your classpath when you ran java

LightDye Sat 2 Aug 2014

I had the same error trying to run afBedNap but on Mac OS X

$ fan myAfBedNap
[09:21:02 03-Aug-14] [info] [afBedSheet] Starting BedSheet Proxy on port 8069
[09:21:02 03-Aug-14] [info] [web] WispService started on port 8069
[09:21:02 03-Aug-14] [info] [afBedSheet] Cached the timestamps of 57 pods
[09:21:02 03-Aug-14] [info] [afBedSheet] Launching BedSheet WebApp 'myAfBedNap' on port 8070

Error: Could not find or load main class fanx.tools.Fan

I solved this problem copying sys.jar from $FAN_HOME/lib/java to ~/Library/Java/Extensions based on this entry on StackOverflow about adding to the CLASSPATH on OS X.

SlimerDude Sun 3 Aug 2014

Hmm...

From what I can gather, Fantom's bin/fanlaunch (called from fan) should ensure that sys.jar is on the classpath as long as $FAN_HOME is set correctly.

Looking at it, that fanlaunch script does a whole lot more than my basic bash foo can comprehend (and I don't have a Mac OSX to try it on), so I'm not much use I'm afraid. :(

But if the work around works, that's cool!

LightDye Sun 3 Aug 2014

I originally defined my FAN_HOME using export FAN_HOME="~/apps/fantom-1.0.66" but when I tried to run $FAN_HOME/bin/fan -version I got:

-bash: ~/apps/fantom-1.0.66/bin/fan: No such file or directory

Then I redefined FAN_HOME using export FAN_HOME="/Users/coder/apps/fantom-1.0.66" and I was able to run fan -version, however I got the error below when I tried to run a simple afBedNap app. I passed that error copying sys.jar into the Java Extensions folder.

Could not find or load main class fanx.tools.Fan

I'm new to Mac OS X and I'm getting errors that I haven't had in Windows, Ubuntu or Raspbian before. Currently I'm stuck on ERROR: cannot init Sys.homeDir

brian Sun 3 Aug 2014

Probably the easiest way to to debug would be to dump the final shell command that is being run at the end of fanlaunch Bash script.

Also just to be sure, make sure you've done chmod +x on all your bin/ files

LightDye Tue 5 Aug 2014

Thanks Brian for replying. I double-checked and all files in $FAN_HOME/bin are executables.

I also printed the final shell command and everything there looks right to me (sorry, I'm on the go and cannot add it here now). Then I manually ran the command and afBedSheet is initialised but the error occurs half way through, just before my afBedNap app is launched.

I need to investigate this error further, but I don't really know where to start. I need to find what component is throwing the error:

ERROR: cannot init Sys.homeDir
java.lang.RuntimeException: Invalid fan.home dir: "/Users/coder/apps/fantom-1.0.66"

And what exactly means to "init" Sys.homeDir ?

I also thought it could be a permission issue, but all files belong to the accout that I'm using to run the app.

brian Tue 5 Aug 2014

If you look in Sys.java you can see where that error occurs. Unless the dir didn't exist or was a file instead of a dir, not sure why it would fail. Maybe check if you are using symlinks or something weird like that? If you aren't setup to bootstrap build, then email me directly and I can give you a sys.jar that has some extra debug in it.

SlimerDude Tue 5 Aug 2014

Looking at the Java src code, Sys.homeDir is a static field with a static initialiser, so is set whenever the Sys class is referenced - presumably half way through launching the web app.

Following the stacktrace in StackOverflow the offending Java code is:

File f = new File(val);
if (!f.exists() || !f.isDirectory())
  throw new RuntimeException("Invalid " + propKey + " dir: " + f);

Which is pretty inconspicuous.

but the error occurs half way through, just before my afBedNap app is launched.

Half way through? The Sys class is pretty important and is / should be referenced at start up! This is suspect.

Can you start your BedNap app with the following? -

$ fan afBedSheet -env dev myAfBedNap 8069

The default BedNap Main class starts BedSheet with the -proxy setting, which runs a separate Java / Fan program using sys::Process - which could be the issue.

So not running a BedSheet Dev Proxy should fix it. Well, be a work around!

SlimerDude Tue 5 Aug 2014

I'm pretty sure it is the proxy process. From the RuntimeException I would expect the Err msg to be:

Invalid fan.home dir: /Users/coder/apps/fantom-1.0.66

But it's reported as:

Invalid fan.home dir: "/Users/coder/apps/fantom-1.0.66"

Note the double quotes.

It looks like I was taking a cheeky shortcut when it came to launching the proxy Process:

home := Env.cur.homeDir.osPath
args := """java -cp "${home}/lib/java/sys.jar" -Dfan.home="${home}" ..."""
realWebApp = Process(args.split).run

So you can see where the extra double quotes may come from!... :(

My bad. I'll correct this in the next BedSheet release.

LightDye Wed 6 Aug 2014

Thanks SlimerDude, this command worked:

$ fan afBedSheet -env dev myAfBedNap 8069

What I meant by "half way through" was that there were Fantom processes already running (which you can see in the stack trace), so I was pretty sure it wasn't Fantom failing.

Login or Signup to reply.