JNDI InitialContext problem

I get the error message:

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory. Root exception is java.lang.ClassNotFoundException

I'm guessing the error is arising from:

InitialContext ctx = new InitialContext();

DataSource ds = (DataSource)ctx.lookup("jdbc/MySQL");

I put the path to j2ee.jar in $J2EE_CLASSPATH and $CLASSPATH, still no luck. Can anyone help me out?

[469 byte] By [BobsYourUncle27a] at [2007-9-29 17:18:17]
# 1
Is your datasource identified in your web.xml file?Does the datasource with that name actually exist on the server?
puckstopper31a at 2007-7-15 16:05:10 > top of Java-index,Archived Forums,Java Programming...
# 2

I'm just fiddling around with a basic command line program, not using servlets/jsps so i didn't think web.xml should matter? And I added the datasource using j2eeadmin -addJdbcDataSource, and now i run j2ee -verbose it prints (amoung other things)

Binding DataSource, name = jdbc/MySQL, url = jdbc://Myserv:3306/test

so i figure that's ok.

BobsYourUncle27a at 2007-7-15 16:05:10 > top of Java-index,Archived Forums,Java Programming...
# 3

just noticed i left a bit of the end of the error message (whoops) full message is

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory. Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory

BobsYourUncle27a at 2007-7-15 16:05:11 > top of Java-index,Archived Forums,Java Programming...
# 4
Still having no luck with this :(
BobsYourUncle27a at 2007-7-15 16:05:11 > top of Java-index,Archived Forums,Java Programming...
# 5
From the error, I would be led to believe that your program, whatever it is, is having problems finding the Sun Initial Context Factory class. Is that class available in the classpath?
Jegadisana at 2007-7-15 16:05:11 > top of Java-index,Archived Forums,Java Programming...
# 6
yeah, that class is in the j2ee.jar archive, which is in my classpath.
BobsYourUncle27a at 2007-7-15 16:05:11 > top of Java-index,Archived Forums,Java Programming...
# 7
any other ideas?
BobsYourUncle27a at 2007-7-15 16:05:11 > top of Java-index,Archived Forums,Java Programming...