File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Query reg Tomcat connection pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Query reg Tomcat connection pool" Watch "Query reg Tomcat connection pool" New topic
Author

Query reg Tomcat connection pool

Sakthivelmurugan Kg
Greenhorn

Joined: Aug 07, 2009
Posts: 3
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

Joined: Jun 25, 2001
Posts: 16014
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8867
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

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

Joined: Jan 10, 2002
Posts: 61010
    
  65

"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

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: Query reg Tomcat connection pool