Sounds like you are running this from a separate jvm, ie not inside jboss. If this is so, you need to construct your initial context with environment vaiables like PROVIDER_URL etc, you are doing new InitialContext(), inside the jboss server instance this would work. So
HashMap map = new HashMap(); map.put(Context.PROVIDER_URL, "your url"); .. more values like principal etc Context ctx = new InitalContext(map); ..
try that ..
or you could put a jndi.properties file with these values in your path, that should work