This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Help required... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Help required..." Watch "Help required..." New topic

Help required...

Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
I am trying to connect to Jboss3.2 & Mysql 3 .I have modified the mysql-ds.xml such that it now reads
Have pasted the mysql driver in appropriate places.
When I see the web-console i see the jdbc/MySqlDS under jboss.jca.
The log file also shows JNDI name bound to 'java:/jdbc/MySqlDS'
However when i try to use i from the client as:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces" );
Context ctx = new InitialContext(env);
DataSource ds = (DataSource) ctx.lookup("java:/jdbc/MySqlDS");
I get a NameNotBound :jdbc not bound Exception

I also tried this:
DataSource ds = (DataSource) ctx.lookup("jdbc/MySqlDS");
Still i get the same exception.
Please help.
I posted this in the JBoss forum but no one answered
velli fieldman

Joined: Aug 04, 2003
Posts: 6
Maybe this will help,
DataSource ds = (DataSource) ctx.lookup("/jdbc/MySqlDS");
instead of
DataSource ds = (DataSource) ctx.lookup("jdbc/MySqlDS");

A wise man once said: I don't know.
Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Thanks,but it didnt help Still gives the error :
/jdbc not bound Exception
Alan Petersen

Joined: May 17, 2003
Posts: 5
You're doing this within a J2EE component? If so, then you just want to create your Context like this:
Context ctx = new InitialContext()
Then do your JNDI lookup.
Of course, your JNDI lookup should be for a string starting with java:comp/env/ and then you need to define the resource-ref in the deployment descriptor, and the mapping between the ref-name and the JNDI name in the jboss-specific deployment descriptor...
- alan
Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Well,if i try it from within a JSP page,its working,but not from an EJB
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

You can try
public NamingEnumeration listBindings(Name name)
throws NamingException
To list the bindings under jdbc context. I am not sure this will help you.

Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Alan about your reply ,cant i run a simple client (normal java class) doing the look up?Do i have to make an ejb from it?Do i have to package the class files in an ear?I think not.The same code works in Weblogic if I change the naming properties from Jboss's to Weblogic.
I agree. Here's the link:
subject: Help required...
It's not a secret anymore!