wood burning stoves 2.0*
The moose likes JBoss/WildFly and the fly likes Need help urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Need help urgent" Watch "Need help urgent" New topic

Need help urgent

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.
M M Islam Chisty

Joined: Aug 31, 2003
Posts: 17
1. First check that your mysql-ds.xml file is configured as follows (assuming that your database name is "XYZ"):
Note the tags <jndi-name> and <connection-url>
(just put DefaultDS rather than jdbc/MySqlDS if you want MySQL as your default database and simply delete the hsqldb-ds.xml file)
2. Within your code, just include the lines:
InitialContext ictx=new InitialContext();
DataSource ds=(DataSource)ictx.lookup("java:comp/env/jdbc/mydb");
Please note the standard enc format "java:comp/env". Also, note that the datasource name format "jdbc/mydb". Don't worry about the "mydb" part, just place any arbitrary name you like with the prefix "jdbc/"
Now deploy the whole thing. I hope it, should work now.
M. M. Islam Chisty
Dhaka, Bangladesh
Email: m_chisty@hotmail.com

M. M. Islam Chisty<br />Sr. J2EE Engineer<br />M&H Informatics<br />Ph. 8802-7121293<br />Dhaka, Bangladesh
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Also, have a look at the JMX console (i don't remember exactly the URL). It helps you a lot to check all your services and MBeans. You should be able to check whether your jdbc is bound or not.

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Natkin Nat

Joined: Oct 09, 2003
Posts: 2
I have similar problem. I checked my mysql-ds.xml - it's ok.
When I'm trying to get dataSource reference the error I get is the following:
javax.naming.NameNotFoundException: comp not bound
My code is as follows:
Context ctx = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/mydb");
As there's no free docs available on this topic (at least I haven't found any), can anyone give me a peace of valuable advice?
One more question. How to redirect output of jboss console in Windows bat file? I cannot check the console output - it's too long.
Natkin Nat

Joined: Oct 09, 2003
Posts: 2
I want to run jboss3.2 with mysql4.0. I've copied the mysql-ds.xml from examples to default/deploy directory, changed <jndi-name> to DefaultDS in this file and removed hsqldb-ds.xml.

The output I have from jboss3.2 startup shows that it starts & binds hypersonic & tries to use hsqldb-ds.xml (which couldn't be found because I removed it).
Is there any configuration file in jboss where i can indicate that i want to use mysql-ds.xml & mysql database instead of hypersonic.
Please, help me to deal with this problem!
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Take a look at the notes available here.
I had to tweak them a bit, but was able to do all of the various activities eventually. Using MySql is covered for the CMP example.
[ October 09, 2003: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
It is sorta covered in the JavaRanch Style Guide.
subject: Need help urgent