It works fine from the command line, connects to the remote host, looks up the JMS queue and the ConnectionFactory and receives messages just fine.
As soon as I put this same code inside a webapp, suddenly I get this sort of thing whenever I try to lookup the "ConnectionFactory" :
NAM0004: Exception during name lookup : {0}
com.sun.enterprise.connectors.ConnectorRuntimeException: This pool is not bound in JNDI : ConnectionFactory