camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Vas Dias (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-8939) org.apache.camel.management.mbean.ManagedCamelContext is not an MXBean
Date Tue, 07 Jul 2015 12:14:04 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-8939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14616585#comment-14616585
] 

Jason Vas Dias commented on CAMEL-8939:
---------------------------------------

And here is the patch, in its entirety: 

$ diff -U0 ./camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java~
./camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
--- ./camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java~
     2012-12-18 20:41:04.000000000 +0000
+++ ./camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
      2015-07-07 13:01:03.586390634 +0100
@@ -29,0 +30 @@
+import javax.management.MXBean;
@@ -48,0 +50 @@
+@MXBean(true)

The apache-camel build with this change to the source from: 
   http://repo.fusesource.com/nexus/content/groups/public/org/apache/camel/apache-camel/2.10.0.fuse-71-047/apache-camel-2.10.0.fuse-71-047-src.zip
builds and passes all tests .


> org.apache.camel.management.mbean.ManagedCamelContext is not an MXBean
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-8939
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8939
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-activemq
>    Affects Versions: 2.10.0
>         Environment: JDK 1.6 , Linux x86_64
> apache-activemq-5.7.0.fuse-71-047 
> apache-camel-2.10.0.fuse-71-047
> spring-framework-*-3.1.2-RELEASE
>            Reporter: Jason Vas Dias
>
> It appears to be impossible to use Camel as a JmsConsumer of queues served by
> apache-activemq of the above versions because it always tries to register its
> CamelContext as an MXBean, but the ManagedCamelContext class is not an 
> MXBean nor can it be coerced into one.
> There does not seem to be any way to override the class used for the camelContext
> to make it into an MXBean (add the '@MXBean' annotation or make its class name
> end with 'MXBean' ),  yet Camel is internally trying to register an instance of the
> ManagedCamelContext as an MXBean:
> Here is a stack trace produced by a debugger of Camel in this situation:
> "main"@1 in group "main": RUNNING
> Exception: Class org.apache.camel.management.mbean.ManagedCamelContext is not a JMX compliant
MXBean
> findMXBeanInterface():94, MXBeanSupport {com.sun.jmx.mbeanserver}
> getMXBeanInterface():308, Introspector {com.sun.jmx.mbeanserver}
> checkCompliance():150, Introspector {com.sun.jmx.mbeanserver}
> registerMBean():305, DefaultMBeanServerInterceptor {com.sun.jmx.interceptor}
> registerMBean():483, JmxMBeanServer {com.sun.jmx.mbeanserver}
> registerMBeanWithServer():313, DefaultManagementAgent {org.apache.camel.management}
> register():222, DefaultManagementAgent {org.apache.camel.management}
> In registerMBeanWithServer we see the bean it is trying to register is 
> the 'camelContext' bean defined in my camel context spring XML file :
> obj = {org.apache.camel.management.mbean.ManagedCamelContext@5199} 
>  context = {org.apache.camel.spring.SpringCamelContext@5196} "SpringCamelContext(camelContext)
with spring id org.springframework.context.support.ClassPathXmlApplicationContext@7fd88db7"
> ...
> name = {javax.management.ObjectName@5200} "org.apache.camel:context=jvasdias/camelContext,type=context,name="camelContext""
>  _canonicalName = {java.lang.String@5360} "org.apache.camel:context=jvasdias/camelContext,name="camelContext",type=context"
> Here is the defining XML of this object:
> <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
>         <packageScan>
>             <package>${MY_PACKAGE}</package>
>         </packageScan>
>         <routeContextRef ref="myRoute1"/>
>         ....
>         <routeContextRef ref="myRouteN"/>
>         <!--Endpoint queues -->
>         <endpoint id="incomingQueue"
>                   uri="activemq:queue:IncomingQueue/>
>         <endpoint id="deadletterQueue"
>                   uri="activemq:queue:DeadletterQueue"/>
>         <endpoint id="retryQueue"
>                   uri="activemq:queue:RetryQueue"/>
>         ....
> </camelContext>
> I have set up a JmsListener in another XML file:
>   <bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver"
>           p:jndiTemplate-ref="jndiTemplate"
>           p:cache="true"/>
>     <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager"
>           p:connectionFactory-ref="connectionFactory"/>
>     <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
>         <property name="environment">
>             <props>
>                 <prop key="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</prop>
>                 <prop key="java.naming.provider.url">QueueConnectionFactory</prop>
>             </props>
>         </property>
>     </bean>
> and I have set the property 'cpp-server.jms.jndi.provider.url' to the 
> 'tcp:localhost:61616' socket address on which the ActiveMQ JMX Broker listens.
>     <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
>         <property name="connectionFactory" ref="connectionFactory"/>
>         <property name="defaultDestinationName" value="${cpp-server.jms.queue.incoming}"/>
>         <property name="receiveTimeout" value="300"/>
>     </bean>
>     <bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory"
>           destroy-method="destroy" p:targetConnectionFactory-ref="targetConnectionFactory"
p:reconnectOnException="true"/>
>     <bean id="targetConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"
p:jndiName="${cpp-server.jms.connection.factory.jndi}"
>           p:jndiTemplate-ref="jndiTemplate"/>
>     <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent"
>           p:connectionFactory-ref="connectionFactory"
>           p:destinationResolver-ref="jmsDestinationResolver"/>
>     <alias name="activemq" alias="swiftmq"/>
> So why is registerMBeanWithServer trying to pass off a ManagedCamelContext object
> as an MXBean ?    This can never succeed, and is a bug .  
> Camel should either make this object into an MXBean, or not attempt to register it.
> I'm now having to resort to building a modified version of Camel where the 
> ManagedCamelContext  is an MXBean to overcome this problem  - I cannot see
> what else to do, because users have no control over what object is used to represent
> the camelContext bean or what is done with it - this is internal to Camel .
> I'll attach the patches to this bug report when done.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message