Spring framework - class loader relation

I am having a problem that is probably related to the Spring / class loader relationship.

I apologize for the verbosity of the question.

I have several outdated java applications that were originally written and intended to work in a specialized JVM. We decided to explore the use of resources that could be achieved by running multiple applications within the same JVM. In this context, I wrote a container manager specifically designed for our environment that is able to run each application in a container (or in a sandbox). The basis for this ability to isolate containers, of course, is the custom class loader.

Everything works well until we come across an application that uses the Spring framework. I have a Spring configuration file with fragments as shown below.

<bean id="MDDStructurPackager" class="abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000">
    <property name="logger">
        <ref local="Logger"/>
    </property>
    <property name="realm">
        <value>unpack</value>
    </property>
</bean>

<bean id="Jakarta" class="abc.def.mdd.channel.corba.M2000AlarmChannel">
    <constructor-arg>
        <ref bean="MDDStructurPackager"/>
    </constructor-arg>
    <property name="interactionLayer">
        <ref local="MDDInteractionLayer"/>
    </property>
    <property name="logger">
        <ref local="Logger"/>
    </property>
    <property name="tempFile" value="/opt/app/abcdef/rt_dev/var/cache/dat/Huawei_M2000_Jakarta.dat"/>
    <property name="host" value="M2000Jakarta.ior"/>
    <property name="irpReference" value="clarity"/>
    <property name="name" value="M2000Jakarta"/>
    <property name="realm" value="Jakarta"/>
	<property name="natAddress" value="99.999.99.9" />
</bean>


The following is a snippet from a log file since Spring creates an instance of beans.

DEBUG [South Agent 1] (DefaultSingletonBeanRegistry.java:162) - Create a shared singleton bean instance 'MDDStructurPackager'

DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java{78) - Create an instance of the bean 'MDDStructurPackager'

DEBUG [Southern Agent 1] (AbstractAutowireCapableBeanFactory.java:453) - Sincere caching of the bean 'MDDStructurPackager', allowing to resolve potential circular references

DEBUG [South Agent 1] (AbstractBeanFactory.java:213) - Returning a cached instance of singleton bean 'Logger'

DEBUG [ 1] (CachedIntrospectionResults.java:242) - BeanInfo [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:258) - PropertyDescriptors [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000]

DEBUG [ 1] (CachedIntrospectionResults.java:267) - bean 'class' [java.lang.Class]

DEBUG [ 1] (CachedIntrospectionResults.java:267) - bean 'colectionDate' [java.lang.String]

DEBUG [ 1] (CachedIntrospectionResults.java:267) - < w810 > "" [abc.def.mdd.msg.MDDComponent]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean 'fileType' [java.lang.String]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean 'listCommonWords' [java.util.ArrayList]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean 'listHeader' [java.util.ArrayList]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean "logger" [abc.def.mdd.logger.Logger]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean 'mapDelimiter' [java.util.Map]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean 'mapElement' [java.util.Map]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean 'namePackager' [java.lang.String]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean 'nameSpaceXMLSchema' [java.lang.String]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean 'nodeName' [java.lang.String]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - bean 'packageXMLSchema' [java.lang.String]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - < w810 > LayerListener [abc.def.mdd.channel.ProcessingLayerListener]

DEBUG [South Agent 1] (CachedIntrospectionResults.java:267) - < > w810 > "realm" [java.lang.String]

DEBUG [ 1] (CachedIntrospectionResults.java:267) - bean 'statesObject' [java.lang.String]

DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:406) - bean 'MDDStructurPackager'

DEBUG [South Agent 1] (DefaultSingletonBeanRegistry.java:162) - singleton bean 'ListAlarmChannel'

DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:378) - bean 'ListAlarmChannel'

DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:453) - bean 'ListAlarmChannel',

DEBUG [South Agent 1] (DefaultSingletonBeanRegistry.java:162) - singleton bean 'Jakarta'

DEBUG [South Agent 1] (AbstractAutowireCapableBeanFactory.java:378) - bean 'Jakarta'

DEBUG [South Agent 1] (AbstractBeanFactory.java:213) - singleton bean 'MDDStructurPackager'

INFO: CORBA_HUAWEI_M2KJKT_ALARM (23447542): "/opt/app/abcdef/rt_dev/lib/logkit-1.2.jar" .

INFO: CORBA_HUAWEI_M2KJKT_ALARM (23447542): "/opt/app/abcdef/rt_dev/lib/avalon-framework-4.1.5.jar" .

INFO: CORBA_HUAWEI_M2KJKT_ALARM (23447542): "/opt/app/abcdef/rt_dev/lib/concurrent-1.3.2.jar" .

INFO: CORBA_HUAWEI_M2KJKT_ALARM (23447542): "/opt/app/abcdef/rt_dev/lib/antlr-2.7.2.jar" .

DEBUG [ 1] (ConstructorResolver.java:195) -
   [public abc.def.mdd.channel.corba.M2000AlarmChannel (
                            java.lang.String,                             ,                             java.lang.String,                             java.lang.String,                             com.citycorp.mdd.msg.MDDComponent                           ) java.lang.Exception                        ]
  bean "": org.springframework.beans.factory.UnsatisfiedDependencyException:
   bean "Jakarta", [/opt/app/abcdef/rt_dev/etc/HUAWEI_M2KJKT_ALARM.xml]:
   , 0 [java.lang.String]:
   [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] [java.lang.String]:
   [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] [java.lang.String];
   - java.lang.IllegalArgumentException:    [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] [java.lang.String]:
  


abc.def.mdd.channel.corba.M2000AlarmChannel:

public M2000AlarmChannel ( MDDComponent)

public M2000AlarmChannel (String host, int port, String username, String password, MDDComponent componentenet)

abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000 MDDComponent (bean MDDStructurPackager).



, Spring beans .. MDDStructurPackager .

"" bean.

:

   bean "Jakarta", [/opt/app/abcdef/rt_dev/etc/HUAWEI_M2KJKT_ALARM.xml]:

   , 0 [java.lang.String]:

   [abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000] [java.lang.String]:

. . , MDDComponent. , , , , .

, .

Bryan

+3
3

, Spring :

public M2000AlarmChannel(String host, int port, String username, String password, MDDComponent componenet)

, Spring , , , MDDComponent ( , , - , Spring , . ...).

Spring manual , <constructor-arg>, , :

"":

<bean id="exampleBean" class="examples.ExampleBean">
  <constructor-arg type="int" value="7500000"/>
  <constructor-arg type="java.lang.String" value="42"/>
</bean>

:

<bean id="exampleBean" class="examples.ExampleBean">
  <constructor-arg index="0" value="7500000"/>
  <constructor-arg index="1" value="42"/>
</bean>

(, , )

Spring , .

, , XML , , Spring?

, .

+3

, , . , Jakarta, abc.def.mdd.msg.alarm.huawei.MDDPackagerAlarmM2000, ctor . .

. ?

, . ?

0

Do you run a class AlarmChannel? If so, can you flip the new version that has a print statement in the constructor (you can also use it try-catchin the initializer staticto get the stack trace from which the class is initialized)?

This way you can get an idea of ​​the existence of duplicate classes

Also in the Spring configuration file, you can make it print ClassLoaderwith MethodInvokingFactoryBean- can this also shed light on the question?

0
source

Source: https://habr.com/ru/post/1703315/


All Articles