but they probably apply to something different from Glassfish Enterprise Edition 3.0... googling around I understand that one should use com.sun.appserv.naming.S1ASCtxFactory as a Initial Context Factory,
but I could not find this class anywhere in the NetBeans and Glassfish jar files...

let's face it, Ant is great but it's a pain in the butt when it comes to writing complex code, with variables, loops, conditions etc.

That's why I love the idea of running Ant tasks directly from Java.

Here is how.

The trick is to bear in mind the Ant object model: A Project contains Targets, a Target contains Tasks. A Task can't run without a Project, otherwise you get a NPE (my compliments to Ant developers for handling so gracefully this exception :o) ).

Of course you can build a "Ant Wrapper" framework on top of this paradygm...