You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sasha Borodin <sa...@whoissasha.com> on 2003/10/14 00:14:32 UTC

Declaring resources - web.xml vs. server.xml

I've Googled and read the documentation without producing a definitive
answer to this question: exactly what IS the purpose of declaring resources
in web.xml?

OK, I've got a GlobalNamingResource set up:

    <Resource auth="Container" name="jdbc/DataTrac" scope="Shareable"
        type="javax.sql.DataSource"/>

    <ResourceParams name="jdbc/DataTrac">
        ... All of my parameters ...
    </ResourceParams>

Then I've got a ResourceLink in my Context definition:

    <ResourceLink global="jdbc/DataTrac" name="jdbc/DataTrac"
        type="javax.sql.DataSource"/>

----------------

Now, Tomcat documentation states that I also need the following in my
web.xml file:

    <resource-ref>
        <res-ref-name>jdbc/DataTrac</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

Why???  Everything works WITHOUT this entry.  And everything works WITH it
as well.  So my question, again, is what is the purpose of declaring
resources in web.xml - to (for some reason) complement the resource
definitions in server.xml, to replace them, or what?

Thank you for your help.

-Sasha Borodin


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Declaring resources - web.xml vs. server.xml

Posted by Sasha Borodin <sa...@whoissasha.com>.
Thanks for your quick feedback.

So, according to the Servlet spec, I need to declare my resource needs in
web.xml; then it's up to the container to provide those resources, and the
spec says that is configured via <ResourceParams/> in the server's
configuration?  Or is that bit Tomcat specific as well?

I think the fact that I was using a GlobalNamingResource was clouding the
issue; if I wanted this DataSource to be available only to this app, I could
supply declaration in web.xml, and configuration in the <Context> OR both
the resource declaration and configuration in the <Context> (but the latter
would be non-portable).  Is this correct?

Thank you again.

-Sasha

On 10/13/03 17:24, "Aleksandr Shneyderman" <al...@law.columbia.edu> wrote:

> 
> ResourceLink is the Tomcat's way of doing JNDI, so
> if you port your app on some other server, the deployer
> will not even know what is wrong if you do not have
> that entry in your web.xml, because this is the only thing
> that gets to be moved around (server.xml is not)
> 
> Looks a bit redundant but it is there for protability.
> I do not see any other reasons for it being there otherwise.
> 
> Alex.
> 
>> -----Original Message-----
>> From: Sasha Borodin [mailto:sasha@whoissasha.com]
>> Sent: Monday, October 13, 2003 5:15 PM
>> To: Tomcat Users List
>> Subject: Declaring resources - web.xml vs. server.xml
>> 
>> 
>> I've Googled and read the documentation without producing a definitive
>> answer to this question: exactly what IS the purpose of declaring
>> resources
>> in web.xml?
>> 
>> OK, I've got a GlobalNamingResource set up:
>> 
>>     <Resource auth="Container" name="jdbc/DataTrac" scope="Shareable"
>>         type="javax.sql.DataSource"/>
>> 
>>     <ResourceParams name="jdbc/DataTrac">
>>         ... All of my parameters ...
>>     </ResourceParams>
>> 
>> Then I've got a ResourceLink in my Context definition:
>> 
>>     <ResourceLink global="jdbc/DataTrac" name="jdbc/DataTrac"
>>         type="javax.sql.DataSource"/>
>> 
>> ----------------
>> 
>> Now, Tomcat documentation states that I also need the following in my
>> web.xml file:
>> 
>>     <resource-ref>
>>         <res-ref-name>jdbc/DataTrac</res-ref-name>
>>         <res-type>javax.sql.DataSource</res-type>
>>         <res-auth>Container</res-auth>
>>     </resource-ref>
>> 
>> Why???  Everything works WITHOUT this entry.  And everything works WITH it
>> as well.  So my question, again, is what is the purpose of declaring
>> resources in web.xml - to (for some reason) complement the resource
>> definitions in server.xml, to replace them, or what?
>> 
>> Thank you for your help.
>> 
>> -Sasha Borodin
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Declaring resources - web.xml vs. server.xml

Posted by Aleksandr Shneyderman <al...@law.columbia.edu>.
ResourceLink is the Tomcat's way of doing JNDI, so
if you port your app on some other server, the deployer
will not even know what is wrong if you do not have
that entry in your web.xml, because this is the only thing
that gets to be moved around (server.xml is not)

Looks a bit redundant but it is there for protability.
I do not see any other reasons for it being there otherwise.

Alex.

> -----Original Message-----
> From: Sasha Borodin [mailto:sasha@whoissasha.com]
> Sent: Monday, October 13, 2003 5:15 PM
> To: Tomcat Users List
> Subject: Declaring resources - web.xml vs. server.xml
>
>
> I've Googled and read the documentation without producing a definitive
> answer to this question: exactly what IS the purpose of declaring
> resources
> in web.xml?
>
> OK, I've got a GlobalNamingResource set up:
>
>     <Resource auth="Container" name="jdbc/DataTrac" scope="Shareable"
>         type="javax.sql.DataSource"/>
>
>     <ResourceParams name="jdbc/DataTrac">
>         ... All of my parameters ...
>     </ResourceParams>
>
> Then I've got a ResourceLink in my Context definition:
>
>     <ResourceLink global="jdbc/DataTrac" name="jdbc/DataTrac"
>         type="javax.sql.DataSource"/>
>
> ----------------
>
> Now, Tomcat documentation states that I also need the following in my
> web.xml file:
>
>     <resource-ref>
>         <res-ref-name>jdbc/DataTrac</res-ref-name>
>         <res-type>javax.sql.DataSource</res-type>
>         <res-auth>Container</res-auth>
>     </resource-ref>
>
> Why???  Everything works WITHOUT this entry.  And everything works WITH it
> as well.  So my question, again, is what is the purpose of declaring
> resources in web.xml - to (for some reason) complement the resource
> definitions in server.xml, to replace them, or what?
>
> Thank you for your help.
>
> -Sasha Borodin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org