Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoInitialContextException

 
amit daundkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends,
i am trying to configure DataSource with JBoss5.
i have a placed the connector jar file in the lib directory and the datasource file in the deploy directory.which is like-

but i get a NoInitialContextException. the code is-


the exception i get is-


please guide me regarding the env variable. which class name is to be specified in this variable and how can i do it?
this may be sounding a dumb question but please reply.

thank you.
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This will get you the InitialContext to lookup the JNDI object if and only if the Java Class that has this line of code deployed onto the Application server.

This will not work without supplying the InitialContextFactory and Provider URL ( Please check JBoss specific parameters and their values) if you have this line of code in a Java class that is running outside Server JVM.
 
amit daundkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Amit,
thank you for the reply.
am i supposed to specify this class name in the environment variable inside the DataSource descriptor(mysql-ds.xml) file?
actually i am doing this for the first time.
as you can see, i have given the JNDI name as MySqlDS.
so what i dont understand is in the code-
,
what is this env variable. or shall i code it simply as-


please reply.
please give me an example if possible.
sorry to bother,
thank you again.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic