kranjcec
Apr 27th, 2006, 04:15 AM
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:
<?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.MBeanServerFactory Bean">
<property name="locateExistingServerIfPossible" value="true" />
</bean>
<!-- RMI registry -->
<bean id="rmiRegistryFactoryBean"
class="org.springframework.remoting.rmi.RmiRegistryFactor yBean">
</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.ConnectorServerFac toryBean"
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_PACKAG ES">
<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:
...
<!-- 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:
Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: 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.MBeanServerFactory Bean] to required t
ype [javax.management.MBeanServer] for property 'server'
at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary
(BeanWrapperImpl.java:1103)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrappe
rImpl.java:848)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrappe
rImpl.java:733)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrappe
rImpl.java:890)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapp
erImpl.java:917)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapp
erImpl.java:906)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapabl eBeanFactory.java:1022)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFa ctory.java:823)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFact ory.java:345)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactor y.java:275)
at org.springframework.context.support.AbstractApplic ationContext.refres
h(AbstractApplicationContext.java:318)
at org.springframework.web.context.support.AbstractRe freshableWebApplica
tionContext.refresh(AbstractRefreshableWebApplicat ionContext.java:134)
at org.springframework.web.context.ContextLoader.crea teWebApplicationCon
text(ContextLoader.java:230)
at org.springframework.web.context.ContextLoader.init WebApplicationConte
xt(ContextLoader.java:156)
at org.springframework.web.context.ContextLoaderListe ner.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
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:
<?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.MBeanServerFactory Bean">
<property name="locateExistingServerIfPossible" value="true" />
</bean>
<!-- RMI registry -->
<bean id="rmiRegistryFactoryBean"
class="org.springframework.remoting.rmi.RmiRegistryFactor yBean">
</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.ConnectorServerFac toryBean"
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_PACKAG ES">
<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:
...
<!-- 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:
Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: 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.MBeanServerFactory Bean] to required t
ype [javax.management.MBeanServer] for property 'server'
at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary
(BeanWrapperImpl.java:1103)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrappe
rImpl.java:848)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrappe
rImpl.java:733)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrappe
rImpl.java:890)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapp
erImpl.java:917)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapp
erImpl.java:906)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapabl eBeanFactory.java:1022)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFa ctory.java:823)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFact ory.java:345)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactor y.java:275)
at org.springframework.context.support.AbstractApplic ationContext.refres
h(AbstractApplicationContext.java:318)
at org.springframework.web.context.support.AbstractRe freshableWebApplica
tionContext.refresh(AbstractRefreshableWebApplicat ionContext.java:134)
at org.springframework.web.context.ContextLoader.crea teWebApplicationCon
text(ContextLoader.java:230)
at org.springframework.web.context.ContextLoader.init WebApplicationConte
xt(ContextLoader.java:156)
at org.springframework.web.context.ContextLoaderListe ner.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