Java Project performance monitoring and tuning tools-javamelody Learning Summary

Source: Internet
Author: User

1. Introduction:

Javamelody can monitor Java or Java EE application servers in a running environment. It is displayed as a graph: Java memory and Java CPU usage, number of user sessions, JDBC connections, and HTTP requests, SQL requests, JSP pages and Business interface methods (EJB3, Spring, Guice), average execution time, Error percentage, and so on. Charts can be viewed by day, week, month, year, or custom time period.

2. Prepare:

Download Javamelody-1.47.0.jar and Jrobin-1.5.9.1.jar, referenced in the project.

3. Configuration method:

The filter configuration of javamelody is usually added before the first filter to ensure that the filter of the javamelody is first executed

Configure filter in Web. xml:

  <filter>    <filter-name>monitoring</filter-name><filter-class> Net.bull.javamelody.monitoringfilter</filter-class></filter><filter-mapping><filter-name >monitoring</filter-name><url-pattern>/*</url-pattern></filter-mapping><listener ><listener-class>net.bull.javamelody.SessionListener</listener-class></listener>

4. Restart Project: Open link: http://

Now that the basic configuration is complete and you can perform simple performance monitoring, javamelody and Struts2 and Spring3 can also be integrated, which is explained in detail in the following summary.

5. Integration with STRUTS2:

1) Add the following code to the Struts-common.xml:

   <package name= "Default" extends= "Struts-default" >      <interceptors>          <interceptor name= " Monitoring "class=" Net.bull.javamelody.StrutsInterceptor "/>                    <interceptor-stack name=" Mystack ">              <interceptor-ref name= "Monitoring"/>              <interceptor-ref name= "Defaultstack"/>          </ interceptor-stack>      </interceptors>      <default-interceptor-ref name= "Mystack"/>  </ Package>

2) Change the extends in the struts-module name. xml to default, i.e.:

6. Integration with spring

1) Add the following code to the Spring-common.xml:

  <bean id= "Facademonitoringadvisor" class= "Net.bull.javamelody.MonitoringSpringAdvisor" >      <property Name= "Pointcut" >          <bean class= "Org.springframework.aop.support.JdkRegexpMethodPointcut" >              < Property name= "pattern" value= "Mgr.*.*.service"/>          </bean>      </property>  </bean>

7. Monitoring Entities

Add a red statement (must use JavaMelody1.5 and above) at the top of the Persistence.xml file for the entity, such as:

<persistence-unit name= "gxpt-qx-entity" transaction-type= "JTA" >          <provider> Net.bull.javamelody.jpapersistence</provider>          <jta-data-source>java:/mysqlds</ jta-data-source>          <properties>               <!--<property name= "Hibernate.dialect" value= " Org.hibernate.dialect.Oracle10gDialect "/>--              <property name=" Hibernate.dialect "value=" Org.hibernate.dialect.MySQLDialect "/>              <property name=" Hibernate.hbm2ddl.auto "value=" Update "/>              <property name= "Hibernate.show_sql" value= "true"/>          </properties>      

8. View Javamelody

access the directory after adding/javamelody, such as Http://localhost:8080/javamelody.

Java Project performance monitoring and tuning tools-javamelody Learning Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.