Skip to Content
0
Former Member
Nov 20, 2008 at 02:01 PM

NullPointerException when binding model to the context

18 Views

Hi guys,

I have a Web Dynpro project which uses an adaptive web service model to query/modify data. Today I updated the service to return a list instead of a string. Then I got the problem after reimported the model. I got a NullPointerException when binding the model to the context. My data structure is as below:

Request_ImportRelationships (0..n)
    ImportRelationshipList (0..1)
        ImportRelationship (0..n)
            DelegatorId
            DelegatorId
    ImportResponse (0..1)
        ImportResultList (0..1)
            ImportResult (0..n)
                Relationship (1..1)
                    DelegatorId
                    Tenant
                Message

The error I got was:

java.lang.NullPointerException 
    at com.sap.tc.webdynpro.model.webservice.base.model.BaseGenericModelClass.retrieveTargetRoleInfo(BaseGenericModelClass.java:91)
    at com.sap.tc.webdynpro.model.webservice.base.model.BaseGenericModelClass.setRelatedModelObject(BaseGenericModelClass.java:344)
    at com.sap.tc.webdynpro.model.webservice.gci.WSTypedModelClass.setRelatedModelObject(WSTypedModelClass.java:69)

The code in my wdDoInit() method is:

CCTenantModel model = new CCTenantModel();
importRequest = new Request_ImportRelationships(model);
Response_ImportRelationships importResponse = new Response_ImportRelationships(
		model);

TenantRelationshipList tenantRelationshipListToImport = new TenantRelationshipList(
		model);
TenantRelationship tenantRelationshipToImport = new TenantRelationship(
		model);
List<TenantRelationship> tenantList = new ArrayList<TenantRelationship>();
tenantList.add(tenantRelationshipToImport);
tenantRelationshipListToImport.setTenantRelationship(tenantList);
importRequest.setRelationshipList(tenantRelationshipListToImport);


TenantImportResultList importResultList = new TenantImportResultList(model);
TenantImportResult importResult = new TenantImportResult(model);
TenantRelationship relationshipResult = new TenantRelationship(model);
List<TenantImportResult> list = new ArrayList<TenantImportResult>();
list.add(importResult);
importResult.setRelationship(relationshipResult);
importResultList.setImportResult(list);
importResponse.setImportResultList(importResultList);

importRequest.setResponse(importResponse);
wdContext.nodeRequest_ImportRelationships().bind(importRequest);

Can anybody point out what is the problem of the binding here? I could find some examples from the forum but they are a bit different since there are several levels in my app.

Thanks very much!

James