Please note, this tutorial is related to JBoss 5. The next versions of the application server do not use port 1099 for binding interfaces.
A piftall which is sometimes reported in JBoss forums is that JBoss refuses to start up correctly after an ear deployment unit has been added.
javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]
If the problem disappear when you undeploy an application it is likely that you have added a jndi.properties file in the package. The jndi.properties should not be packaged in deployments as it globally changes the jndi configuration. Deployments should setup jndi properties and pass them into new InitialContext(properties) to use a different jndi.
The file jndi.properties is generally used when you connect to jBoss environment from remote resources.
#jboss JNDI properties java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=jnp://localhost:1099 java.naming.factory.url.pkgs=org.jnp.interfaces
Adding to the your deployment interferes with JBoss binding process, so JBoss refuses to start-up. Get rid of it and the problem will disappear!
The same happens if you add the -Djava.naming.provider.url in your run.conf or startup command as this overrides jndi.properties.