Geek_To_Learn Geek_To_Learn - 14 days ago 6
Java Question

Unable to retrieve instance of Object from bean

I have defined

shipmentProperties.xml
file as:

<bean id = "shipmentProperties" class = "com.amazon.tfs.utils.Record" scope="prototype">
<constructor-arg type = "java.lang.String" value = "shipmentProperties" />
<property name = "schema">
<map>
<entry key = "shipmentProperty" value = "com.abc.xyz.data.types.ShipmentProperty" />
</map>
</property>
</bean>


at some other place I tried to retrieve it by using

myproperties = (Record) ApplicationBean.staticGetNonNullable("shipmentProperties");

if (myproperties == null) {
logger.info("It is pkgGTSDataCreationSstage and shipmentProperties can not be retrieved from bean");
}


ShipmentProperty prop = (ShipmentProperty) myproperties.get(shipmentProperty);

if (prop == null) {
logger.info("Object of class shipmentProperties can not be retrieved from bean");
}


Now the problem is the output which is printed is Object of class
shipmentProperties
can not be retrieved from bean.

I didn't understand why it is not getting instantiated? Can somebody suggest me why this problem occurred?

Answer

ShipmentProperty needs to be marked as a bean as well since the shipmentProperties bean depends on it. Also, I assume the ShipmentProperty class has getters within it?

Comments