Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Java Melody Data base monitoring help

Fabio Manzoni
Contributor
March 9, 2018

Hi Guys,

I'm traying to configure Java Melody dabatase monitoring without sucesss. I followed the instructions of Java melody wiki https://github.com/javamelody/javamelody/wiki/AtlassianPlugin.

Also I found this question https://community.atlassian.com/t5/Jira-questions/How-to-configure-Java-Melody-in-JIRA-5-or-6-so-it-does-monitor/qaq-p/7319 without success again.

Can someone help me?

This is a Jira 7.1 and MySQL, its a test envinronment.

server.xml

<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">

<Context path="" docBase="${catalina.home}/atlassian-jira" reloadable="false">
<Resource name="jdbc/jiradb" auth="Container" type="javax.transaction.UserTransaction"
username="xxxx"
password="xxxx"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/jiradb"
maxActive="20"
maxIdle="10"
/>

<Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
<Manager pathname=""/>

<JarScanner scanManifest="false"/>
</Context>

</Host>


dbconfig.xml


<?xml version="1.0" encoding="UTF-8"?>

<jira-database-config>
<name>defaultDS</name>
<delegator-name>default</delegator-name>
<database-type>mysql</database-type>

<jdbc-datasource>
<url>jdbc:mysql://localhost:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=default_storage_engine=InnoDB</url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<username>xxxx</username>
<password>xxxx</password>
<pool-min-size>20</pool-min-size>
<pool-max-size>20</pool-max-size>
<pool-max-wait>30000</pool-max-wait>
<validation-query>select 1</validation-query>
<min-evictable-idle-time-millis>60000</min-evictable-idle-time-millis>
<time-between-eviction-runs-millis>300000</time-between-eviction-runs-millis>
<pool-max-idle>20</pool-max-idle>
<pool-remove-abandoned>true</pool-remove-abandoned>
<pool-remove-abandoned-timeout>300</pool-remove-abandoned-timeout>
<pool-test-on-borrow>false</pool-test-on-borrow>
<pool-test-while-idle>true</pool-test-while-idle>
<validation-query-timeout>3</validation-query-timeout>
<schema-name>public</schema-name>

<jndi-datasource>
<jndi-datasource><jndi-name>java:comp/env/jdbc/jiradb</jndi-name></jndi-datasource>
</jndi-datasource>

</jdbc-datasource>
</jira-database-config>

 

2 answers

1 accepted

0 votes
Answer accepted
Fabio Manzoni
Contributor
March 14, 2018

Hi everyone, 

For configure your Java Melody database monitoring in a SQL Server, take a look on this example.

Dbconfig.xml

 

<?xml version="1.0" encoding="UTF-8"?>

<jira-database-config>
<name>defaultDS</name>
<delegator-name>default</delegator-name>
<database-type>mssql</database-type>
<schema-name>Jira_Schema</schema-name>

<url>jdbc:sqlserver://localhost:1433;databaseName=jiradb</url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<username>xxxxx</username>
<password>xxxxxx</password>
<pool-min-size>20</pool-min-size>
<pool-max-size>20</pool-max-size>
<pool-max-wait>30000</pool-max-wait>

<min-evictable-idle-time-millis>60000</min-evictable-idle-time-millis>
<time-between-eviction-runs-millis>300000</time-between-eviction-runs-millis>
<pool-max-idle>20</pool-max-idle>
<pool-remove-abandoned>true</pool-remove-abandoned>
<pool-remove-abandoned-timeout>300</pool-remove-abandoned-timeout>
<pool-test-on-borrow>false</pool-test-on-borrow>
<pool-test-while-idle>true</pool-test-while-idle>


<jndi-datasource><jndi-name>java:comp/env/jdbc/JiraDS</jndi-name></jndi-datasource>

</jira-database-config>

server.xml

<Context path="" docBase="${catalina.home}/atlassian-jira" reloadable="false" useHttpOnly="true">

<Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
username="xxxxxx"
password="xxxxxx"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;databaseName=jiradb"
maxActive="20"
maxIdle="10"
validationQuery="select 1"

/>

Sylvain Leduc
Contributor
August 10, 2022

Hello @Fabio Manzoni 

So you need to keep both <jdbc-datasource> and <jndi-datasource> in the dbconfig.xml + add the resource in server.xml ?

https://github.com/javamelody/javamelody/wiki/AtlassianPlugin says to replace it : "To configure JIRA with a datasource, replace in the jira-home/dbconfig.xml file "<jdbc-datasource>...</jdbc-datasource>" with "<jndi-datasource>"

Thanks.

Sylvain

0 votes
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 13, 2018

Fabio,

Can you tell us exactly what is not working and error messages that you see? 

Regards,

Shannon

Fabio Manzoni
Contributor
March 13, 2018

Hi Shannon,

Thank you for your attention. It's a test environment and I solved the problem in MySQL database with this information below. But now I try to use the same configuration to Microsoft SQL, but doesn't work. This configurarion enable the data base monitoring on Java Melody. And I will apply this in our costumer.

This Work in MY SQL


Server.xml

<Context path="" docBase="${catalina.home}/atlassian-jira" reloadable="false" useHttpOnly="true">


<Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
username="xxxxxx"
password="xxxxxx"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/jiradb"
maxActive="20"
maxIdle="10"
validationQuery="select 1"
/>

<Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
<Manager pathname=""/>
<JarScanner scanManifest="false"/>
</Context>

dbconfig.xml

<jira-database-config>
<name>defaultDS</name>
<delegator-name>default</delegator-name>
<database-type>mysql</database-type>

<url>jdbc:mysql://localhost:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=default_storage_engine=InnoDB</url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<username>xxxxx</username>
<password>xxxxxx</password>
<pool-min-size>20</pool-min-size>
<pool-max-size>20</pool-max-size>
<pool-max-wait>30000</pool-max-wait>
<validation-query>select 1</validation-query>
<min-evictable-idle-time-millis>60000</min-evictable-idle-time-millis>
<time-between-eviction-runs-millis>300000</time-between-eviction-runs-millis>
<pool-max-idle>20</pool-max-idle>
<pool-remove-abandoned>true</pool-remove-abandoned>
<pool-remove-abandoned-timeout>300</pool-remove-abandoned-timeout>
<pool-test-on-borrow>false</pool-test-on-borrow>
<pool-test-while-idle>true</pool-test-while-idle>
<validation-query-timeout>3</validation-query-timeout>

<jndi-datasource><jndi-name>java:comp/env/jdbc/JiraDS</jndi-name></jndi-datasource>

</jira-database-config>

This Doesn't work on Microsoft SQL

Server.xml

<Context path="" docBase="${catalina.home}/atlassian-jira" reloadable="false" useHttpOnly="true">
<Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
username="xxxxx"
password="xxxxx"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:mssql://localhost:1433/jiradb"
maxActive="20"
maxIdle="10"

/>

<Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
<Manager pathname=""/>
<JarScanner scanManifest="false"/>
</Context>

dbconfig.xml

<?xml version="1.0" encoding="UTF-8"?>

<jira-database-config>
<name>defaultDS</name>
<delegator-name>default</delegator-name>
<database-type>mssql</database-type>
<schema-name>Jira_Schema</schema-name>


<url>jdbc:sqlserver://localhost:1433;databaseName=jiradb</url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<username>xxxxxx</username>
<password>xxxxxx</password>
<pool-min-size>20</pool-min-size>
<pool-max-size>20</pool-max-size>
<pool-max-wait>30000</pool-max-wait>
<validation-query>select 1</validation-query>
<min-evictable-idle-time-millis>60000</min-evictable-idle-time-millis>
<time-between-eviction-runs-millis>300000</time-between-eviction-runs-millis>
<pool-max-idle>20</pool-max-idle>
<pool-remove-abandoned>true</pool-remove-abandoned>
<pool-remove-abandoned-timeout>300</pool-remove-abandoned-timeout>
<pool-test-on-borrow>false</pool-test-on-borrow>
<pool-test-while-idle>true</pool-test-while-idle>

<jndi-datasource><jndi-name>java:comp/env/jdbc/JiraDS</jndi-name></jndi-datasource>

</jira-database-config>

 

Best Regards, 

Fabio

Fabio Manzoni
Contributor
March 13, 2018

This is the message error.

If I remove the java melody information, this instance works very well.

mensagem de erro sql.PNG

Microsoft SQL - Doesn't Work

 

SQL monitoring Microsoft SQL.PNG 

My SQL - Working.

SQL monitoring MY SQL.PNG

Fabio Manzoni
Contributor
March 13, 2018

It Works... 

I did a mistake and put the mssql-jdbc-6.4.0.jre8 file on Jira. It's wrong!

The dbconfig.xml is correctly and the server.xml I did some adjust, see below.

I hope this information can now help other people...

server.xml 
<Context path="" docBase="${catalina.home}/atlassian-jira" reloadable="false" useHttpOnly="true">

<Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
username="xxxxxx"
password="xxxxxx"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;databaseName=jiradb"
maxActive="20"
maxIdle="10"
validationQuery="select 1"

/>

 

Microsoft SQL monitoring working.PNG

Like Damien Davis likes this
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 14, 2018

Hi Fabio!

Thank you for confirming you were able to resolve your issue.

If you'd like, you can put your fix in as a separate Answer (below Suggest an answer) and I can mark it as the accepted answer.

Regards,

Shannon

Fabio Manzoni
Contributor
March 14, 2018

Thank you for your suggestion Shannon. I put  in Suggest an answer.

Administradores January 26, 2022

I have the same problem.
But not for mysql but for postgress
server.xml
<Context path=""
docBase="${catalina.home}/atlassian-jira"
reloadable="false"
useHttpOnly="true">

<Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
username="xxxx"
password="xxxx"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://xxxxxx"
/>

db.config.xml 

 

<jira-database-config>
<name>defaultDS</name>
<delegator-name>default</delegator-name>
<database-type>postgres72</database-type>
<schema-name>public</schema-name>
<jdbc-datasource>
<url>jdbc:postgresql://xxxxxxxxxx</url>
<driver-class>org.postgresql.Driver</driver-class>
<username>xxxx</username>
<password>xxxxx</password>
<pool-min-size>20</pool-min-size>
<pool-max-size>20</pool-max-size>
<pool-max-wait>30000</pool-max-wait>
</jdbc-datasource>
<jndi-datasource>
<jndi-name>java:comp/env/jdbc/jirads</jndi-name>
</jndi-datasource>
</jira-database-config>

 

 

Any suggestions?

Suggest an answer

Log in or Sign up to answer