• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Query reg Tomcat connection pool

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 28323
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28323
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic