• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Accessing GlobalNamingResources values through JDNI

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



I am trying to access this value, set in server.xml, at runtime.

Somehow I am meant to use something like:



but I always get an exception.

Can anyone help?

John
 
Saloon Keeper
Posts: 24310
167
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
You are repeating yourself on directory levels. Try this:

 
John Farrel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I did as you suggested and still got this exception:

"Name [configDirectory] is not bound in this Context. Unable to find [configDirectory]."

I am debugging tomcat through netbeans... might there be an issue there?
 
Tim Holloway
Saloon Keeper
Posts: 24310
167
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

John Farrel wrote:
I am debugging tomcat through netbeans... might there be an issue there?



There shouldn't. There something fundamentally wrong with any webapp that care what IDE you're using.

I think actually you are probably missing the web.xml definition of this resource that gets paired to the Tomcat context override.
 
John Farrel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Also tried this with no success:



 
John Farrel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:

John Farrel wrote:
I am debugging tomcat through netbeans... might there be an issue there?



There shouldn't. There something fundamentally wrong with any webapp that care what IDE you're using.

I think actually you are probably missing the web.xml definition of this resource that gets paired to the Tomcat context override.



I see, I think.

I can't access the global settings unless I also map them in web.xml to the local context?

I am trying to avoid that... is there any other way to do this?

 
John Farrel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe I should explain what I'm trying to do.

We run multiple webapps on the one tomcat instance. They are all running the same war (renamed), but each context has it's own .ini settings.

I am going to set the global value to a directory, then pick up the .ini file for the context based on the context name.

The contexts running on any one tomcat instance may change over time, so I don't want to have to keep creating/editing other .xml files for this to work.

My fallback is that I get the directory path from an environment variable instead.
 
Tim Holloway
Saloon Keeper
Posts: 24310
167
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 can't recommend environment variables for webapps. They're not a good fit, as they're targeting the entire JVM, not the app.

What you are proposing is nothing I haven't done. However, I never did see what you did to WEB-INF/web.xml to define the JNDI variable's prototype/default.
 
Ranch Hand
Posts: 75
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I can't access the global settings unless I also map them in web.xml to the local context?
I am trying to avoid that... is there any other way to do this?



If a resource has been defined in a Context element it is not necessary for that resource to be defined in /WEB-INF/web.xml
If it's defined outside Context element, web.xml entry is required, otherwise your app can't see this resource.

 
John Farrel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

K. Gil wrote:

I can't access the global settings unless I also map them in web.xml to the local context?
I am trying to avoid that... is there any other way to do this?



If a resource has been defined in a Context element it is not necessary for that resource to be defined in /WEB-INF/web.xml
If it's defined outside Context element, web.xml entry is required, otherwise your app can't see this resource.



So, to be clear, there's no way to define a resource in server.xml that is available to all contexts without also defining a link to that resource in each web.xml then?
Seems like pointless double handling to me... but if that's the way it is so be it.
 
We noticed he had no friends. So we gave him this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic