我在Tomcat服务器中使用CXF公开Web服务.
我想在JMX中公开一些性能信息,如ResponseTimeFeature提出的那些.
我的cxf-beans.xml文件如下:
<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>
这与CXF JMX page中解释的非常相似.
问题是,当我使用jconsole在[默认地址(服务:jmx:rmi:/// jndi / rmi:// localhost:9913 / jmxrmi)]连接时,我看不到任何性能MBean.我有MyBus的管理信息和里面的服务.但没有关于ResponseTime(即使在对服务进行SOAP-UI负载测试之后).
我在Web应用启动时记录了以下错误:
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]
有人对如何解决这个问题有任何想法吗?
提前致谢.
解决方法:
我终于找到了一个“解决方案”(事实上它只是一个解决方法).
<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>
在JMX控制台的最后,我可以看到以下层次结构.
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
我说解决方法,因为我丢失了一些通常在CXF WebServices MBean上可用的属性(例如状态),并且因为计数器的总线名称不是我设置的.