i'm a newbie and for the couple of days i too was struggling with same prob as the one you've mentioned. Well, i've finally found a way out.
1. DataSource ds = (DataSource) initialContext.lookup("java:/OracleDS");
2. change ur ejb-jar.xml file to include:
3. change ur jboss.xml file to include:
4. Also drop the classes12.jar into the deploy directory
I don't whether this is the most elegant solution around but atleast it works.
thanks, but I don't use Ejb to connect the DataSource, I just want to use an application to get this connection, How can I do this?
In JNDIView, I found "OracleDS" was in java:namespace(not in Global JNDI NameSpcace), my another question is: how Can I put "OracleDS" in Global JNDI NameSpace(not namespace)?
It seems like what you are trying to do is to get a reference to that datasource from 'outside' of JBoss or on a different JVM (I believe that is the proper terminology). That is not possible. You could only get a reference to that datasource from an EJB,JSP,Servlet,etc. that has been deployed on JBoss.
Anyone, please correct me if I am wrong.
You can't get a DataSource from a different VM.
Now I get the answer of my question from you, thank you all. I can use the connection pool in my Ejb, not an application, and I try to return the connection to my client , the JVM tell me that this connection must be Serializable.
I believe it's also not possible to return the connection to a different VM. Returning DataSource + Connection to a different VM is not good practice IMHO. What you should probably do is set up a DataSource on the client side. May I know the reason why you would want to return a connection to the client ? If you need to call a Statement ( Prepared, Callable, etc ) maybe you should delegate the call to a SessionBean or something.