On Mon, Jul 14, 2014 at 2:10 PM, Andrew Carr <andrewlanec...@gmail.com>
wrote:

> Hi,
>
> On this page
> http://tomcat.apache.org/tomcat-8.0-doc/jndi-datasource-examples-howto.html
> there is an example of a global JDBC resource being defined.  There is also
> a comment saying "This author has not had success here, although others
> have reported so. Clarification would be appreciated here."
>

Not sure about the why behind this comment, maybe someone else can comment
on the comment :)

You should be able to define global resources though.  If global resources
don't work for you then it probably due to a configuration error.  Most
often, people forget to add resource links.


>
> I defined the global postgres jdbc definition, and then I add a resource
> link in the two web application contexts that I wanted to use the
> datasource with, and this resolved the issue.
>

Sounds right.


>
> If I did not define the resource links in the context elements I would
> receive an error that the driver was not present.
>

That's correct.  A global resource is not exposed to any applications by
default.  You need to define resource links to indicate which applications
can see a given global resource.


>
> Is this the correct approach to solving this problem?


It's one correct way.  You can also just define a Resource tag directly in
your context.  See here.


http://tomcat.apache.org/tomcat-8.0-doc/config/context.html#Resource_Definitions

The difference being a global resource can be shared across multiple
applications, while a resource defined directly in the context (even in
conf/context.xml) is specific to that application.



>  If so, should I
> document it this way?   Basically:
>
> 1.  Define the global JDBC resource
> 2.  Define the resource references in the contexts you would like to share
> the datasource with.
>

Does this documentation link help to clarify?

http://tomcat.apache.org/tomcat-8.0-doc/jndi-resources-howto.html#Global_configuration

If not and you feel there's room for improvement, I think the general
suggestion is that patches are welcome.

Dan

Reply via email to