Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring framework - class loader relationship
    primarykey
    data
    text
    <p>I am having a problem which is probably related to the Spring / class loader relationship.</p> <p>I will apologise for the verbosity of the question now.</p> <p>I have a number of legacy java applications which were originally written and intended to run within a dedicated JVM. We decided upon examination of the resource usage that efficiencies could be gained by running multiple applications within a single JVM. Within that context I wrote a container manager specifically designed for our environment which is capable of running each application within a container (or sandbox). The basis of this ability to isolate the containers is of course a custom class loader.</p> <p>All works well until we came across an application which uses the Spring framework. I have a Spring configuration file with fragments as below.</p> <pre><code>&lt;bean id="MDDStructurPackager" class="abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000"&gt; &lt;property name="logger"&gt; &lt;ref local="Logger"/&gt; &lt;/property&gt; &lt;property name="realm"&gt; &lt;value&gt;unpack&lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="Jakarta" class="abc.def.mdd.channel.corba.M2000AlarmChannel"&gt; &lt;constructor-arg&gt; &lt;ref bean="MDDStructurPackager"/&gt; &lt;/constructor-arg&gt; &lt;property name="interactionLayer"&gt; &lt;ref local="MDDInteractionLayer"/&gt; &lt;/property&gt; &lt;property name="logger"&gt; &lt;ref local="Logger"/&gt; &lt;/property&gt; &lt;property name="tempFile" value="/opt/app/abcdef/rt_dev/var/cache/dat/Huawei_M2000_Jakarta.dat"/&gt; &lt;property name="host" value="M2000Jakarta.ior"/&gt; &lt;property name="irpReference" value="clarity"/&gt; &lt;property name="name" value="M2000Jakarta"/&gt; &lt;property name="realm" value="Jakarta"/&gt; &lt;property name="natAddress" value="99.999.99.9" /&gt; &lt;/bean&gt; </code></pre> <p><hr /></p> <p>The following is a fragment from the log file as Spring is instantiating the beans.</p> <p><p> DEBUG [South Agent 1] (DefaultSingletonBeanRegistry.java:162) - Creating shared instance of singleton bean 'MDDStructurPackager' <p> DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:378) - Creating instance of bean 'MDDStructurPackager' <p> DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:453) - Eagerly caching bean 'MDDStructurPackager' to allow for resolving potential circular references <p> DEBUG [South Agent 1] (AbstractBeanFactory.java:213) - Returning cached instance of singleton bean 'Logger' <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:242) - Getting BeanInfo for class [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:258) - Caching PropertyDescriptors for class [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'class' of type [java.lang.Class] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'colectionDate' of type [java.lang.String] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'component' of type [abc.def.mdd.msg.MDDComponent] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'fileType' of type [java.lang.String] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'listCommonWords' of type [java.util.ArrayList] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'listHeader' of type [java.util.ArrayList] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'logger' of type [abc.def.mdd.logger.Logger] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'mapDelimiter' of type [java.util.Map] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'mapElement' of type [java.util.Map] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'namePackager' of type [java.lang.String] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'nameSpaceXMLSchema' of type [java.lang.String] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'nodeName' of type [java.lang.String] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'packageXMLSchema' of type [java.lang.String] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'processingLayerListener' of type [abc.def.mdd.channel.ProcessingLayerListener] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'realm' of type [java.lang.String] <p> DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - Found bean property 'statesObject' of type [java.lang.String] <p> DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:406) - Finished creating instance of bean 'MDDStructurPackager' <p> DEBUG [South Agent 1] (DefaultSingletonBeanRegistry.java:162) - Creating shared instance of singleton bean 'ListAlarmChannel' <p> DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:378) - Creating instance of bean 'ListAlarmChannel' <p> DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:453) - Eagerly caching bean 'ListAlarmChannel' to allow for resolving potential circular references <p> DEBUG [South Agent 1] (DefaultSingletonBeanRegistry.java:162) - Creating shared instance of singleton bean 'Jakarta' <p> DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:378) - Creating instance of bean 'Jakarta' <p> DEBUG [South Agent 1] (AbstractBeanFactory.java:213) - Returning cached instance of singleton bean 'MDDStructurPackager' <p> INFO: CORBA_HUAWEI_M2KJKT_ALARM (23447542): Added "/opt/app/abcdef/rt_dev/lib/logkit-1.2.jar" to the class path. <p> INFO: CORBA_HUAWEI_M2KJKT_ALARM (23447542): Added "/opt/app/abcdef/rt_dev/lib/avalon-framework-4.1.5.jar" to the class path. <p> INFO: CORBA_HUAWEI_M2KJKT_ALARM (23447542): Added "/opt/app/abcdef/rt_dev/lib/concurrent-1.3.2.jar" to the class path. <p> INFO: CORBA_HUAWEI_M2KJKT_ALARM (23447542): Added "/opt/app/abcdef/rt_dev/lib/antlr-2.7.2.jar" to the class path. <p> DEBUG [South Agent 1] (ConstructorResolver.java:195) - <br> Ignoring constructor [public abc.def.mdd.channel.corba.M2000AlarmChannel(<br> java.lang.String, int, java.lang.String, java.lang.String, com.citycorp.mdd.msg.MDDComponent ) throws java.lang.Exception ] <br> of bean 'Jakarta': org.springframework.beans.factory.UnsatisfiedDependencyException: <br> Error creating bean with name 'Jakarta' defined in file [/opt/app/abcdef/rt_dev/etc/HUAWEI_M2KJKT_ALARM.xml]: <br> Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: <br> Could not convert constructor argument value of type [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] to required type [java.lang.String]:<br> Failed to convert value of type [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] to required type [java.lang.String]; <br> nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] to required type [java.lang.String]: <br> no matching editors or conversion strategy found </b> <hr /></p> <p>The following are the signatures of the constructors for the abc.def.mdd.channel.corba.M2000AlarmChannel class:</p> <p>public M2000AlarmChannel( MDDComponent componenet )</p> <p>public M2000AlarmChannel( String host, int port, String username, String password, MDDComponent componenet )</p> <p>The class abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000 implements MDDComponent (bean MDDStructurPackager).</p> <p><hr /></p> <p><hr /></p> <p>As you can see, Spring is instantiating some of the beans ie. MDDStructurPackager without problem.</p> <p>The problem is instantiating the 'Jakarta' bean.</p> <p>The implications of the lines:</p> <p><b> <p> Error creating bean with name 'Jakarta' defined in file [/opt/app/abcdef/rt_dev/etc/HUAWEI_M2KJKT_ALARM.xml]: <p> Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: <p> Could not convert constructor argument value of type [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] to required type [java.lang.String]: <p> </b> are not clear. I am not sure the reasons for the type confusion when attempting to determine the appropriate constructor. It is possible that the problem is associated with the loading of the interface MDDComponent. If it was loaded twice, by different class loaders which are not related in the class loader hierarchy you could imagine problems associated with determining the correct constructor.</p> <p>Any ideas gratefully received, I am grasping at straws.</p> <p>Thanks Bryan</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload