Patrik Mihalčin
Patrik Mihalčin

Reputation: 4031

View Tomcat's JNDI tree

Given I have context.xml with Resource definitions and I copy it to /usr/local/tomcat/conf/context.xml

How can I check that Resources were created as expected?

Is there any way how to view JNDI tree after context.xml is applied?

Upvotes: 3

Views: 4076

Answers (1)

Andreas
Andreas

Reputation: 159135

If you want to see what is going on inside Tomcat, you should enable JMX.
See Monitoring and Managing Tomcat 8.5.

You can then connect using the jconsole command that comes with Java, where you can see the Resources available to each of the webapps running in that Tomcat instance.

I personally never put Data Sources <Resource> elements in the context.xml file, but instead put them in server.xml and then put <ResourceLink> elements in the context's XML file (not .../conf/context.xml, but .../conf/Catalina/localhost/mywebapp.xml).

This allows multiple webapps running in the same Tomcat instance to share the database connection pool(s).

So in my instance, I can see the Resource Links for my webapp (from mywebapp.xml) below the /Catalina/ResourceLink/Context node, and the Resources (from server.xml) below the /Catalina/Resource/Global node.

I can also see the Data Sources below the /Catalina/DataSource/javax.sql.DataSource node.

enter image description here

Upvotes: 7

Related Questions