Results 1 to 3 of 3

Thread: Newbie - two JMX spring app. in one web container

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Posts
    8

    Default Newbie - two JMX spring app. in one web container

    Hi

    I'm have problem with running two web apps in one app. server. Both use spring for exporting spring beans on mbean server.
    When I run only one app. everything is OK.

    This is (example) applicationContext.xml for first app:
    Code:
    <?xml version="1.0"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
      <!-- Creates the mbeanServer -->
      <bean id="mbeanServer" 
          class="org.springframework.jmx.support.MBeanServerFactoryBean">
        <property name="locateExistingServerIfPossible" value="true" />
      </bean>
      <!-- RMI registry -->
      <bean id="rmiRegistryFactoryBean" 
          class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
      </bean>
      <bean id="serviceUrl" class="java.lang.String">
        <constructor-arg type="java.lang.String">
          <value>service:jmx:rmi://localhost/jndi/rmi://localhost:1099/jmxrmi</value>
        </constructor-arg>
      </bean>  
      <bean id="jmxServiceURL"
        class="javax.management.remote.JMXServiceURL">
        <constructor-arg>
          <ref local="serviceUrl"/>
        </constructor-arg>
      </bean>
      <bean id="jmxConnectorServer" 
          class="org.springframework.jmx.support.ConnectorServerFactoryBean"
          depends-on="mbeanServer">     
          <property name="serviceUrl">
            <ref local="serviceUrl"/>
          </property>
          <property name="server">
            <ref local="mbeanServer"/>
          </property>
          <property name="environmentMap">
          <map>
            <entry
              key="JMXConnectorServerFactory.PROTOCOL_PROVIDER_PACKAGES">
              <value>MX4JRemoteConstants.PROVIDER_PACKAGES</value>
            </entry>
          </map>      
          </property>
      </bean>
      <!-- exports the beans with the assembler -->
      <bean id="jmxAdapter"
        class="org.springframework.jmx.export.MBeanExporter">
        <property name="beans">
          <map>
            <entry key="appOne:name=TestAppOne">
              <ref local="TestAppOne" />
            </entry>        
          </map>
        </property>
        <property name="server">
          <ref local="mbeanServer" />
        </property>
      </bean>
      <bean id="TestAppOne" class="TestAppOne"/>
    
    </beans>
    applicationContext.xml for second app is similar:
    Code:
    ...
      <!-- exports the beans with the assembler -->
      <bean id="jmxAdapter"
        class="org.springframework.jmx.export.MBeanExporter">
        <property name="beans">
          <map>
            <entry key="appTwo:name=TestAppTwo">
              <ref local="TestAppTwo" />
            </entry>        
          </map>
        </property>
        <property name="server">
          <ref local="mbeanServer" />
        </property>
      </bean>
      <bean id="TestAppTwo" class="TestAppTwo"/>
    ...
    When app. server is started (Orion) first app is started OK (with JMX mbeans exported), but second app throws this excpetion:
    Code:
    Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean wit
    h name 'jmxConnectorServer' defined in ServletContext resource [/WEB-INF/applica
    tionContext.xml]: Error setting property values; nested exception is org.springf
    ramework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsExcept
    ion (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.
    TypeMismatchException: Failed to convert property value of type [org.springframe
    work.jmx.support.MBeanServerFactoryBean] to required type [javax.management.MBea
    nServer] for property 'server']
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property valu
    e of type [org.springframework.jmx.support.MBeanServerFactoryBean] to required t
    ype [javax.management.MBeanServer] for property 'server'
            at org.springframework.beans.BeanWrapperImpl.doTypeConversionIfNecessary
    (BeanWrapperImpl.java:1103)
            at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrappe
    rImpl.java:848)
            at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrappe
    rImpl.java:733)
            at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrappe
    rImpl.java:890)
            at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapp
    erImpl.java:917)
            at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapp
    erImpl.java:906)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1022)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.populateBean(AbstractAutowireCapableBeanFactory.java:823)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFactory.java:345)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
    (AbstractBeanFactory.java:226)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
    (AbstractBeanFactory.java:147)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.
    preInstantiateSingletons(DefaultListableBeanFactory.java:275)
            at org.springframework.context.support.AbstractApplicationContext.refres
    h(AbstractApplicationContext.java:318)
            at org.springframework.web.context.support.AbstractRefreshableWebApplica
    tionContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
            at org.springframework.web.context.ContextLoader.createWebApplicationCon
    text(ContextLoader.java:230)
            at org.springframework.web.context.ContextLoader.initWebApplicationConte
    xt(ContextLoader.java:156)
            at org.springframework.web.context.ContextLoaderListener.contextInitiali
    zed(ContextLoaderListener.java:48)
            at com.evermind._ay._lee(.:552)
            at com.evermind._ay.<init>(.:317)
            at com.evermind._am._rtb(.:607)
            at com.evermind._ex._rtb(.:581)
            at com.evermind._eu._kae(.:482)
            at com.evermind._eu._bi(.:226)
            at com.evermind._ex._bn(.:240)
            at com.evermind._ex._bi(.:146)
            at com.evermind.server.ApplicationServer._gke(.:1730)
            at com.evermind.server.ApplicationServer._bi(.:1068)
            at com.evermind._ctb.run(.:89)
            at java.lang.Thread.run(Thread.java:595)
            at com.evermind._bf.run(.:47)
    I don't understand why is MBeanServerFactoryBean referenced instead od MBeanServer.
    If I deploy only second app. everything runs fine.

    Any ideas?

    Thanks in advance.

    Regards,
    Denis

  2. #2
    Join Date
    Feb 2006
    Posts
    8

    Default

    I found workaround for this problem. When spring.jar, commons-logging.jar and mx4j*.jar was in EAR of every application, I got errors from previous post, but when jars are in Orion's classpath everything forks fine.

    This is good enough for me right now, but I don't understand why spring.jar must be in app. server classpath.

    I tried spring 1.2.6 and 1.2.8, and orion 2.0.2 and 2.0.7.

    Denis

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    classpath problems - some lib from the EAR will load some lib from the server classloader which will try to load some lib from your EAR again but since its not visible it will blow up.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •