cancel
Showing results for 
Search instead for 
Did you mean: 

NullPointerException when binding model to the context

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello James,

You can use "Invalidate of ARFC Metadata Cache" tool in webdynpro console instead of restarting the server.

Here you can invalidate the metadata cache after reimporting the model.

Best Regards,

Pankaj Sharma

Former Member
0 Kudos

James,

you need to restart the server after the reimporting process.

i think that's the problem

regards,

Former Member
0 Kudos

HI

in the ws navigator provide the input or values to the webservices and execute the webservce

and try to hard code the same values and check . or there may be problem with the

structure node initialization and setting .

There would be classes generated for the structured Nodes for your service and you can find all the

classes in the data modeler on edit on data link from model to controller .

initialization those classes and set the attributes and model according with comparing to the

Webservice structure in the Wsnavigator . this would help you .

Thanks

Former Member
0 Kudos

Hi, i think this null pointer will come in the so many scenarios, but my guess is when your getting the values from model or passing tyhe value to the model its giving this null pointer, may be,

check for the data in the backend are check with all message is there any field is null,]

it better check with use of IF condition before getting or setting the value,

it may help you my friend,

Cheers.

Apparao