Javamelody从1.42升级到1.58但容器管理的安全性(web.xml)在tomcat8中不起作用,但在tomcat9中它工作正常。如何解决这个问题?
采取以下步骤升级javamelody。
下载javamelody.zip 将位于提供的javamelody.zip文件根目录的文件javamelody.jar和jrobin-x.jar复制到要监视的Web应用程序之战的WEB-INF / lib目录中。
将以下标记放在应用程序的web.xml中。
<filter>
<filter-name>javamelody</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
<async-supported>true</async-supported>
<init-param>
<param-name>authorized-users</param-name>
<param-value>user:pwd</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>javamelody</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
<listener>
<listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>
使用路径WEB-INF / classes / net / bull / javamelody / monitoring-spring.xml中的以下代码创建名为monitoring-spring.xml的文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="monitoringAdvisor" class="net.bull.javamelody.MonitoringSpringAdvisor">
<property name="pointcut">
<bean class="net.bull.javamelody.MonitoredWithAnnotationPointcut"/>
</property>
</bean>
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
<bean id="springDataSourceBeanPostProcessor" class="net.bull.javamelody.SpringDataSourceBeanPostProcessor">
<!--
<property name="excludedDatasources">
<set>
<value>excludedDataSourceName</value>
</set>
</property>
-->
</bean>
<!--
<bean id="wrappedDataSource" class="net.bull.javamelody.SpringDataSourceFactoryBean">
<property name="targetName" value="targetDataSource" />
</bean>
-->
</beans>
文件路径在应用程序的web.xml中配置为context-param,如下所示:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext/**/*.xml classpath:net/bull/javamelody/monitoring-spring.xml</param-value>
</context-param>
And also when open monitoring in tomcat9 the correct and latest version is showing but not in tomcat8 and I am using java 8.
答案 0 :(得分:0)
我遇到了同样的问题(JavaMelody 1.59和Tomcat 8.0.23)。 web.xml中javamelody过滤器的所有init-param设置都不适用。
我必须在应用程序的web.xml中为web-app元素添加版本属性,并将其设置为3.1(版本=&#34; 3.1&#34; )。
的web.xml:
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
<filter>
<filter-name>monitoring</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
<init-param>
<param-name>authorized-users</param-name>
<param-value>user:pwd</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>javamelody</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>
...
</web-app>