You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Ivan Pryvalov <i....@smiss.com.ua> on 2009/01/20 13:01:30 UTC

MBeans in SMX test-classes

Hi!

I have some component (extends 
org.apache.servicemix.common.endpoints.ProviderEndpoint) and in method 
start() it is used getContext().getMBeanServer() for registering some 
mBean. In standalone SMX 3.2.3 it works in correct way, but in tests I 
can not implement it.
getContext().getMBeanServer() returns null.


My test-resources:


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:sm="http://servicemix.apache.org/config/1.0" 	
        xmlns:test="urn:test">


   <sm:container id="jbi" embedded="true" createMBeanServer="true" 
rmiPort="1500">

     <sm:activationSpecs>

       <sm:activationSpec>
       	<sm:component>
             <!--  definition of some component -->
         </sm:component>
       </sm:activationSpec>

     </sm:activationSpecs>
   </sm:container>

</beans>


jndi.properties:

java.naming.factory.initial = 
org.apache.xbean.spring.jndi.SpringInitialContextFactory
java.naming.provider.url = jndi.xml


jndi.xml:

<beans>
   <bean id="jndi"
         class="org.apache.xbean.spring.jndi.SpringInitialContextFactory"
         factory-method="makeInitialContext"
         singleton="true">
     <property name="entries">
       <map>
       </map>
     </property>
   </bean>
</beans>


My output logs during tests are following:

...
2009-01-20 13:50:26,843 [main           ] INFO  JBIContainer 
        - ServiceMix 3.2.3 JB
I Container (ServiceMix) is starting
2009-01-20 13:50:26,843 [main           ] INFO  JBIContainer 
        - For help or more in
formation please see: http://servicemix.apache.org/
2009-01-20 13:50:26,843 [main           ] INFO 
SpringInitialContextFactory    - Loading JNDI contex
t from: class path resource [jndi.xml]
2009-01-20 13:50:26,843 [main           ] INFO 
XBeanXmlBeanDefinitionReader   - Loading XML bean de
finitions from class path resource [jndi.xml]
2009-01-20 13:50:27,031 [main           ] INFO 
ConnectorServerFactoryBean     - JMX connector serve
r started: javax.management.remote.rmi.RMIConnectorServer@cbf9bd
2009-01-20 13:50:27,031 [main           ] INFO 
ConnectorServerFactoryBean     - JMX connector avail
able at: service:jmx:rmi:///jndi/rmi://localhost:1500/jmxrmi
...


It is possible to configure properly test-env in my case?

Thanks,
Truly yours,
Ivan Pryvalov

Re: MBeans in SMX test-classes

Posted by Ivan Pryvalov <i....@smiss.com.ua>.
Guillaume Nodet пишет:
> Try using embedded="false"

Hi Guillame!

It helped. Thanks for hint.

Ivan Pryvalov.

> 
> On Tue, Jan 20, 2009 at 13:01, Ivan Pryvalov <i....@smiss.com.ua> wrote:
>> Hi!
>>
>> I have some component (extends
>> org.apache.servicemix.common.endpoints.ProviderEndpoint) and in method
>> start() it is used getContext().getMBeanServer() for registering some mBean.
>> In standalone SMX 3.2.3 it works in correct way, but in tests I can not
>> implement it.
>> getContext().getMBeanServer() returns null.
>>
>>
>> My test-resources:
>>
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
>>       xmlns:test="urn:test">
>>
>>
>>  <sm:container id="jbi" embedded="true" createMBeanServer="true"
>> rmiPort="1500">
>>
>>    <sm:activationSpecs>
>>
>>      <sm:activationSpec>
>>        <sm:component>
>>            <!--  definition of some component -->
>>        </sm:component>
>>      </sm:activationSpec>
>>
>>    </sm:activationSpecs>
>>  </sm:container>
>>
>> </beans>
>>
>>
>> jndi.properties:
>>
>> java.naming.factory.initial =
>> org.apache.xbean.spring.jndi.SpringInitialContextFactory
>> java.naming.provider.url = jndi.xml
>>
>>
>> jndi.xml:
>>
>> <beans>
>>  <bean id="jndi"
>>        class="org.apache.xbean.spring.jndi.SpringInitialContextFactory"
>>        factory-method="makeInitialContext"
>>        singleton="true">
>>    <property name="entries">
>>      <map>
>>      </map>
>>    </property>
>>  </bean>
>> </beans>
>>
>>
>> My output logs during tests are following:
>>
>> ...
>> 2009-01-20 13:50:26,843 [main           ] INFO  JBIContainer       -
>> ServiceMix 3.2.3 JB
>> I Container (ServiceMix) is starting
>> 2009-01-20 13:50:26,843 [main           ] INFO  JBIContainer       - For
>> help or more in
>> formation please see: http://servicemix.apache.org/
>> 2009-01-20 13:50:26,843 [main           ] INFO SpringInitialContextFactory
>>  - Loading JNDI contex
>> t from: class path resource [jndi.xml]
>> 2009-01-20 13:50:26,843 [main           ] INFO XBeanXmlBeanDefinitionReader
>>   - Loading XML bean de
>> finitions from class path resource [jndi.xml]
>> 2009-01-20 13:50:27,031 [main           ] INFO ConnectorServerFactoryBean
>>   - JMX connector serve
>> r started: javax.management.remote.rmi.RMIConnectorServer@cbf9bd
>> 2009-01-20 13:50:27,031 [main           ] INFO ConnectorServerFactoryBean
>>   - JMX connector avail
>> able at: service:jmx:rmi:///jndi/rmi://localhost:1500/jmxrmi
>> ...
>>
>>
>> It is possible to configure properly test-env in my case?
>>
>> Thanks,
>> Truly yours,
>> Ivan Pryvalov
>>
> 
> 
> 


Re: MBeans in SMX test-classes

Posted by Guillaume Nodet <gn...@gmail.com>.
Try using embedded="false"

On Tue, Jan 20, 2009 at 13:01, Ivan Pryvalov <i....@smiss.com.ua> wrote:
> Hi!
>
> I have some component (extends
> org.apache.servicemix.common.endpoints.ProviderEndpoint) and in method
> start() it is used getContext().getMBeanServer() for registering some mBean.
> In standalone SMX 3.2.3 it works in correct way, but in tests I can not
> implement it.
> getContext().getMBeanServer() returns null.
>
>
> My test-resources:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
>       xmlns:test="urn:test">
>
>
>  <sm:container id="jbi" embedded="true" createMBeanServer="true"
> rmiPort="1500">
>
>    <sm:activationSpecs>
>
>      <sm:activationSpec>
>        <sm:component>
>            <!--  definition of some component -->
>        </sm:component>
>      </sm:activationSpec>
>
>    </sm:activationSpecs>
>  </sm:container>
>
> </beans>
>
>
> jndi.properties:
>
> java.naming.factory.initial =
> org.apache.xbean.spring.jndi.SpringInitialContextFactory
> java.naming.provider.url = jndi.xml
>
>
> jndi.xml:
>
> <beans>
>  <bean id="jndi"
>        class="org.apache.xbean.spring.jndi.SpringInitialContextFactory"
>        factory-method="makeInitialContext"
>        singleton="true">
>    <property name="entries">
>      <map>
>      </map>
>    </property>
>  </bean>
> </beans>
>
>
> My output logs during tests are following:
>
> ...
> 2009-01-20 13:50:26,843 [main           ] INFO  JBIContainer       -
> ServiceMix 3.2.3 JB
> I Container (ServiceMix) is starting
> 2009-01-20 13:50:26,843 [main           ] INFO  JBIContainer       - For
> help or more in
> formation please see: http://servicemix.apache.org/
> 2009-01-20 13:50:26,843 [main           ] INFO SpringInitialContextFactory
>  - Loading JNDI contex
> t from: class path resource [jndi.xml]
> 2009-01-20 13:50:26,843 [main           ] INFO XBeanXmlBeanDefinitionReader
>   - Loading XML bean de
> finitions from class path resource [jndi.xml]
> 2009-01-20 13:50:27,031 [main           ] INFO ConnectorServerFactoryBean
>   - JMX connector serve
> r started: javax.management.remote.rmi.RMIConnectorServer@cbf9bd
> 2009-01-20 13:50:27,031 [main           ] INFO ConnectorServerFactoryBean
>   - JMX connector avail
> able at: service:jmx:rmi:///jndi/rmi://localhost:1500/jmxrmi
> ...
>
>
> It is possible to configure properly test-env in my case?
>
> Thanks,
> Truly yours,
> Ivan Pryvalov
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com