Javamelody with Struts 2 . No action mapped for monitoring

自作多情 提交于 2021-02-11 12:10:36

问题


I got a Struts 2 , Java 8 web application running on Wildfly 10 and wanted to integrate Javamelody but i am unable to access the monitoring page no matter my configuration in the web.xml and struts.xml

I use the following maven dependency

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

In my web.xml (web-app version="3.0" ) i have the following configuration:

<filter>
    <filter-name>monitoring</filter-name>
    <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
    <async-supported>true</async-supported>
</filter>
<filter-mapping>
    <filter-name>monitoring</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ASYNC</dispatcher>
</filter-mapping>
<listener>
    <listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>

In my struts configuration following

<interceptor-stack name="myStack">
    <interceptor-ref name="monitoring"/>
    <interceptor-ref name="defaultStack"/>
</interceptor-stack>

and set myStack as default

<default-interceptor-ref name="myStack" />

When i try to access http://localhost:8080/myapp/monitoring i get following error: [org.apache.struts2.dispatcher.Dispatcher] (default task-3) Could not find action or result: There is no Action mapped for namespace / and action name monitoring. - [unknown location]

I cannot find many resources on the web concerning this issue or configuration with Struts . Any ideas ?

Note: I am one step closer, but i don't get why this is happening. I had to remove all filter that had a url-pattern /* for this to work. Is there a workaround on this? Of course with this configuration i cannot access any of my pages anymore.


回答1:


The javamelody user's guide says to write the javamelody MonitoringFilter in WEB-INF/web.xml before your servlet. But in the case of Struts 2, there is no more servlet and Struts 2 is controlled by a filter.

So you have to write the javamelody MonitoringFilter in WEB-INF/web.xml before your Struts 2 filter.



来源:https://stackoverflow.com/questions/56391102/javamelody-with-struts-2-no-action-mapped-for-monitoring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!