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

NullPointerException while setting a context

Hi

I am setting a model attribute but it gives the NullPointerException while i use the setter method. that attribute is the input parameter for a web service so i can't able to run the web service as exception is coming

so can any one tell me the solution for this

Thank

Ninad

Add comment
10|10000 characters needed characters exceeded

2 Answers

  • Posted on Aug 02, 2006 at 10:31 AM

    Can you paste the code and the exception you are getting? Is it like u r doing modelclass.setAttributeValue("ABC",null);

    Regards,

    Arun

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Valery,

      I have solved the problem by my own by looking same kind of implimentation in some other web service i have added some more code in doInit method i will paste that code for you but i don't know any thing from that code can you explain me if you get some thing from that.

      		ZstrCpexReceiver[] tab_rec = new ZstrCpexReceiver[1];
      		ZstrCpexReceiver[] tab_mes_rec = new ZstrCpexReceiver[1];
      		ZstrCpexReceiver tab1_rec = new ZstrCpexReceiver();
      		ZstrCpexReceiver tab_mes1_rec = new ZstrCpexReceiver();
      		tab1_rec.setReceiver("");
      		tab_rec[0] = tab1_rec;
      		tab_mes_rec[0] = tab_mes1_rec;
      
      		ZstrCpexSender[] tab_sen = new ZstrCpexSender[1];
      		ZstrCpexSender[] tab_mes_sen = new ZstrCpexSender[1];
      		ZstrCpexSender tab1_sen = new ZstrCpexSender();
      		ZstrCpexSender tab_mes1_sen = new ZstrCpexSender();
      		tab1_sen.setSender("");
      		tab_sen[0] = tab1_sen;
      		tab_mes_sen[0] = tab_mes1_sen;
      
      		ZstrCpexMesstype[] tab_doc = new ZstrCpexMesstype[1];
      		ZstrCpexMesstype[] tab_mes_doc = new ZstrCpexMesstype[1];
      		ZstrCpexMesstype tab1_doc = new ZstrCpexMesstype();
      		ZstrCpexMesstype tab_mes1_doc = new ZstrCpexMesstype();
      		tab1_doc.setDoctype("");
      		tab_doc[0] = tab1_doc;
      		tab_mes_doc[0] = tab_mes1_doc;
      
      		
      		ComplexType_ZcpexGetList comp_getList = new ComplexType_ZcpexGetList();
      		comp_getList.setReceiver(tab_rec);
      		comp_getList.setSender(tab_sen);
      		comp_getList.setDoctype(tab_doc);
      		
      		Request_ZCPEX_GET_LIST_WSD_zcpexGetList request_getList = new Request_ZCPEX_GET_LIST_WSD_zcpexGetList();
      		request_getList.setParameters(comp_getList);
      		request_getList.setResponse(new Response_ZCPEX_GET_LIST_WSD_zcpexGetList());
      		
      		wdContext.nodeEvent_Get_List().bind(request_getList);
      

      here there are 3 internal tables which the webservice is returning Sender,Receiver,Doctype and ZCPEX_GET_LIST_WSD is the function module

      thats it this is the only thing i know in that code and i am binding it to some thing

      so please explain me if you can what this code is doing

      Thanks a lot for your co-operation and help in this matter

      Thanks

      Ninad

  • Posted on Aug 02, 2006 at 11:10 AM

    Well there's no current element at all on which you can set ,hence you get this error. In your WdDoInit() ,create a element like this

    Collection temp = new ArrayList();

    IWDNodeElement ele= wdContext.nodeTestNode().createElement();

    temp.add(ele);

    wdContext.nodeTestNode().bind(temp);

    Then your currentelement should work !

    Regards,

    Arun

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hey that is when generate model from web service. i had one Basic interface. when i map to context element basicrequest(node) for calling web service and basicresponse(node) for return type of same web service.

      Dont confuse with my namings....use your web service accordingly.

      Regards

      Suresh