Here is the exact error:
"exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial"
I belive the code is fine, because it runs with 'ant run' and I think my general config is fine, because I can deploy and run .jsp, but my run configuration must be off.
Can you post the link to the tutorial you are actually following.
The error you are getting is saying that the properties required to initialise the JNDI lookup have not been set. It is not about the classpath to find the bean.
It is likely that the ant script you are using has a file called jndi.properties on the classpath and this will contain the settings.