cancel
Showing results for 
Search instead for 
Did you mean: 

Cardinality Error from WD when calling an Standard Enterprise Service

Former Member
0 Kudos

Hello,

I dont know why when I run my WD application that is calling the enterprise service "PurchaseOrderByIdQueryResponse_In" I am getting the following error:

java.lang.NullPointerException: Setting related objects to empty collection not allowed for mandatory target role 'Item' of model

class 'pe.com.minsur.wd_po_v7.ecc_purchaseorder002qr.PurchaseOrder' with cardinality 'ONE_TO_MANY'

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Exception was thrown in preprocessing phase of application session ApplicationSession(id=dd04241105e511dfc4bd0017a477042a, name=pe.com.minsur.wd_po_v7.wdpov7_app.Wdpov7_App). The causing exception is nested.

Caused by: java.lang.NullPointerException: Setting related objects to empty collection not allowed for mandatory target role 'Item' of model class 'pe.com.minsur.wd_po_v7.ecc_purchaseorder002qr.PurchaseOrder' with cardinality 'ONE_TO_MANY'

at com.sap.tc.cm.base.model.BaseGenericModelClass.setRelatedModelObjectsInternal(BaseGenericModelClass.java:561)

I dont know if I have to add some code.

Please help

Thanks & Regards

SU

Edited by: soauniverse on Jan 21, 2010 2:30 PM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

usually there is a block like this in wdDoInit()-Method of the component controller.

//$$begin Service Controller

...

java.util.List<yourType> yourlist = new ArrayList<yourType>();

...

//$$end

Because there is no element in this list you get an error.

To avoid this, you can add a line like this:

yourlist.add(new yourType(yourModell));

Regards

Timo

snehal_kendre
Active Contributor
0 Kudos

HI,

Answer to your first question. please check your WD applications is using any GP or BPM (PurchaseOrderByIdQueryResponse)?

it may be the reasson as service automaticaly execute when application starts.

If it is, then you can check the reason for no data coming through it, you can start search from interface controller.

creating the node element or changing its cardinality may solve the problem only if you know root cause.

Former Member
0 Kudos

Open you Context and set the Cardinality of nod PurchaseOrder to 0..*

Former Member
0 Kudos

Hello,

I've changed the property "Selection Cardinality" to 0..n for ITEM node, the property "Collection Cardinality" is disabled for editing. After that I deploy & run the application again, I've got the same exception.

java.lang.NullPointerException: Setting related objects to empty collection not allowed for mandatory target role 'Item' of model class 'pe.com.minsur.wd_po_v7.ecc_purchaseorder002qr.PurchaseOrder' with cardinality 'ONE_TO_MANY'

Thanks

SU

Former Member
0 Kudos

Hi Friend,

Try to create element for that node as follows


wdContext.nodeITEM().createandaddItemElement();
wdContext.currentITEMnodeElement().set<AttributeName>("<AttributeValue>");

Hope it will help. Let us know if any issue persist.

Regards

Jeetendra