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.
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.
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 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.
Joined: Jul 28, 2009
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,
Joined: Jul 28, 2009
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.
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.
Joined: Jul 28, 2009
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!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com