#1106 FAN_HOME or fan.home for JarDist() bundle?

liamstask Wed 2 Jun 2010

I think my classpath issues are in pretty good shape for the moment, having dropped the requisite jars directly into my JDK ext dir.

I'm still on my mission to run some fantom code within appengine, and my latest stumbling block is that, having created a bundle via JarDist(), I'm getting the following error upon trying to access my FanServlet: http://pastebin.com/1gMV5Jay.

I tried adding a FAN_HOME env variable pointing to the Fantom installation on my system, but got a bunch of file io permission errors, presumably since appengine can't access anything outside its sandbox. So I'm wondering how to ensure that the bundled fantom code can find FAN_HOME or fan.home within itself.

brian Wed 2 Jun 2010

This will be cool once you get it working!

Ideally we want to set the system property "fan.home" to something (even if just "."). Do you have that system property set? Maybe try something like The Environment?

liamstask Wed 2 Jun 2010

Getting closer :) I've set fan.home to . but in this case, fantom doesn't seem to start up properly: http://pastebin.com/v6zaA86q

brian Wed 2 Jun 2010

It shouldn't be trying to open a zip file in JarDist, but rather opening reflection files from the ClassLoader.

You should have the "fan.jardist" System property set to "true".

Looking thru, doesn't appear that stuff is documented as well as it should - I will add some of these notes to the docLang::Env chapter

liamstask Wed 2 Jun 2010

Hah, that did it. I can now spit back some trivial text from a Fantom class that subclasses javax.servlet.http.HttpServlet - pretty cool. A bit more doc would be helpful, but I think I'm off and running for now...thanks again!

Akcelisto Tue 23 Nov 2010

I want use pod as jar in AppEngine. But my call of Fantom from Java is fail.

I build jar:

@Target { help = "build JAR" }
Void jar() {
  dist := JarDist(this){
    outFile = `/D:/Sites/_java/Tabulara/web/WEB-INF/lib/tabulara.jar`.toFile.normalize
    podNames = Str["tabulara","util","web","mustache","concurrent","inet"]
    mainMethod = "tabulara::Tabulara.main"
  }
  dist.run
}

I write in Java (with tabulara.jar in classpath):

public class TestTabulara {
  public static void main(String[] args) throws CacheException {    
    Tabulara tabulara = Tabulara.make();
    System.out.println(tabulara);
  }
}  

But:

ERROR: cannot init Sys.homeDir
java.lang.RuntimeException: Missing fan.home system property or FAN_HOME env var
  at fan.sys.Sys.sysPropToDir(Sys.java:320)
  at fan.sys.Sys.initHomeDir(Sys.java:283)
  at fan.sys.Sys.<clinit>(Sys.java:41)
  at fan.sys.Pod.readFPod(Pod.java:140)
  at fan.sys.Pod.doFind(Pod.java:65)
  at fan.sys.Pod.find(Pod.java:46)
  at fanx.util.TypeParser.find(TypeParser.java:87)
  at fanx.util.TypeParser.load(TypeParser.java:67)
  at fan.sys.Type.find(Type.java:44)
  at fan.tabulara.Tabulara.<clinit>(Tabulara.fan:5)

I dont understand:

  • where I have to add fan.jardist and fan.home
  • what is value of fan.jardist and fan.home

go4 Wed 24 Nov 2010

In java:

System.getProperties().put("fan.jardist", "true");
System.getProperties().put("fan.home", ".");
Sys.boot();
Sys.bootEnv.setArgs(new String[0]);
Env.cur().loadPodClass(Pod.find("compiler"));
Env.cur().loadPodClass(Pod.find("myfan"));
Env.cur().loadPodClass(Pod.find("concurrent"));

but GAE:

<system-properties>
    <property name="fan.jardist" value="true" />
    <property name="fan.home" value="." />
</system-properties>

In fact, I have not tried it. Good luck

Akcelisto Wed 24 Nov 2010

Thanks. This works.

brian Fri 26 Nov 2010

So if that XML file something we can stick into the dist jar file and have GAE automatically pick it up?

Akcelisto Sat 27 Nov 2010

I think JarDist must add this code to init Fantom code:

System.setProperty("fan.jardist", "true");
System.setProperty("fan.home", ".");

This code works in Java and AppEngine if his called before calling Fantom.

brian Sun 28 Nov 2010

The code to set the system properties is generated in the jardist main method.

See JarDist source.

We could potentially pull that out into a static init method?

Login or Signup to reply.