Bug 1201273 - Tomcat 7 datasources are not discovered if defined in server.xml file
Summary: Tomcat 7 datasources are not discovered if defined in server.xml file
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugins
Version: 4.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: RHQ Project Maintainer
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On: 1201269
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-12 12:47 UTC by bkramer
Modified: 2017-11-02 13:07 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-11-02 13:07:55 UTC
Embargoed:


Attachments (Terms of Use)

Description bkramer 2015-03-12 12:47:17 UTC
Description of problem:
Tomcat 7 datasources are not discovered if defined in server.xml file. At the same time, datasources will be properly discovered when defined in the context.xml file.

It seems that the problem is in the name of the MBean that tomcat plugin expects to see:

- if datasource is defined using server.xml file, the MBean name will be: Catalina:type=DataSource,class=javax.sql.DataSource,name="jdbc/mysql";

- if datasource is defined using context.xml file, the MBean name is: Catalina:type=DataSource,context=/examples,host=localhost,class=javax.sql.DataSource,name="jdbc/mysql"

Version-Release number of selected component (if applicable):
- RHQ 4.9
- Tomcat 7
- RHQ plugins for tomcat

How reproducible:
Always

Steps to Reproduce:
1. Install and start RHQ
2. Download, install  and configure Tomcat server; 
3. Install RHQ plugin for tomcat;
3. Define datasource in the context.xml file - for instance add the following Resource inside Context:

***********************
...
<Context>
...
    <Resource auth="Container"
              name="jdbc/mysql"
              type="javax.sql.DataSource"
              driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/test"
              username="userName" password="password" />
</Context>
***********************
4. Save the file, restart the Tomcat;
5. Navigate to the RHQ UI -> Tomcat Servers -> Tomcat instance -> Tomcat Virtual Hosts -> localhost -> Tomcat Web Application (WAR)s -> example and there should be Tomcat Datasoruces with the "jdbc/mysql" discovered;
6. Shutdown Tomcat instance and uninventory it from the JBoss ON UI;
7. Delete Resource configuration (given in the step 3 above) from context.xml and instead add the following in the context.xml file:
***********************
<Context>
...
<ResourceLink name="jdbc/mysql" 
              global="jdbc/mysql"
              auth="Container"
              type="javax.sql.DataSource" />
</Context>
***********************
   
Above Resource configuration add to the Tomcat's server.xml file:

***********************
<GlobalNamingResources>
...
    <Resource auth="Container"
              name="jdbc/mysql"
              type="javax.sql.DataSource"
              driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/test"
              username="userName" password="password" />
</GlobalNamingResources>
***********************
and save the file.
8. Start Tomcat server again and let RHQ Agent discover it;

Actual results:
No datasource is discovered

Expected results:
Globally defined datasources should be discovered.


Additional info:

Comment 1 Larry O'Leary 2017-11-02 13:07:55 UTC
The fix for this seems to have been done back in April 2015... just cleaning things up a bit.

commit 10f72b3dae0d51d0db4dc5e3156da743f40867a1
Merge: c3b9a23740 22f60241ba
Author: Libor Zoubek <lzoubek>
Date:   Wed Apr 29 20:42:25 2015 +0200

    Merge pull request #167 from maximebeck/master
    
    Fix BZ 1201269

commit 22f60241baca485ce6c06fa0ff250a89457471af (refs/pull/origin/167)
Author: maximebeck <maxbeck>
Date:   Wed Apr 29 15:12:03 2015 +0200

    Fix BZ 1201269


Note You need to log in before you can comment on or make changes to this bug.