You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jakub 1983 <jj...@gmail.com> on 2013/04/18 04:26:41 UTC

explanation of resource-ref in web.xml

What the hell is <resource-ref> in web.xml used for ?

My imagination is as follows, please confirm or deny it.


<resource-ref> is part of servlet spec, not tomcat spec.
context.xml and it's resource declaration is private concept of tomcat, not
described by any external specificatin, jsr, etc.


<resource-ref> says, that in your webapp you can lookup such type by such
name with jndi.
in case of tomcat application can run without it, <Resource ...> in
context.xml is sufficient, but in other servlet containers it can be
different, and they may require <resource-ref> declaration.

regards
Jakub

Re: explanation of resource-ref in web.xml

Posted by Jakub 1983 <jj...@gmail.com>.
Konstantin,
thx for your reply.

Do you know name of such a tool and application server which offers
configuration of database connection on basis of web.xml.resource-ref ?

regards
Jakub


On Thu, Apr 18, 2013 at 11:05 AM, Konstantin Kolinko <knst.kolinko@gmail.com
> wrote:

> 2013/4/18 Jakub 1983 <jj...@gmail.com>:
> > I have tried google, but this links don't explain me, eg 4 states
> >
> > <resource-ref>
> >   <res-ref-name>jdbc/primaryDB</res-ref-name>
> >   <jndi-name>jdbc/PrimaryDBInTheContainer</jndi-name></resource-ref>
> >
> > I have already tried it, and it doesn't work.
> >
> > In my opinion <resource-ref> is useless under tomcat,
> >
> > or better said, it has only informative value, at least in case of
> > database connection.
> >
>
> Yes, it has only informative value.
>
> E.g. if you have to deploy your web application to some other web
> server, not Tomcat, and you have to use a tool to do such deployment,
> this element says that your application needs a database connection.
> Thus the tool will offer you to configure one.
>
> Configuration of connection itself is always server-specific. Thus it
> is in context.xml, not web.xml.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: explanation of resource-ref in web.xml

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/4/18 Jakub 1983 <jj...@gmail.com>:
> I have tried google, but this links don't explain me, eg 4 states
>
> <resource-ref>
>   <res-ref-name>jdbc/primaryDB</res-ref-name>
>   <jndi-name>jdbc/PrimaryDBInTheContainer</jndi-name></resource-ref>
>
> I have already tried it, and it doesn't work.
>
> In my opinion <resource-ref> is useless under tomcat,
>
> or better said, it has only informative value, at least in case of
> database connection.
>

Yes, it has only informative value.

E.g. if you have to deploy your web application to some other web
server, not Tomcat, and you have to use a tool to do such deployment,
this element says that your application needs a database connection.
Thus the tool will offer you to configure one.

Configuration of connection itself is always server-specific. Thus it
is in context.xml, not web.xml.

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


Re: explanation of resource-ref in web.xml

Posted by Jakub 1983 <jj...@gmail.com>.
I have tried google, but this links don't explain me, eg 4 states

<resource-ref>
  <res-ref-name>jdbc/primaryDB</res-ref-name>
  <jndi-name>jdbc/PrimaryDBInTheContainer</jndi-name></resource-ref>

I have already tried it, and it doesn't work.

In my opinion <resource-ref> is useless under tomcat,

or better said, it has only informative value, at least in case of
database connection.




On Thu, Apr 18, 2013 at 4:58 AM, Howard W. Smith, Jr. <
smithh032772@gmail.com> wrote:

> On Wed, Apr 17, 2013 at 10:38 PM, Leo Donahue - RDSA IT <
> LeoDonahue@mail.maricopa.gov> wrote:
>
> >
> > ________________________________________
> > From: Jakub 1983 [jjakub83@gmail.com]
> > Sent: Wednesday, April 17, 2013 7:26 PM
> > To: Tomcat Users List
> > Subject: explanation of resource-ref in web.xml
> >
> > What the hell is <resource-ref> in web.xml used for ?
> > ********************************************
> >
> > I use it in a context, to define a <Resource> such as a database
> > connection.
> >
> > There is an example here:
> >
> http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example
> >
> >
> I saw your first email to the list, and then after your 2nd separate email
> to the list, I searched google for the following:
>
> tomcat resource-ref web.xml [1]
>
> and found many search results that should get you on your way. Of which, I
> found [2], [3], [4], [5]
>
>
> [1] http://lmgtfy.com/?q=tomcat+resource-ref+web.xml
> [2] http://www.mulesoft.com/tomcat-mysql
> [3]
> http://www.mkyong.com/tomcat/how-to-configure-mysql-datasource-in-tomcat-6/
> [4]
>
> http://stackoverflow.com/questions/2887967/what-is-resource-ref-in-web-xml-used-for
> [5]
>
> http://stackoverflow.com/questions/9078511/resource-ref-usage-in-web-xml-with-tomcat-5-5-and-spring
>

Re: explanation of resource-ref in web.xml

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Wed, Apr 17, 2013 at 10:38 PM, Leo Donahue - RDSA IT <
LeoDonahue@mail.maricopa.gov> wrote:

>
> ________________________________________
> From: Jakub 1983 [jjakub83@gmail.com]
> Sent: Wednesday, April 17, 2013 7:26 PM
> To: Tomcat Users List
> Subject: explanation of resource-ref in web.xml
>
> What the hell is <resource-ref> in web.xml used for ?
> ********************************************
>
> I use it in a context, to define a <Resource> such as a database
> connection.
>
> There is an example here:
> http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example
>
>
I saw your first email to the list, and then after your 2nd separate email
to the list, I searched google for the following:

tomcat resource-ref web.xml [1]

and found many search results that should get you on your way. Of which, I
found [2], [3], [4], [5]


[1] http://lmgtfy.com/?q=tomcat+resource-ref+web.xml
[2] http://www.mulesoft.com/tomcat-mysql
[3]
http://www.mkyong.com/tomcat/how-to-configure-mysql-datasource-in-tomcat-6/
[4]
http://stackoverflow.com/questions/2887967/what-is-resource-ref-in-web-xml-used-for
[5]
http://stackoverflow.com/questions/9078511/resource-ref-usage-in-web-xml-with-tomcat-5-5-and-spring

Re: explanation of resource-ref in web.xml

Posted by Jakub 1983 <jj...@gmail.com>.
I have tried, and definig only <Resource> in context.xml is sufficient,
<resource-ref> in web.xml was commented, but I still could acces database
connection from jndi.


On Thu, Apr 18, 2013 at 4:38 AM, Leo Donahue - RDSA IT <
LeoDonahue@mail.maricopa.gov> wrote:

>
> ________________________________________
> From: Jakub 1983 [jjakub83@gmail.com]
> Sent: Wednesday, April 17, 2013 7:26 PM
> To: Tomcat Users List
> Subject: explanation of resource-ref in web.xml
>
> What the hell is <resource-ref> in web.xml used for ?
> ********************************************
>
> I use it in a context, to define a <Resource> such as a database
> connection.
>
> There is an example here:
> http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: explanation of resource-ref in web.xml

Posted by Leo Donahue - RDSA IT <Le...@mail.maricopa.gov>.
________________________________________
From: Jakub 1983 [jjakub83@gmail.com]
Sent: Wednesday, April 17, 2013 7:26 PM
To: Tomcat Users List
Subject: explanation of resource-ref in web.xml

What the hell is <resource-ref> in web.xml used for ?
********************************************

I use it in a context, to define a <Resource> such as a database connection.

There is an example here:  http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example  


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