tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexandre Borgoltz" <alexandre.borgo...@smartjog.com>
Subject Fw: [tomcat 5.5] Reference a JNDI env resource from another env-resource
Date Mon, 29 Nov 2004 14:59:12 GMT
Hi, 

I have developed my own BeanFactory as explained in your JNDI-RESOURCE-HOWTO.

Everything works fine and I can use the corresponding factory successfully. 

But when I try to upgrade it a bit, I'm facing a problem:

I'd like my factory to access a database to update the bean it returns. So I'd like it to
use the datasource I've also configured in server.xml:

<GlobalNamingResources>    <Resource   name="jdbc/oracle/sjogmxf" auth="Container"
               type="javax.sql.DataSource"                 factory="org.apache.commons.dbcp.BasicDataSourceFactory"
                driverClassName="oracle.jdbc.driver.OracleDriver"                 url="jdbc:oracle:thin:@re7:1521:SJOGMXF"
                username="pdi"                password="pdi"                maxActive="20"
               maxIdle="10"                maxWait="-1"    />     <Resource name="infocenter"
auth="Container"                                type="cosmos.infocenter.Infocenter"      
         factory="test.factory.InfocenterFactory"    /></GlobalNamingResources>To
be more precise, I've also added the following ResourceLink in my <Context> declaration:

<ResourceLink name="infocenter" type="cosmos.infocenter.Infocenter" global="infocenter"/>
<ResourceLink name="jdbc/oracle/sjogmxf" type="javax.sql.DataSource" global="jdbc/oracle/sjogmxf"/>

When I try to lookup and use one of these resources directly from the webapps, it just works
great. But if I try to modify my custom factory to make it lookup the datasource, it gets
a NamingException (Comp is not linked to the initial context). 

I suppose this means the initial context is created after the resources are created. Is there
a way to have my custom resource reference another resource (in this case, the datasource)?
Then is there a way to specify the order of loading for resources? (Here I'll need the datasource
to be loaded BEFORE the custom factory...)

I thank you in advance,

Alexandre BORGOLTZ
Head of Technology

SmartJog SA
Phone: +33 (0)1 4996 6324 
Fax: +33 (0)1 4996 6405
Mobile: +33 (0)6 8882 1417
alexandre.borgoltz@smartjog.com



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message