2

这是我的设置:

Apache Tomcat:8.0.5

JavaMelody:1.52.0 - 通过 Maven 依赖添加

<dependency>
  <groupId>net.bull.javamelody</groupId>
  <artifactId>javamelody-core</artifactId>
  <version>1.52.0</version>
</dependency>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

<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>

<listener>
    <listener-class>com.something.utils.WebAppInitializer</listener-class>
</listener>

<servlet>
    <servlet-name>jersey-services</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.brightertext.server.services</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
        <param-value>true</param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>jersey-services</servlet-name>
    <url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/static/*</url-pattern>
</servlet-mapping>
</web-app>

该应用程序通过 tomcat-maven-plugin 部署:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
       <url>http://domain.com:8080/manager/text</url>
       <server>tomcat</server>
       <path>/something</path>
    </configuration>
</plugin>

根据 catalina.out,JavaMelody init 似乎没问题:

2014-08-29 14:33:28,675 [localhost-startStop-1] DEBUG net.bull.javamelody - JavaMelody filter init started
2014-08-29 14:33:28,677 [localhost-startStop-1] DEBUG net.bull.javamelody - OS: Mac OS X unknown, x86_64/64
2014-08-29 14:33:28,677 [localhost-startStop-1] DEBUG net.bull.javamelody - Java: Java(TM) SE Runtime Environment, 1.8.0_05-b13
2014-08-29 14:33:28,677 [localhost-startStop-1] DEBUG net.bull.javamelody - Server: Apache Tomcat/8.0.5
2014-08-29 14:33:28,677 [localhost-startStop-1] DEBUG net.bull.javamelody - Webapp context: /something
2014-08-29 14:33:28,678 [localhost-startStop-1] DEBUG net.bull.javamelody - JavaMelody version: 1.52.0
2014-08-29 14:33:28,678 [localhost-startStop-1] DEBUG net.bull.javamelody - JavaMelody classes loaded from: jar:file:/usr/share/apache-tomcat-8.0.5/webapps/something/WEB-INF/lib/javamelody-core-1.52.0.jar!/net/bull/javamelody/
2014-08-29 14:33:28,679 [localhost-startStop-1] DEBUG net.bull.javamelody - Host: Matthiass-MBP.fritz.box@192.168.178.22
2014-08-29 14:33:28,680 [localhost-startStop-1] DEBUG net.bull.javamelody - log listeners initialized
2014-08-29 14:33:28,681 [localhost-startStop-1] DEBUG net.bull.javamelody - datasources found in JNDI: []
2014-08-29 14:33:28,683 [localhost-startStop-1] DEBUG net.bull.javamelody - counters initialized
2014-08-29 14:33:28,703 [localhost-startStop-1] DEBUG net.bull.javamelody - counters data read from files in /usr/share/apache-tomcat-8.0.5/temp/javamelody/something_Matthiass-MBP.fritz.box
2014-08-29 14:33:29,233 [localhost-startStop-1] DEBUG net.bull.javamelody - collect task scheduled every 60s
2014-08-29 14:33:29,276 [localhost-startStop-1] DEBUG net.bull.javamelody - first collect of data done
2014-08-29 14:33:29,277 [localhost-startStop-1] DEBUG net.bull.javamelody - JavaMelody filter init done in 602 ms

如何访问监控页面?既不: http ://domain.com:8080/something/monitoring 也不: http ://domain.com:8080/something/services/monitoring 工作。

4

1 回答 1

0

我通过从 web.xml 中删除以下行来使其工作(见上文):

<servlet-mapping>
   <servlet-name>default</servlet-name>
   <url-pattern>/static/*</url-pattern>
</servlet-mapping>

我将此作为“错误”报告给 JavaMelody 的作者。不确定它是否真的是一个。

https://groups.google.com/forum/#!topic/javamelody/fRPJ7q1KzbA

于 2014-08-30T20:10:32.160 回答