Skip to Content
author's profile photo Former Member
Former Member

NullPointerException during binding of adaptive webservice model to ui

Hi all

I try to consume a webservice over the adaptive web service model and webdnypro. My scenario is similiar to the tutorial on the sdn about "sending an email over webservices with webdynpro".

My request has the following structure:

[Request_AddNewActivity]
  [AddNewActivity]
    [ActivityData]
      ActivityType - int
      Description - string
      DoneBy - string
      FromDate - date
      Subject - string
      ToDate - date
    ServiceCallId - int
  [AddNewActivity_Response]
    [AddNewActivityResponse]

The webservice has a void return value, therefor there is no field in the response part. I have created a model binding in the context of the component controller and an associated mapping in the view context. Additionally I generated a form by applying the form template to the view and the ActivityData.

In the wdDoInit method of the component controller I initialize the Request_AddNewActivity and bind it to the context:

scServiceModel = new SCServiceModel();
	  
Request_AddNewActivity request = new Request_AddNewActivity(scServiceModel);	  
AddNewActivityRequest addNewActivityRequest = new AddNewActivityRequest(scServiceModel);
Activity activitiy = new Activity(scServiceModel);
addNewActivityRequest.setActivity(activitiy);
request.setAddNewActivity(addNewActivityRequest);
	  
wdContext.nodeRequest_AddNewActivity().bind(request);

When I now open the view, I get a NullPointerException:

java.lang.NullPointerException

    at com.sap.tc.webdynpro.model.webservice.gci.WSTypedModelClass.getAttributeValueAsInt(WSTypedModelClass.java:162)
    at .....netweaver.model.scservice.Activity.getActivityType(Activity.java:47)
    at ...netweaver.viewemployeeservicecalls.wdp.IPublicViewEmployeeServiceCalls$IActivityDataElement.wdGetObject(IPublicViewEmployeeServiceCalls.java:5948)
    at com.sap.tc.webdynpro.progmodel.context.MappedNodeElement.wdGetObject(MappedNodeElement.java:55)
    at com.sap.tc.webdynpro.progmodel.context.AttributePointer.getObject(AttributePointer.java:324)
    ... 104 more

I can avoid the NullPointerException by removing the Activity = new Activity(...) and the addNewActivityRequest.setActivity(...) lines from the wdDoInit Method. Unfortunately the input fields are then disabled in the browser and no data can be entered. What am I doing wrong?

Thanks for your help,

Thierry

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Jul 24, 2008 at 07:28 AM

    Hi,

    Your error shows that there is an error with ActivityType attribute which is "int". what is the value in the backend and is it a import parameter? what you are passing to this attribute or how you are getting this variable?

    error is there in .getActivityType(). while getting the integer value.

    The error is around this attribute only. check this once again.

    PradeeP

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I just try to display an input field on the view, where the int can be entered. I can see that there is an error with this int, but this is strange.

      Hmm... I added two more lines in the wdDoInit method in the component controller where i put the int fields of the model to 0. And now it works. This is a very strange behaviour or better say this is a bug. An int field is a primitive type which should be 0 initialized anyway... Has anyone came accross the same problem?

      Thierry

  • author's profile photo Former Member
    Former Member
    Posted on Jul 24, 2008 at 07:19 AM

    Hi can you tell me what type of Webservice ?

    i mean R/3 or java webservice

    Thanks,

    Tulasi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 24, 2008 at 07:45 AM

    Hi

    Inorder to take Adaptive web service model you should to take Webservice model (deprecated last one) and then it will work.

    let me know

    Thanks,

    Tulasi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 07, 2008 at 09:34 AM

    Hi

    I came across a similar problem to the one above. Again it became a NullPointerException when setting an int field in a model. I figured out that the problem in this case was the server or the deployment. I reimported the model before and it looked like the developer studio didn't completly redeploy the new model and therefor the server didn't know the new field. After restarting the server, the application worked as expected.

    So can anyone tell me please, where one can report bugs?

    Greetings Thierry

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 03:21 PM

    Hi Thierry,

    I just ran into this problem too. Restarting the server did not help, so I have used your workaround, initializing each integer value.

    Did you by any chance find out if there is a fix for this bug?

    Thanks,

    René

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.