JavaMelody映射网址

时间:2016-01-22 11:04:37

标签: java spring mapping servlet-filters java-melody

我尝试在我的spring应用程序中安装Javamelody。我在localhost上配置并可以使用URL访问javamelody:

http://localhost:9080/myapp/stats

服务器:webSphere 7.0和我的web.xml配置是:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="myapp">
    <display-name>myapp</display-name>      
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:net/bull/javamelody/monitoring-spring.xml
            /WEB-INF/applicationContext.xml
        </param-value>
    </context-param>        

    <filter>
        <filter-name>monitoring</filter-name>
        <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
        <init-param>
             <param-name>monitoring-path</param-name>
             <param-value>/stats</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>monitoring</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>       

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
        <listener-class>myapp.web.AppInit</listener-class>
    </listener>

    <listener>
            <listener-class>net.bull.javamelody.SessionListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>javascript</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>page</servlet-name>
        <display-name>page</display-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>unificator</servlet-name>
        <display-name>unificator</display-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>webservicesoap</servlet-name>
        <display-name>webservicesoap</display-name>
        <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>QuartzInitializer</servlet-name>
        <servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>
        <init-param>
            <param-name>shutdown-on-unload</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>start-scheduler-on-load</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>javascript</servlet-name>
        <url-pattern>/validation.js</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>page</servlet-name>
        <url-pattern>/page/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>unificator</servlet-name>
        <url-pattern>/home/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>unificator</servlet-name>
        <url-pattern>/users/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>unificator</servlet-name>
        <url-pattern>/contacts/*</url-pattern>
    </servlet-mapping>  

    <session-config>
        <session-timeout>0</session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>

但生产环境中的此配置无效。如果我去

http://app.gtrwe.dev.corp/myapp/stats

我收到404错误。我的web.xml中也有servlet

我正在寻求有关如何设置的帮助。

提前谢谢。

1 个答案:

答案 0 :(得分:0)

如果没有将servlet映射到/ *或/ monitoring,IBM WebSphere可能会遇到ERROR 404,如上所述here