Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query reg Tomcat connection pool

 
Sakthivelmurugan Kg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can i run a stand alone java class(but which is included in my web application) to get a datasource for the tomcat connection pool? when i try to run the java cliass(its main method), i am getting the following exception:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

Can someone help me to solve this error?

Thanks & Regards,
Sakthi
 
Tim Holloway
Saloon Keeper
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what you mean by running a stand alone java class. Normally, classes in a web application are invoked by the application server. If you're trying to do something like this:



Then you're not really running "in" the webapp, just using the war as though it was a jar. And, since the JNDI registry is built and controlled by the Tomcat server, but you're not running in the server, there's no registry to be found.
 
Joe Ess
Bartender
Posts: 9319
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've done this kind of thing to get to Weblogic EJB's from stand-alone applications. One has to specify an initial context factory, server URL and server credentials.
I don't know if Tomcat makes it's JNDI accessible like Weblogic does. Google pointed me to this guy who looks like he's got a number of the settings right, but still cannot look up a JNDI resource.
 
Tim Holloway
Saloon Keeper
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, Tomcat doesn't publish its JNDI registry on a port. At least by default. So the only way to get the root context is via the Tomcat internal classpath.

WebLogic would have had problems not publishing its registry, since that's how remote apps lookup the EJBs. Since Tomcat doesn't support EJBs, they don't need that ability.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sakthivelmurugan Kg", please check your private messages for an important administrative matter.

Also, please use real words when posting to the forums. Abbreviations such as "reg" in place of "regarding" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic