Failed to activate CXF ResponseTimeFeature

I host a web service using CXF inside a Tomcat server. I would like to show some performance data in JMX, similar to the one suggested by ResponseTimeFeature.

My cxf- beans.xml file looks like this:

<cxf:bus bus="cxf" id="MyBus"> <cxf:properties> <entry key="bus.jmx.enabled" value="true" /> </cxf:properties> </cxf:bus> <bean id="CounterRepository" class="org.apache.cxf.management.counters.CounterRepository"> <property name="bus" ref="cxf" /> </bean> <jaxws:endpoint id="analyserEndpoint" implementor="#analyserImpl" address="/analyser"> <jaxws:features> <bean class="org.apache.cxf.management.interceptor.ResponseTimeFeature" /> </jaxws:features> </jaxws:endpoint> 

This is very similar to what is described in the CXF JMX page .

The problem is that when I connect using jconsole to [the default address (service: jmx: rmi: /// jndi / rmi: // localhost: 9913 / jmxrmi)], I do not see any MBean performance. I have MyBus management information and a service inside. But nothing about ResponseTime (even after loading the SOAP-UI test through the service).

I have the following error registered when starting a web application:

 2012-09-10 15:13:19,692 ERROR org.apache.cxf.management.jmx.InstrumentationManagerImpl - Could not start JMX connector server : java.io.IOException: Cannot bind to URL [rmi://localhost:9913/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi] 

Does anyone have any ideas on how to solve this problem?

Thanks in advance.

+4
source share
1 answer

I finally found a β€œsolution” (actually this is just a workaround).

 <cxf:bus bus="MyBus" id="MyBus" name="MyBus"> <cxf:properties> <entry key="bus.jmx.enabled" value="true" /> <entry key="bus.jmx.persistentBusId" value="MyBus" /> <entry key="bus.jmx.usePlatformMBeanServer" value="true" /> <entry key="bus.jmx.createMBServerConnectorFactory" value="false" /> </cxf:properties> </cxf:bus> <bean id="CounterRepository" class="org.apache.cxf.management.counters.CounterRepository"> <property name="bus" ref="MyBus" /> </bean> <jaxws:endpoint id="analyserEndpoint" implementor="#analyserImpl" address="/analyser"> <jaxws:features> <bean class="org.apache.cxf.management.interceptor.ResponseTimeFeature" /> </jaxws:features> </jaxws:endpoint> 

At the end of the JMX console, I see the following hierarchy.

 org.apache.cxf Bus MyBus Operations shutdown Notifications Performance.Counter.Server cxf+random_number "WebServiceServiceNameAsAQName" "WebServicePortName" Attributes NumInvocations AvgResponseTime MaxResponseTime MinResponseTime NumCheckedApplicationFaults NumLogicalRuntimeFaults NumRuntimeFaults NumUnCheckedApplicationFaults TotalHandlingTime Operations reset "WebServiceMethodName" Attributes (same as above, per method) Operations reset 

I am talking about a workaround since I lost some attributes that are commonly available in CXF WebServices MBeans (like state), and since the bus name for the counter is not the one I created.

+1
source

Source: https://habr.com/ru/post/1433369/


All Articles