aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Help required..." Watch "Help required..." New topic
Author

Help required...

Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Hi,
I am trying to connect to Jboss3.2 & Mysql 3 .I have modified the mysql-ds.xml such that it now reads
<jndi-name>jdbc/MySqlDS</jndi-name>
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);
System.out.println(ctx);
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
Greenhorn

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");
Grtz,
Velli


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
Greenhorn

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: 8919

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.


Groovy
Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Hi,
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.
Still
 
 
subject: Help required...