Stupid question, but have you tried casting it to a DataSource? If you are getting a ClassCastException when you try to do a JNDI lookup, it is usually a classpath issue. Try including all of the JARs from the client directory in your classpath and remove any J2EE jars that weren't distributed with the version of JBoss that you're using.
Thanks for getting back to me. I finally figured this out, it was what you mentioned. I had to remove all other J2EE jar files and include jboss-j2ee.jar in the classpath. The problem was I had two different versions of javax.sql.DataSource in the classpath.
Thanks for the help!
Another cause that I've seen is when you try to cast the return value of the JNDI lookup on an EJB to the bean type rather than the interface type.
//This works GreeterRemote myGreeter = (GreeterRemote) ctx.lookup("GreeterBean/remote"); // This doesn't work (throws "ClassCastException: $Proxy0") GreeterBean myGreeter = (GreeterBean) ctx.lookup("GreeterBean/remote");
Of course, you shouldn't be doing the second one, because the client should only be dealing with the remote interface.