-
1. Re: Extremely basic JNDI question
dbronk Aug 9, 2007 12:20 PM (in response to dbronk)Sorry, I guess some of the xml got removed... here it is again but with some spaces so it does not get removed.
This is the tomcat, easy, setup...
< Context path="/myApp" ... >
< !-- Datasource -->
< Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" / >
.... all the normal datasource params ...
< !-- My Bean -->
< Resource name="rps/RPSClient"
auth="Container"
type="com.myco.rps.RPSClient"
factory="org.apache.naming.factory.BeanFactory"
location="localhost" / >
< / Context> -
2. Re: Extremely basic JNDI question
peterj Aug 9, 2007 12:24 PM (in response to dbronk)I guess some questions come in threes, but to access a data source using the ENC, see http://www.jboss.com/index.html?module=bb&op=viewtopic&t=115556
Not sure about the custom pojo, maybe someone else knows. -
3. Re: Extremely basic JNDI question
dbronk Aug 9, 2007 12:41 PM (in response to dbronk)Thanks for the very fast reply. I looked at that thread and not sure that is going to give me what I want. I'm assuming that in the thread you pointed me to there would be a someds-ds.xml in the deploy directory of JBoss. That xml will point to the database. The problem now comes in that since you have a war file with the web.xml and jboss-web.xml in it, you now can not simply copy/paste that same war file from someApp.war to someAppQA.war. Well, I'm sure the app will come up, but it will point to the same someds-ds.xml file, thus pointing to the same database. I want my someds-ds.xml to really be something like someContext-someds-ds.xml. ie: someApp-someds-ds.xml, someAppQA-someds-ds.xml. The contents would be the same, except for the actual database pointing to, uid/pw, etc. But the name would be the same name. This way, I have zero reconfiguring of my application when I promote through the different environments. The code always looks for "java:comp/env/ds/SomeDS", but each will pull from the appropriate someApp-someds-ds.xml.
This is easy as pie in Tomcat.
Thanks again. -
4. Re: Extremely basic JNDI question
stevev Aug 14, 2007 9:12 AM (in response to dbronk)I'm having a very similar problem; multiple web contexts sharing a war file, each using distinct data.
I solved the problem slightly differently in Tomcat stand alone. Each context is given a unique key via JNDI that it uses to select the relevant rows of a shared database. But I think we're looking for the same thing: a way to set up each web context with it's own InitialContext.
I've been doing some digging and as far as I can see there doesn't seem to be a way to achieve this in JBoss (I would gladly be proved wrong).
I'm looking at MBeans at the moment. Would it be possible to configure the JNDI for each web context with MBeans?
Thanks,
Steve -
5. Re: Extremely basic JNDI question
stevev Aug 16, 2007 10:12 AM (in response to dbronk)Before I continue looking for a way to initialise a name space for each web context maybe I should be asking whether there is one in the fist place.
So does anyone know whether each web context is given it's own JNDI name space?
Thanks,
Steve -
6. Re: Extremely basic JNDI question
waynebaylor Aug 16, 2007 10:20 AM (in response to dbronk)each web context should have its own ENC. so, for a given WAR file you can define "java:comp/env/..." lookups in its web.xml/jboss-web.xml.
-
7. Re: Extremely basic JNDI question
dbronk Aug 16, 2007 10:30 AM (in response to dbronk)This unfortunately does not satisfy my needs. I'll go about it in a different way. But, this is extremly easy to do in Tomcat so I thought it would be easy to do in JBoss. But, we have found other issues moving from Tomcat to JBoss with JNDI also. Placing data sources in Tomcat we find them by looking up "java:comp/env/....". Move the same app to JBoss and add a xxxxx-datasource.xml to JBoss, and it will not find it when we lookup "java:comp/env/....". We need to remove the "java:comp/env/" portion of our lookup... not very portable portability.
-
8. Re: Extremely basic JNDI question
jaikiran Aug 16, 2007 10:34 AM (in response to dbronk)"dbronk" wrote:
Placing data sources in Tomcat we find them by looking up "java:comp/env/....". Move the same app to JBoss and add a xxxxx-datasource.xml to JBoss, and it will not find it when we lookup "java:comp/env/....". We need to remove the "java:comp/env/" portion of our lookup... not very portable portability.
That's not correct. You can have the datasources available in the java:comp/env/ namespace. All you have to do is, add a resource-ref entry in your web.xml and jboss-web.xml files. Let us know if you want more details on this. -
9. Re: Extremely basic JNDI question
stevev Aug 24, 2007 5:13 AM (in response to dbronk)waynebaylor wrote:
each web context should have its own ENC. so, for a given WAR file you can define "java:comp/env/..." lookups in its web.xml/jboss-web.xml.
That's true. But if each war file is being shared by multiple web contexts then they all share the same ENC. Is there a way to set up each web context with it's own unique ENC?
Ideally this would not be inside the war file (like jboss-web.xml is) so that it can be edited easily.
Thanks,
Steve -
10. Re: Extremely basic JNDI question
waynebaylor Aug 26, 2007 2:20 PM (in response to dbronk)not that i know of :(
-
11. Re: Extremely basic JNDI question
stevev Sep 3, 2007 5:17 AM (in response to dbronk)Thanks Wayne.
Do you know whether a web contexts ENC can be set up dynamically with MBeans under JBoss. I know that Tomcat has pretty good MBeans support and in stand alone mode this can be done, but as far as I know JBoss handles Tomcat's JNDI when it's embedded.
Any thoughts?
Steve