miaoyf / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

javamelody unable to collect data (Struts2) - NullPointerException #444

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am trying to configure javamelody in a Struts2 project that contains also 
ejb. The project runs on JBoss 7.1.1 

I have added the javamelody libraries through maven. This step was successful. 

Furthermore i made the required changes in the web.xml and also added the 
required (?) interceptors in the struts.xml file. 

<interceptor name="monitoring" class="net.bull.javamelody.StrutsInterceptor" /> 

and put it on the very top of my stack. 
<interceptor-ref name="monitoring" />

Once t he application is deployed i constantly see the following warning in my 
logs:

WARN  [net.bull.javamelody] (javamelody ) exception while collecting data: 
java.lang.NullPointerException
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:49)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.iterate(RootResourceIterator.java:39)
    at org.jboss.as.jmx.model.ModelControllerMBeanHelper.queryNames(ModelControllerMBeanHelper.java:136)
    at org.jboss.as.jmx.model.ModelControllerMBeanServerPlugin.queryNames(ModelControllerMBeanServerPlugin.java:124)
    at org.jboss.as.jmx.PluggableMBeanServerImpl.queryNames(PluggableMBeanServerImpl.java:280)
    at net.bull.javamelody.MBeans.getTomcatThreadPools(MBeans.java:76) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.TomcatInformations.initMBeans(TomcatInformations.java:145) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.TomcatInformations.buildTomcatInformationsList(TomcatInformations.java:108) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.JavaInformations.<init>(JavaInformations.java:135) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.Collector.collectLocalContextWithoutErrors(Collector.java:292) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.FilterContext$CollectTimerTask.run(FilterContext.java:56) [javamelody-core-1.53.0.jar:1.53.0]
    at java.util.TimerThread.mainLoop(Timer.java:555) [rt.jar:1.7.0_21]
    at java.util.TimerThread.run(Timer.java:505) [rt.jar:1.7.0_21]

I tried to find something on the web, but i could find only this issue: 
https://issues.jboss.org/browse/AS7-4441 .
I removed from my persistence.xml file the property <property 
name="hibernate.cache.region_prefix" value=""/>, but this did not solve the 
issue. 

Furthermore, I am able to access all project-relevant actions without any 
problem. Once i try to access the url: 
http://localhost:8080/<project>/monitoring 
The following exception appears:

12:08:41,068 ERROR 
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/tempProject
].[default]] (http--0.0.0.0-8080-5) Servlet.service() for servlet default threw 
exception: java.lang.NullPointerException
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:49)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.doIterate(RootResourceIterator.java:55)
    at org.jboss.as.jmx.model.RootResourceIterator.iterate(RootResourceIterator.java:39)
    at org.jboss.as.jmx.model.ModelControllerMBeanHelper.queryNames(ModelControllerMBeanHelper.java:136)
    at org.jboss.as.jmx.model.ModelControllerMBeanServerPlugin.queryNames(ModelControllerMBeanServerPlugin.java:124)
    at org.jboss.as.jmx.PluggableMBeanServerImpl.queryNames(PluggableMBeanServerImpl.java:280)
    at net.bull.javamelody.MBeans.getTomcatThreadPools(MBeans.java:76) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.TomcatInformations.initMBeans(TomcatInformations.java:145) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.TomcatInformations.buildTomcatInformationsList(TomcatInformations.java:108) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.JavaInformations.<init>(JavaInformations.java:135) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.MonitoringController.doActionIfNeededAndReport(MonitoringController.java:150) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:343) [javamelody-core-1.53.0.jar:1.53.0]
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:167) [javamelody-core-1.53.0.jar:1.53.0]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]

Please do let me know if you need further information and also if this might be 
a bug or a user error.

Thank you

Original issue reported on code.google.com by BinaryX...@gmail.com on 4 Nov 2014 at 10:12

GoogleCodeExporter commented 8 years ago
This seems to be a bug in JBoss and yes it is probably:
https://issues.jboss.org/browse/AS7-4441

The cause of this bug is probably unrelated to hibernate.cache.region_prefix 
(it may happen for something else) and certainly unrelated to struts.

I suggest that you try with a more recent version of JBoss or Wildfly than 
JBoss 7.1.1.
Is that OK?

Original comment by evernat@free.fr on 4 Nov 2014 at 1:43

GoogleCodeExporter commented 8 years ago
Using another version of JBoss is unfortunately not possible, since this is the 
one specified in our documents. 

Is there any further information/configuration i could provide to exclude a 
misconfiguration ? 

Thank you.

PS. According to javamelody, JBoss 7 is listed as a compatible server. 

Original comment by BinaryX...@gmail.com on 4 Nov 2014 at 2:35

GoogleCodeExporter commented 8 years ago
Yes JBoss 7 is listed as a compatible server, but JBoss bugs are supported by 
JBoss, not here.

Reading again the issue, I am not sure if the bug appeared after adding the 
StrutsInterceptor, or if it was present before.
Otherwise, I don't know what can work around this JBoss issue.

If there is no solution here, can we close this issue?

Original comment by evernat@free.fr on 4 Nov 2014 at 7:16

GoogleCodeExporter commented 8 years ago
Thank you very much for the fast response.

We can surely close the issue if you believe that this is a JBoss bug and not 
some wrong configuration.

From my side, i would like to ask:

1) Is the <interceptor name="monitoring" 
class="net.bull.javamelody.StrutsInterceptor" />  really needed ? 
2) I am deploying an ear file and use EJB. Is there maybe anything else i 
should do for this? Like adding the javamelody dependencies in the EJB package 
instead of the WEB package only ? 
3) Will <async-supported>true</async-supported> make any difference? 
4) In your docs, Section 2. web.xml file, you mention "If your application 
server is compatible with Servlet API 3.0 (like tomcat 7, glassfish v3 or jboss 
6), this paragraph is generally not needed" . What happens if i do finally add  
those lines? Can they have a negative effect? 

Any suggestions, tips, notes will be very helpful.

Thank you again

Original comment by BinaryX...@gmail.com on 5 Nov 2014 at 7:32

GoogleCodeExporter commented 8 years ago
1) No, StrutsInterceptor is optional. If you don't include it, you will not 
have statistics of Struts actions. You only need it, if you want Struts 
statistics besides other statistics.
2) No, nothing else. javamelody dependencies in WEB package is probably enough.
3) "<async-supported>true</async-supported>" will probably make no difference 
in your case. "async-supported" is, in the servlet api, to support asynchronous 
http requests (for example, to push data from the server to the browser).
4) Adding these lines will have no negative effect, and there is code to detect 
this potential case and then to do what's needed to work.

The issue is a jboss bug as said above, so closing this issue here.

Original comment by evernat@free.fr on 13 Nov 2014 at 5:04