• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JBoss JNDI question - very basic

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, now I'm sure this is a fairly simple question but I am having the hardest time finding a simple answer; please help.

I am a relatively new JBoss user, but have experience with Tomcat(6.0.x) and WebSphere (6.1x) - within both of these I have had no problem setting JNDI environment variables but cannot figure out JBoss.

To better illustrate my issue - in Tomcat, I can set a context within the server.xml such as:



where the Resource is the jdbc data source lookup and the Environment is a JNDI string environment lookup.

Now..
Within JBoss I can create a JNDI data source by creating a myapp-ds.xml file within the %JBOSS_HOME%/server/default/deploy/ folder, but cannot figure out how to set the Environment variable (myapp.environment from the example) - any help would be greatly appreciated.

I have jfgi'ed the heck out of this one and unfortunately only come up with ejb answers (I'm not using ejb) and other round about methods that don't seem to work - I'm sure there has to be a really simple answer to this one.


I am using JBoss AS 4.2.2.GA and also just got 6.0.0.M1 to try it out.


Thanks in advance,
Tom
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but cannot figure out how to set the Environment variable (myapp.environment from the example)



I haven't used Tomcat standalone, so my question - What's an environment variable? Is it some property which is a JVM level property and accessible to all applications on the server? Or is it a property per web application? And is your application a web application?
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:
I haven't used Tomcat standalone, so my question - What's an environment variable? Is it some property which is a JVM level property and accessible to all applications on the server? Or is it a property per web application?



Ignore that. I figured it out from the Tomcat docs. The way to achieve the same in JBoss is also mentioned in that doc, see the "Environment Entries" section which says:

For example, you can create an environment entry like this:



This is equivalent to the inclusion of the following element in the web application deployment descriptor (/WEB-INF/web.xml):




Follow the web.xml approach.
 
Tom Esposito
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Jaikiran, for your quick response, but the reason I would like to keep the environment variables on the server and out of the web.xml (or anywhere else inside my code for that matter) is because I would like to be able to keep designated development and production servers where each one may require a different variable. I would not want to be changing my app and rebuilding every time a common variable would need to be changed; I would really prefer to keep the variable within the server if possible.

Please let me know if JBoss has this functionality or if I am doomed to remain a tomcat faithful.


Thanks again for the help,
Tom
 
Tom Esposito
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did find what i was looking for over in ch3 of their docs under section 3.5.1 where they say that it is an addition to the mbean section of some config - but I don't know where this is supposed to go (what xml/file/etc is this supposed to go in - and what section?).



In this, the jndi:binding name is the same as the Environment name and can be looked up the same (from what the doc tells me) but I still cant seem to get this to work.


Thanks again,
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Create a file whose name ends with -service.xml (for example: myapp-service.xml) and copy that entire contents into that file. Place that file in the JBOSS_HOME/server/<servername>/deploy folder. That MBean configured in that file will be deployed by the server when you start it up. Let us know how it goes - i wasn't aware there existed this JNDIBindingServiceMgr.
 
Tom Esposito
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes! that worked!!

with the exception of a few minor modifications of course..

within the MBEAN the xmlns:jndi must be updated to "urn:jboss:jndi-binding-service:1.0" being sure to specify the 1.0 to be compliant with the xsd.



I also had to add the reference to my jboss-web.xml as "resource-env-ref" to distinguish it as an environment variable.


Once that was all done, I was able to start up JBoss and there was my environment entry! Now I get to play and see if I have a new trusty container.


Thanks again for all help!
Tom
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic